[PATCH] D152661: [XRay] Make xray_fn_idx entries PC-relative

2023-06-20 Thread Fangrui Song 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 rGe0a6561ec9ec: [XRay] Make xray_fn_idx entries PC-relative 
(authored by MaskRay).

Changed prior to commit:
  https://reviews.llvm.org/D152661?vs=533131=533132#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152661

Files:
  clang/test/CodeGen/xray-function-index.c
  compiler-rt/lib/xray/xray_interface.cpp
  compiler-rt/lib/xray/xray_interface_internal.h
  llvm/include/llvm/MC/MCContext.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/MC/MCContext.cpp
  llvm/test/CodeGen/AArch64/xray-tail-call-sled.ll
  llvm/test/CodeGen/ARM/xray-armv6-attribute-instrumentation.ll
  llvm/test/CodeGen/ARM/xray-armv7-attribute-instrumentation.ll
  llvm/test/CodeGen/Hexagon/xray.ll
  llvm/test/CodeGen/PowerPC/xray-attribute-instrumentation.ll
  llvm/test/CodeGen/X86/xray-attribute-instrumentation.ll
  llvm/test/CodeGen/X86/xray-partial-instrumentation-skip-entry.ll
  llvm/test/CodeGen/X86/xray-partial-instrumentation-skip-exit.ll
  llvm/test/CodeGen/X86/xray-tail-call-sled.ll
  llvm/test/DebugInfo/X86/xray-split-dwarf-interaction.ll

Index: llvm/test/DebugInfo/X86/xray-split-dwarf-interaction.ll
===
--- llvm/test/DebugInfo/X86/xray-split-dwarf-interaction.ll
+++ llvm/test/DebugInfo/X86/xray-split-dwarf-interaction.ll
@@ -25,7 +25,7 @@
 ; `a::b()` is actually associated with the function's symbol instead of the
 ; .debug_types.dwo section.
 ;
-; CHECK-ASM: xray_fn_idx,"awo",@progbits,_ZN1a1bEv{{$}}
+; CHECK-ASM: xray_fn_idx,"ao",@progbits,_ZN1a1bEv{{$}}
 ;
 ; CHECK-ELF-DAG: [[FSECT:[0-9]+]]] .text._ZN1a1bEv PROGBITS
 ; CHECK-ELF-DAG: [{{.*}}] .debug_types.dwo PROGBITS
Index: llvm/test/CodeGen/X86/xray-tail-call-sled.ll
===
--- llvm/test/CodeGen/X86/xray-tail-call-sled.ll
+++ llvm/test/CodeGen/X86/xray-tail-call-sled.ll
@@ -18,9 +18,10 @@
 ; CHECK-LINUX: .quad .Lxray_sled_0
 ; CHECK-LINUX: .quad .Lxray_sled_1
 ; CHECK-LINUX-LABEL: .Lxray_sleds_end0:
-; CHECK-LINUX-LABEL: .section xray_fn_idx,"awo",@progbits,callee{{$}}
-; CHECK-LINUX: .quad .Lxray_sleds_start0
-; CHECK-LINUX-NEXT:.quad .Lxray_sleds_end0
+; CHECK-LINUX-LABEL: .section xray_fn_idx,"ao",@progbits,callee{{$}}
+; CHECK-LINUX:   [[IDX:\.Lxray_fn_idx[0-9]+]]:
+; CHECK-LINUX-NEXT:.quad .Lxray_sleds_start0-[[IDX]]
+; CHECK-LINUX-NEXT:.quad 2
 
 ; CHECK-MACOS-LABEL: .section __DATA,xray_instr_map,regular,live_support{{$}}
 ; CHECK-MACOS-LABEL: Lxray_sleds_start0:
@@ -28,8 +29,9 @@
 ; CHECK-MACOS: .quad Lxray_sled_1
 ; CHECK-MACOS-LABEL: Lxray_sleds_end0:
 ; CHECK-MACOS-LABEL: .section __DATA,xray_fn_idx,regular,live_support{{$}}
-; CHECK-MACOS: .quad Lxray_sleds_start0
-; CHECK-MACOS-NEXT:.quad Lxray_sleds_end0
+; CHECK-MACOS:   [[IDX:lxray_fn_idx[0-9]+]]:
+; CHECK-MACOS-NEXT:.quad Lxray_sleds_start0-[[IDX]]
+; CHECK-MACOS-NEXT:.quad 2
 
 define dso_local i32 @caller() nounwind noinline uwtable "function-instrument"="xray-always" {
 ; CHECK:   .p2align 1, 0x90
@@ -50,9 +52,10 @@
 ; CHECK-LINUX: .quad .Lxray_sled_2
 ; CHECK-LINUX: .quad .Lxray_sled_3
 ; CHECK-LINUX-LABEL: .Lxray_sleds_end1:
-; CHECK-LINUX-LABEL: .section xray_fn_idx,"awo",@progbits,caller{{$}}
-; CHECK-LINUX: .quad .Lxray_sleds_start1
-; CHECK-LINUX: .quad .Lxray_sleds_end1
+; CHECK-LINUX-LABEL: .section xray_fn_idx,"ao",@progbits,caller{{$}}
+; CHECK-LINUX:   [[IDX:\.Lxray_fn_idx[0-9]+]]:
+; CHECK-LINUX-NEXT:.quad .Lxray_sleds_start1-[[IDX]]
+; CHECK-LINUX-NEXT:.quad 2
 
 ; CHECK-MACOS-LABEL: .section __DATA,xray_instr_map,regular,live_support{{$}}
 ; CHECK-MACOS-LABEL: Lxray_sleds_start1:
@@ -60,5 +63,6 @@
 ; CHECK-MACOS: .quad Lxray_sled_3
 ; CHECK-MACOS-LABEL: Lxray_sleds_end1:
 ; CHECK-MACOS-LABEL: .section __DATA,xray_fn_idx,regular,live_support{{$}}
-; CHECK-MACOS: .quad Lxray_sleds_start1
-; CHECK-MACOS: .quad Lxray_sleds_end1
+; CHECK-MACOS:   [[IDX:lxray_fn_idx[0-9]+]]:
+; CHECK-MACOS-NEXT:.quad Lxray_sleds_start1-[[IDX]]
+; CHECK-MACOS-NEXT:.quad 2
Index: llvm/test/CodeGen/X86/xray-partial-instrumentation-skip-exit.ll
===
--- llvm/test/CodeGen/X86/xray-partial-instrumentation-skip-exit.ll
+++ llvm/test/CodeGen/X86/xray-partial-instrumentation-skip-exit.ll
@@ -55,7 +55,8 @@
 ; CHECK-LINUX: .quad .Lxray_sled_1
 ; CHECK-LINUX-LABEL: .Lxray_sleds_end1:
 ; CHECK-LINUX-LABEL: .section xray_fn_idx,"awo",@progbits,bar{[$}}
-; CHECK-LINUX: .quad .Lxray_sleds_start1
+; CHECK-LINUX:   .Lxray_fn_idx0:
+; CHECK-LINUX-NEXT:.quad .Lxray_sleds_start1-.Lxray_fn_idx0
 ; CHECK-LINUX-NEXT:.quad 

[clang] e0a6561 - [XRay] Make xray_fn_idx entries PC-relative

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

Author: Fangrui Song
Date: 2023-06-20T22:40:56-07:00
New Revision: e0a6561ec9ec10f8c0c43b15dfcbbc3c57d37d3f

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

LOG: [XRay] Make xray_fn_idx entries PC-relative

As mentioned by commit c5d38924dc6688c15b3fa133abeb3626e8f0767c (Apr 2020),
PC-relative entries avoid dynamic relocations and can therefore make the
section read-only.

This is similar to D78082 and D78590. We cannot commit to support
compiler/runtime built at different versions, so just don't play with versions.

For Mach-O support (incomplete yet), we use non-temporary `lxray_fn_idx[0-9]+`
symbols. Label differences are represented as a pair of UNSIGNED and SUBTRACTOR
relocations. The SUBTRACTOR external relocation requires r_extern==1 (needs to
reference a symbol table entry) which can be satisfied by `lxray_fn_idx[0-9]+`.
A `lxray_fn_idx[0-9]+` symbol also serves as the atom for this dead-strippable
section (follow-up to commit b9a134aa629de23a1dcf4be32e946e4e308fc64d).

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

Added: 


Modified: 
clang/test/CodeGen/xray-function-index.c
compiler-rt/lib/xray/xray_interface.cpp
compiler-rt/lib/xray/xray_interface_internal.h
llvm/include/llvm/MC/MCContext.h
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/lib/MC/MCContext.cpp
llvm/test/CodeGen/AArch64/xray-tail-call-sled.ll
llvm/test/CodeGen/ARM/xray-armv6-attribute-instrumentation.ll
llvm/test/CodeGen/ARM/xray-armv7-attribute-instrumentation.ll
llvm/test/CodeGen/Hexagon/xray.ll
llvm/test/CodeGen/PowerPC/xray-attribute-instrumentation.ll
llvm/test/CodeGen/X86/xray-attribute-instrumentation.ll
llvm/test/CodeGen/X86/xray-partial-instrumentation-skip-entry.ll
llvm/test/CodeGen/X86/xray-partial-instrumentation-skip-exit.ll
llvm/test/CodeGen/X86/xray-tail-call-sled.ll
llvm/test/DebugInfo/X86/xray-split-dwarf-interaction.ll

Removed: 




diff  --git a/clang/test/CodeGen/xray-function-index.c 
b/clang/test/CodeGen/xray-function-index.c
index 0b18c2a530247..3c2ead58e91b1 100644
--- a/clang/test/CodeGen/xray-function-index.c
+++ b/clang/test/CodeGen/xray-function-index.c
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 -S -triple x86_64 -fxray-instrument 
-fxray-instruction-threshold=1 %s -o - | FileCheck %s
 // RUN: %clang_cc1 -S -triple x86_64 -fxray-instrument 
-fxray-instruction-threshold=1 -fno-xray-function-index %s -o - | FileCheck %s 
--check-prefix=NO
 
-// CHECK: .section xray_fn_idx,"awo",@progbits,foo
+// CHECK: .section xray_fn_idx,"ao",@progbits,foo
 // NO-NOT: .section xray_fn_idx
 
 void foo(void) {}

diff  --git a/compiler-rt/lib/xray/xray_interface.cpp 
b/compiler-rt/lib/xray/xray_interface.cpp
index af9f11e166ac5..095fc6227217b 100644
--- a/compiler-rt/lib/xray/xray_interface.cpp
+++ b/compiler-rt/lib/xray/xray_interface.cpp
@@ -183,7 +183,7 @@ findFunctionSleds(int32_t FuncId,
   const XRaySledMap ) XRAY_NEVER_INSTRUMENT {
   int32_t CurFn = 0;
   uint64_t LastFnAddr = 0;
-  XRayFunctionSledIndex Index = {nullptr, nullptr};
+  XRayFunctionSledIndex Index = {nullptr, 0};
 
   for (std::size_t I = 0; I < InstrMap.Entries && CurFn <= FuncId; I++) {
 const auto  = InstrMap.Sleds[I];
@@ -196,12 +196,10 @@ findFunctionSleds(int32_t FuncId,
 if (CurFn == FuncId) {
   if (Index.Begin == nullptr)
 Index.Begin = 
-  Index.End = 
+  Index.Size =  - Index.Begin + 1;
 }
   }
 
-  Index.End += 1;
-
   return Index;
 }
 
@@ -235,13 +233,17 @@ XRayPatchingStatus patchFunction(int32_t FuncId,
   }
 
   // Now we patch ths sleds for this specific function.
-  auto SledRange = InstrMap.SledsIndex ? InstrMap.SledsIndex[FuncId - 1]
-   : findFunctionSleds(FuncId, InstrMap);
+  XRayFunctionSledIndex SledRange;
+  if (InstrMap.SledsIndex) {
+SledRange = {InstrMap.SledsIndex[FuncId - 1].fromPCRelative(),
+ InstrMap.SledsIndex[FuncId - 1].Size};
+  } else {
+SledRange = findFunctionSleds(FuncId, InstrMap);
+  }
   auto *f = SledRange.Begin;
-  auto *e = SledRange.End;
   bool SucceedOnce = false;
-  while (f != e)
-SucceedOnce |= patchSled(*f++, Enable, FuncId);
+  for (size_t i = 0; i != SledRange.Size; ++i)
+SucceedOnce |= patchSled(f[i], Enable, FuncId);
 
   atomic_store(, false,
 memory_order_release);
@@ -365,12 +367,17 @@ XRayPatchingStatus mprotectAndPatchFunction(int32_t 
FuncId,
 
   // Here we compute the minimum sled and maximum sled associated with a
   // particular function ID.
-  auto SledRange = InstrMap.SledsIndex ? InstrMap.SledsIndex[FuncId - 1]
-   : findFunctionSleds(FuncId, InstrMap);
+  XRayFunctionSledIndex SledRange;
+  if 

[PATCH] D152661: [XRay] Make xray_fn_idx entries PC-relative

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

Tested on aarch64-linux-gnu and powerpc64le-linux-gnu.

I'll use `createLinkerPrivateSymbol` instead of `createLinkerPrivateTempSymbol` 
since the symbol is not considered `IsTemporary` by MC...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152661

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


[PATCH] D153161: [RISCV] Move Zca/Zcb/Zcd/Zcf/Zcmp/Zcmt out of experimental status.

2023-06-20 Thread Xinlong Wu via Phabricator via cfe-commits
VincentWu added inline comments.



Comment at: clang/test/Driver/riscv-arch.c:376
 
-// RUN: %clang --target=riscv32-unknown-elf -march=rv32izca -### %s \
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32izfa -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-NOFLAG 
%s

does it should be `zca`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153161

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


[PATCH] D152661: [XRay] Make xray_fn_idx entries PC-relative

2023-06-20 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 533131.
MaskRay edited the summary of this revision.
MaskRay added a comment.
Herald added subscribers: cfe-commits, arphaman.
Herald added a project: clang.

fix clang/test/CodeGen/xray-function-index.c


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152661

Files:
  clang/test/CodeGen/xray-function-index.c
  compiler-rt/lib/xray/xray_interface.cpp
  compiler-rt/lib/xray/xray_interface_internal.h
  llvm/include/llvm/MC/MCContext.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/MC/MCContext.cpp
  llvm/test/CodeGen/AArch64/xray-tail-call-sled.ll
  llvm/test/CodeGen/ARM/xray-armv6-attribute-instrumentation.ll
  llvm/test/CodeGen/ARM/xray-armv7-attribute-instrumentation.ll
  llvm/test/CodeGen/Hexagon/xray.ll
  llvm/test/CodeGen/PowerPC/xray-attribute-instrumentation.ll
  llvm/test/CodeGen/X86/xray-attribute-instrumentation.ll
  llvm/test/CodeGen/X86/xray-partial-instrumentation-skip-entry.ll
  llvm/test/CodeGen/X86/xray-partial-instrumentation-skip-exit.ll
  llvm/test/CodeGen/X86/xray-tail-call-sled.ll
  llvm/test/DebugInfo/X86/xray-split-dwarf-interaction.ll

Index: llvm/test/DebugInfo/X86/xray-split-dwarf-interaction.ll
===
--- llvm/test/DebugInfo/X86/xray-split-dwarf-interaction.ll
+++ llvm/test/DebugInfo/X86/xray-split-dwarf-interaction.ll
@@ -25,7 +25,7 @@
 ; `a::b()` is actually associated with the function's symbol instead of the
 ; .debug_types.dwo section.
 ;
-; CHECK-ASM: xray_fn_idx,"awo",@progbits,_ZN1a1bEv{{$}}
+; CHECK-ASM: xray_fn_idx,"ao",@progbits,_ZN1a1bEv{{$}}
 ;
 ; CHECK-ELF-DAG: [[FSECT:[0-9]+]]] .text._ZN1a1bEv PROGBITS
 ; CHECK-ELF-DAG: [{{.*}}] .debug_types.dwo PROGBITS
Index: llvm/test/CodeGen/X86/xray-tail-call-sled.ll
===
--- llvm/test/CodeGen/X86/xray-tail-call-sled.ll
+++ llvm/test/CodeGen/X86/xray-tail-call-sled.ll
@@ -18,9 +18,10 @@
 ; CHECK-LINUX: .quad .Lxray_sled_0
 ; CHECK-LINUX: .quad .Lxray_sled_1
 ; CHECK-LINUX-LABEL: .Lxray_sleds_end0:
-; CHECK-LINUX-LABEL: .section xray_fn_idx,"awo",@progbits,callee{{$}}
-; CHECK-LINUX: .quad .Lxray_sleds_start0
-; CHECK-LINUX-NEXT:.quad .Lxray_sleds_end0
+; CHECK-LINUX-LABEL: .section xray_fn_idx,"ao",@progbits,callee{{$}}
+; CHECK-LINUX:   [[IDX:\.Lxray_fn_idx[0-9]+]]:
+; CHECK-LINUX-NEXT:.quad .Lxray_sleds_start0-[[IDX]]
+; CHECK-LINUX-NEXT:.quad 2
 
 ; CHECK-MACOS-LABEL: .section __DATA,xray_instr_map,regular,live_support{{$}}
 ; CHECK-MACOS-LABEL: Lxray_sleds_start0:
@@ -28,8 +29,9 @@
 ; CHECK-MACOS: .quad Lxray_sled_1
 ; CHECK-MACOS-LABEL: Lxray_sleds_end0:
 ; CHECK-MACOS-LABEL: .section __DATA,xray_fn_idx,regular,live_support{{$}}
-; CHECK-MACOS: .quad Lxray_sleds_start0
-; CHECK-MACOS-NEXT:.quad Lxray_sleds_end0
+; CHECK-MACOS:   [[IDX:lxray_fn_idx[0-9]+]]:
+; CHECK-MACOS-NEXT:.quad Lxray_sleds_start0-[[IDX]]
+; CHECK-MACOS-NEXT:.quad 2
 
 define dso_local i32 @caller() nounwind noinline uwtable "function-instrument"="xray-always" {
 ; CHECK:   .p2align 1, 0x90
@@ -50,9 +52,10 @@
 ; CHECK-LINUX: .quad .Lxray_sled_2
 ; CHECK-LINUX: .quad .Lxray_sled_3
 ; CHECK-LINUX-LABEL: .Lxray_sleds_end1:
-; CHECK-LINUX-LABEL: .section xray_fn_idx,"awo",@progbits,caller{{$}}
-; CHECK-LINUX: .quad .Lxray_sleds_start1
-; CHECK-LINUX: .quad .Lxray_sleds_end1
+; CHECK-LINUX-LABEL: .section xray_fn_idx,"ao",@progbits,caller{{$}}
+; CHECK-LINUX:   [[IDX:\.Lxray_fn_idx[0-9]+]]:
+; CHECK-LINUX-NEXT:.quad .Lxray_sleds_start1-[[IDX]]
+; CHECK-LINUX-NEXT:.quad 2
 
 ; CHECK-MACOS-LABEL: .section __DATA,xray_instr_map,regular,live_support{{$}}
 ; CHECK-MACOS-LABEL: Lxray_sleds_start1:
@@ -60,5 +63,6 @@
 ; CHECK-MACOS: .quad Lxray_sled_3
 ; CHECK-MACOS-LABEL: Lxray_sleds_end1:
 ; CHECK-MACOS-LABEL: .section __DATA,xray_fn_idx,regular,live_support{{$}}
-; CHECK-MACOS: .quad Lxray_sleds_start1
-; CHECK-MACOS: .quad Lxray_sleds_end1
+; CHECK-MACOS:   [[IDX:lxray_fn_idx[0-9]+]]:
+; CHECK-MACOS-NEXT:.quad Lxray_sleds_start1-[[IDX]]
+; CHECK-MACOS-NEXT:.quad 2
Index: llvm/test/CodeGen/X86/xray-partial-instrumentation-skip-exit.ll
===
--- llvm/test/CodeGen/X86/xray-partial-instrumentation-skip-exit.ll
+++ llvm/test/CodeGen/X86/xray-partial-instrumentation-skip-exit.ll
@@ -55,7 +55,8 @@
 ; CHECK-LINUX: .quad .Lxray_sled_1
 ; CHECK-LINUX-LABEL: .Lxray_sleds_end1:
 ; CHECK-LINUX-LABEL: .section xray_fn_idx,"awo",@progbits,bar{[$}}
-; CHECK-LINUX: .quad .Lxray_sleds_start1
+; CHECK-LINUX:   .Lxray_fn_idx0:
+; CHECK-LINUX-NEXT:.quad .Lxray_sleds_start1-.Lxray_fn_idx0
 ; CHECK-LINUX-NEXT:.quad .Lxray_sleds_end1
 
 ; CHECK-MACOS-LABEL: .section 

[PATCH] D153359: [clang][Diagnostics] Fix distant source ranges in bad-conversion notes

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

Can you post a before/after comparison of the exact output for that example?




Comment at: clang/lib/Sema/SemaOverload.cpp:10752
   QualType ToTy = Conv.Bad.getToType();
+  ParmVarDecl *ToPVD = !isObjectArgument ? Fn->getParamDecl(I) : nullptr;
 

Can this be `const`?



Comment at: clang/lib/Sema/SemaOverload.cpp:10752
   QualType ToTy = Conv.Bad.getToType();
+  ParmVarDecl *ToPVD = !isObjectArgument ? Fn->getParamDecl(I) : nullptr;
 

tbaeder wrote:
> Can this be `const`?
Actually, `ToPVD` is only used to access its source range later, isn't it? If 
so, can we just declare the a `ToPVDRange` or something here and use that later 
for diagnostics?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153359

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


[clang] d5bebb3 - [Driver] Allow XRay on Apple Silicon

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

Author: Oleksii Lozovskyi
Date: 2023-06-20T20:47:32-07:00
New Revision: d5bebb3fb402c4ba7e5838d267fa840eee8ecdce

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

LOG: [Driver] Allow XRay on Apple Silicon

Codegen can handle XRay for AArch64, tell the driver to allow it.

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

Added: 


Modified: 
clang/lib/Driver/XRayArgs.cpp
clang/test/Driver/XRay/xray-instrument.c

Removed: 




diff  --git a/clang/lib/Driver/XRayArgs.cpp b/clang/lib/Driver/XRayArgs.cpp
index 427c4ced3cd46..1f397d08237d5 100644
--- a/clang/lib/Driver/XRayArgs.cpp
+++ b/clang/lib/Driver/XRayArgs.cpp
@@ -32,9 +32,14 @@ XRayArgs::XRayArgs(const ToolChain , const ArgList ) 
{
 return;
   XRayInstrument = Args.getLastArg(options::OPT_fxray_instrument);
   if (Triple.isMacOSX()) {
-if (Triple.getArch() != llvm::Triple::x86_64) {
+switch (Triple.getArch()) {
+case llvm::Triple::aarch64:
+case llvm::Triple::x86_64:
+  break;
+default:
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << XRayInstrument->getSpelling() << Triple.str();
+  break;
 }
   } else if (Triple.isOSBinFormatELF()) {
 switch (Triple.getArch()) {

diff  --git a/clang/test/Driver/XRay/xray-instrument.c 
b/clang/test/Driver/XRay/xray-instrument.c
index 430418446366c..4c6b9b12fe9ab 100644
--- a/clang/test/Driver/XRay/xray-instrument.c
+++ b/clang/test/Driver/XRay/xray-instrument.c
@@ -1,4 +1,5 @@
 // RUN: %clang -### --target=aarch64-pc-freebsd -fxray-instrument -c %s -o 
/dev/null 2>&1 | FileCheck %s
+// RUN: %clang -### --target=arm64-apple-macos -fxray-instrument -c %s -o 
/dev/null 2>&1 | FileCheck %s
 // RUN: %clang -### --target=x86_64-apple-darwin -fxray-instrument -c %s -o 
/dev/null 2>&1 | FileCheck %s
 // RUN: %clang -### --target=x86_64-pc-windows -fxray-instrument -c %s -o 
/dev/null 2>&1 | FileCheck %s --check-prefix=ERR
 



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


[PATCH] D145849: [Driver][xray] Allow XRay on Apple Silicon

2023-06-20 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd5bebb3fb402: [Driver] Allow XRay on Apple Silicon (authored 
by ilammy, committed by MaskRay).

Changed prior to commit:
  https://reviews.llvm.org/D145849?vs=530285=533116#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145849

Files:
  clang/lib/Driver/XRayArgs.cpp
  clang/test/Driver/XRay/xray-instrument.c


Index: clang/test/Driver/XRay/xray-instrument.c
===
--- clang/test/Driver/XRay/xray-instrument.c
+++ clang/test/Driver/XRay/xray-instrument.c
@@ -1,4 +1,5 @@
 // RUN: %clang -### --target=aarch64-pc-freebsd -fxray-instrument -c %s -o 
/dev/null 2>&1 | FileCheck %s
+// RUN: %clang -### --target=arm64-apple-macos -fxray-instrument -c %s -o 
/dev/null 2>&1 | FileCheck %s
 // RUN: %clang -### --target=x86_64-apple-darwin -fxray-instrument -c %s -o 
/dev/null 2>&1 | FileCheck %s
 // RUN: %clang -### --target=x86_64-pc-windows -fxray-instrument -c %s -o 
/dev/null 2>&1 | FileCheck %s --check-prefix=ERR
 
Index: clang/lib/Driver/XRayArgs.cpp
===
--- clang/lib/Driver/XRayArgs.cpp
+++ clang/lib/Driver/XRayArgs.cpp
@@ -32,9 +32,14 @@
 return;
   XRayInstrument = Args.getLastArg(options::OPT_fxray_instrument);
   if (Triple.isMacOSX()) {
-if (Triple.getArch() != llvm::Triple::x86_64) {
+switch (Triple.getArch()) {
+case llvm::Triple::aarch64:
+case llvm::Triple::x86_64:
+  break;
+default:
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << XRayInstrument->getSpelling() << Triple.str();
+  break;
 }
   } else if (Triple.isOSBinFormatELF()) {
 switch (Triple.getArch()) {


Index: clang/test/Driver/XRay/xray-instrument.c
===
--- clang/test/Driver/XRay/xray-instrument.c
+++ clang/test/Driver/XRay/xray-instrument.c
@@ -1,4 +1,5 @@
 // RUN: %clang -### --target=aarch64-pc-freebsd -fxray-instrument -c %s -o /dev/null 2>&1 | FileCheck %s
+// RUN: %clang -### --target=arm64-apple-macos -fxray-instrument -c %s -o /dev/null 2>&1 | FileCheck %s
 // RUN: %clang -### --target=x86_64-apple-darwin -fxray-instrument -c %s -o /dev/null 2>&1 | FileCheck %s
 // RUN: %clang -### --target=x86_64-pc-windows -fxray-instrument -c %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR
 
Index: clang/lib/Driver/XRayArgs.cpp
===
--- clang/lib/Driver/XRayArgs.cpp
+++ clang/lib/Driver/XRayArgs.cpp
@@ -32,9 +32,14 @@
 return;
   XRayInstrument = Args.getLastArg(options::OPT_fxray_instrument);
   if (Triple.isMacOSX()) {
-if (Triple.getArch() != llvm::Triple::x86_64) {
+switch (Triple.getArch()) {
+case llvm::Triple::aarch64:
+case llvm::Triple::x86_64:
+  break;
+default:
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << XRayInstrument->getSpelling() << Triple.str();
+  break;
 }
   } else if (Triple.isOSBinFormatELF()) {
 switch (Triple.getArch()) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] e105141 - [Driver] Allow XRay for more architectures on ELF systems

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

Author: Fangrui Song
Date: 2023-06-20T20:41:54-07:00
New Revision: e1051414a16e970c2e36c2ab7dfe2b17353c4751

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

LOG: [Driver] Allow XRay for more architectures on ELF systems

Codegen OS-agnostic for ELF and the runtime is mostly OS-agnostic. It
seems unnecessary to make restriction.

While here, rewrite test/Driver/XRay/xray-instrument*.c to be more conventional:
specify --target= explicitly instead of relying on the configured default target
(which needs `REQUIRES:`).

I am not sure enumerating every supported architecture is useful, so we just 
test a few.

Added: 
clang/test/Driver/XRay/xray-instrument.c

Modified: 
clang/lib/Driver/XRayArgs.cpp

Removed: 
clang/test/Driver/XRay/xray-instrument-cpu.c
clang/test/Driver/XRay/xray-instrument-macos.c
clang/test/Driver/XRay/xray-instrument-os.c



diff  --git a/clang/lib/Driver/XRayArgs.cpp b/clang/lib/Driver/XRayArgs.cpp
index 9a4b28576a9b9..427c4ced3cd46 100644
--- a/clang/lib/Driver/XRayArgs.cpp
+++ b/clang/lib/Driver/XRayArgs.cpp
@@ -31,7 +31,12 @@ XRayArgs::XRayArgs(const ToolChain , const ArgList ) 
{
 options::OPT_fno_xray_instrument, false))
 return;
   XRayInstrument = Args.getLastArg(options::OPT_fxray_instrument);
-  if (Triple.getOS() == llvm::Triple::Linux) {
+  if (Triple.isMacOSX()) {
+if (Triple.getArch() != llvm::Triple::x86_64) {
+  D.Diag(diag::err_drv_unsupported_opt_for_target)
+  << XRayInstrument->getSpelling() << Triple.str();
+}
+  } else if (Triple.isOSBinFormatELF()) {
 switch (Triple.getArch()) {
 case llvm::Triple::x86_64:
 case llvm::Triple::arm:
@@ -47,21 +52,6 @@ XRayArgs::XRayArgs(const ToolChain , const ArgList ) 
{
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << XRayInstrument->getSpelling() << Triple.str();
 }
-  } else if (Triple.isOSFreeBSD() || Triple.isOSOpenBSD() ||
- Triple.isOSNetBSD() || Triple.isMacOSX()) {
-if (Triple.getArch() != llvm::Triple::x86_64) {
-  D.Diag(diag::err_drv_unsupported_opt_for_target)
-  << XRayInstrument->getSpelling() << Triple.str();
-}
-  } else if (Triple.getOS() == llvm::Triple::Fuchsia) {
-switch (Triple.getArch()) {
-case llvm::Triple::x86_64:
-case llvm::Triple::aarch64:
-  break;
-default:
-  D.Diag(diag::err_drv_unsupported_opt_for_target)
-  << XRayInstrument->getSpelling() << Triple.str();
-}
   } else {
 D.Diag(diag::err_drv_unsupported_opt_for_target)
 << XRayInstrument->getSpelling() << Triple.str();

diff  --git a/clang/test/Driver/XRay/xray-instrument-cpu.c 
b/clang/test/Driver/XRay/xray-instrument-cpu.c
deleted file mode 100644
index a8bc2a6431335..0
--- a/clang/test/Driver/XRay/xray-instrument-cpu.c
+++ /dev/null
@@ -1,5 +0,0 @@
-// RUN: not %clang -o /dev/null -v -fxray-instrument -c %s
-// XFAIL: target={{(amd64|x86_64|x86_64h|powerpc64le)-.*}}
-// XFAIL: target={{(arm|aarch64|arm64|mips|mipsel|mips64|mips64el)-.*}}
-// REQUIRES: linux
-typedef int a;

diff  --git a/clang/test/Driver/XRay/xray-instrument-macos.c 
b/clang/test/Driver/XRay/xray-instrument-macos.c
deleted file mode 100644
index ce68345ed019f..0
--- a/clang/test/Driver/XRay/xray-instrument-macos.c
+++ /dev/null
@@ -1,4 +0,0 @@
-// RUN: %clang -o /dev/null -v -fxray-instrument -target 
x86_64-apple-macos10.11 -c %s
-// RUN: %clang -o /dev/null -v -fxray-instrument -target x86_64-apple-darwin15 
-c %s
-// REQUIRES: x86_64 || x86_64h
-typedef int a;

diff  --git a/clang/test/Driver/XRay/xray-instrument-os.c 
b/clang/test/Driver/XRay/xray-instrument-os.c
deleted file mode 100644
index 7a4f1c13cb0b1..0
--- a/clang/test/Driver/XRay/xray-instrument-os.c
+++ /dev/null
@@ -1,4 +0,0 @@
-// RUN: not %clang -o /dev/null -v -fxray-instrument -c %s
-// XFAIL: target={{.*-(linux|freebsd).*}}, 
target=x86_64-apple-{{(darwin|macos).*}}
-// REQUIRES: target={{(amd64|x86_64|x86_64h|arm|aarch64|arm64)-.*}}
-typedef int a;

diff  --git a/clang/test/Driver/XRay/xray-instrument.c 
b/clang/test/Driver/XRay/xray-instrument.c
new file mode 100644
index 0..430418446366c
--- /dev/null
+++ b/clang/test/Driver/XRay/xray-instrument.c
@@ -0,0 +1,8 @@
+// RUN: %clang -### --target=aarch64-pc-freebsd -fxray-instrument -c %s -o 
/dev/null 2>&1 | FileCheck %s
+// RUN: %clang -### --target=x86_64-apple-darwin -fxray-instrument -c %s -o 
/dev/null 2>&1 | FileCheck %s
+// RUN: %clang -### --target=x86_64-pc-windows -fxray-instrument -c %s -o 
/dev/null 2>&1 | FileCheck %s --check-prefix=ERR
+
+// CHECK: "-cc1" {{.*}}"-fxray-instrument"
+// ERR:   error: unsupported option '-fxray-instrument' for target
+
+typedef int a;




[PATCH] D153293: [clang][WebAssembly] support wasm32-wasi shared libraries

2023-06-20 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added a comment.

I'm happy to merge it, but perhaps we should get @sunfish to lg too.

Also, should we remove the `-experimental-pic` linker flag, or are you OK with 
that warning from the linker?   If yes, I wonder if we should do that as part 
of this CL or a followup?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153293

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


[PATCH] D145849: [Driver][xray] Allow XRay on Apple Silicon

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

In D145849#4436623 , @MaskRay wrote:

> In D145849#4430870 , @ilammy wrote:
>
>> In D145849#4412286 , @MaskRay 
>> wrote:
>>
>>> However, `Triple.isMacOSX()` is allowed before the feature actually works 
>>> and `compiler-rt/test/xray/lit.cfg.py` tests it.
>>
>> I have some patches for `compiler-rt` cooking, fixing the build for AArch64. 
>> Should those go in first, before `clang` is ultimately allowed to use 
>> `-fxray-instrument` when targeting AArch64, so that everything works out of 
>> the box?
>>
>> For me, Clang is able to compile binaries with XRay sections (with this 
>> change), but I have `compiler-rt` disabled and not linked in, since it's not 
>> possible to build it for AArch64 yet.
>>
>> I thought it could be done separately. I was not aware of those tests in 
>> compiler-rt, checking all archs.
>>
>> I guess the build should be fixed first, then this change should 
>> simultaneously allow clang to target AArch64 and update compiler-rt's 
>> expectations of what works.
>>
>> How does that sound to you?
>
> Since Mach-O porting is supposed to be done soon, I think landing this change 
> is fine. This patch should make fixing the underlying issue easier as we 
> don't need to locally patch XRayArgs.cpp...
>
> I think D152661  is very much desired and 
> ideally landed before other fixes.

Needs to be rebased first. Hold on. I'll improve the xray-instrument* tests 
soon and you may want to `git pull`:)


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

https://reviews.llvm.org/D145849

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


[PATCH] D145849: [Driver][xray] Allow XRay on Apple Silicon

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

In D145849#4430870 , @ilammy wrote:

> In D145849#4412286 , @MaskRay wrote:
>
>> However, `Triple.isMacOSX()` is allowed before the feature actually works 
>> and `compiler-rt/test/xray/lit.cfg.py` tests it.
>
> I have some patches for `compiler-rt` cooking, fixing the build for AArch64. 
> Should those go in first, before `clang` is ultimately allowed to use 
> `-fxray-instrument` when targeting AArch64, so that everything works out of 
> the box?
>
> For me, Clang is able to compile binaries with XRay sections (with this 
> change), but I have `compiler-rt` disabled and not linked in, since it's not 
> possible to build it for AArch64 yet.
>
> I thought it could be done separately. I was not aware of those tests in 
> compiler-rt, checking all archs.
>
> I guess the build should be fixed first, then this change should 
> simultaneously allow clang to target AArch64 and update compiler-rt's 
> expectations of what works.
>
> How does that sound to you?

Since Mach-O porting is supposed to be done soon, I think landing this change 
is fine. This patch should make fixing the underlying issue easier as we don't 
need to locally patch XRayArgs.cpp...

I think D152661  is very much desired and 
ideally landed before other fixes.


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

https://reviews.llvm.org/D145849

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


[PATCH] D153293: [clang][WebAssembly] support wasm32-wasi shared libraries

2023-06-20 Thread Joel Dice via Phabricator via cfe-commits
dicej added a comment.

@sbc100 Thanks for the "lgtm".  What's the next step to get this merged?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153293

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


[PATCH] D153375: [Clang] Fix incorrect use of direct initialization with copy initialization

2023-06-20 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

It looks like the build failure happens on other PR as well.


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

https://reviews.llvm.org/D153375

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


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

2023-06-20 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Ok whew that's a big patch! I *think* I found a couple of bugs. In any case, 
this code is quickly becoming very complicated, and the functions we're editing 
are rapidly growing out of control. Chopping them up into smaller functions 
with clear separation of concerns would probably help the reader a lot 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153059

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


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

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



Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:2077
+
   for (const auto &[VD, Fixables] : FixablesForUnsafeVars.byVar) {
 FixItsForVariable[VD] =

There's a bug in variable naming: `FixablesForUnsafeVars`actually contains 
fixables for *all* variables. Rashmi correctly renames it in D150489 to reflect 
its actual behavior. So IIUC you're generating fixits for all variables here, 
which is probably not what you want.



Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:2278-2281
+  if (isParameterOf(Impl.first, D))
+ParmsNeedFix.insert(Impl.first);
+  if (isParameterOf(Impl.second, D))
+ParmsNeedFix.insert(Impl.second);

Does this really go in both directions? Shouldn't it be just one direction?

```lang=c++
void foo(int *p) {
  int *q = new int[10];
  p = q;
  q[5] = 7;
}
```
In this case `q` is an unsafe local buffer, but `p` is a (mostly) safe 
single-object pointer that doesn't need fixing, despite implication from `q` to 
`p`. Of course this example is somewhat unrealistic (people don't usually 
overwrite their parameters), but it is also the only situation where the other 
direction matters.



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

What about the situation where params aren't seen as unsafe yet, but they're 
discovered to be unsafe later? Eg.
```
void foo(int *p, int *q) {
  int *p2 = p;
  p2[5] = 7;
  int *q2 = q;
  q2[5] = 7;
}
```
Will we notice that `p` and `q` need to be fixed simultaneously?

---

I suspect that the problem of parameter grouping can't be solved by 
pre-populating strategy implications between all parameters. It'll either cause 
you to implicate all parameters (even the ones that will never need fixing), or 
cause you to miss connections between parameters that do need fixing (as the 
connection is discovered later).

Connection between parameters needs to be added *after* the implications 
algorithm has finished. And once it's there (might be already there if I missed 
something), then this part of code probably becomes unnecessary.



Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:2374-2376
   FixItsForVariableGroup =
   getFixIts(FixablesForAllVars, NaiveStrategy, D->getASTContext(), D,
 Tracker, Handler, VariableGroupsMap);

Note: This is why `FixablesForUnsafeVars` is actually `FixablesForAllVars`.



Comment at: 
clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-multi-parm-span.cpp:13-15
+   expected-note{{change type of 'p' to 'std::span' to preserve bounds 
information, and change 'q' and 'a' to 'std::span' to propagate bounds 
information between them}} \
+   expected-note{{change type of 'q' to 'std::span' to preserve bounds 
information, and change 'p' and 'a' to 'std::span' to propagate bounds 
information between them}} \
+   expected-note{{change type of 'a' to 'std::span' to preserve bounds 
information, and change 'p' and 'q' to 'std::span' to propagate bounds 
information between them}}

QoL thing: //"to propagate bounds information between them"// isn't the correct 
reason in this case. Bounds information doesn't propagate between `p` and `q` 
and `a`. Each of them carries its own, completely unrelated bounds information.

We need to come up with a different reason. Or it might be better to combine 
the warnings into one warning here, so that we didn't need a reason:
```
warning: 'p', 'q' and 'a' are unsafe pointers used for buffer access
note: change type of 'p', 'q' and 'a' to 'std::span' to preserve bounds 
information
```

This gets a bit worse when parameters are implicated indirectly, but it still 
mostly works fine, for example:
```
void foo(int *p, int *q) {
  int *p2 = p;
  p2[5] = 7;
  int *q2 = q;
  q2[5] = 7;
}
```
would produce:
```
warning: 'p2' and 'q2' are unsafe pointers used for buffer access
note: change type of 'p2' and 'q2' to 'std::span' to preserve bounds 
information, and
  change 'p' and 'q' to 'std::span' to propagate bounds information between 
them
```

---

In any case, this shows that the relationship between parameters (grouped 
together simply for being parameters) is very different from the relationship 
within groups of variables implicated by assignments (even if two or more of 
them are parameters). All the way down to the warning/note printer, we probably 
need to continue giving the parameter relationship a special treatment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153059

___
cfe-commits mailing list
cfe-commits@lists.llvm.org

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

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

@ABataev wdyt?


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

https://reviews.llvm.org/D144634

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


[PATCH] D137872: Implement lambdas with inalloca parameters by forwarding to function without inalloca calling convention.

2023-06-20 Thread Amy Huang 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 rG015049338d7e: Try to implement lambdas with inalloca 
parameters by forwarding without use of… (authored by akhuang).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137872

Files:
  clang/include/clang/CodeGen/CGFunctionInfo.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGCall.h
  clang/lib/CodeGen/CGClass.cpp
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CodeGenABITypes.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenTypes.h
  clang/lib/CodeGen/Targets/X86.cpp
  clang/test/CodeGenCXX/inalloca-lambda.cpp

Index: clang/test/CodeGenCXX/inalloca-lambda.cpp
===
--- clang/test/CodeGenCXX/inalloca-lambda.cpp
+++ clang/test/CodeGenCXX/inalloca-lambda.cpp
@@ -1,11 +1,50 @@
-// RUN: not %clang_cc1 -triple i686-windows-msvc -emit-llvm -o /dev/null %s  2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -o - %s  2>&1 | FileCheck %s
 
-// PR28299
-// CHECK: error: cannot compile this forwarded non-trivially copyable parameter yet
-
-class A {
+struct A {
+  A();
   A(const A &);
+  int x;
 };
-typedef void (*fptr_t)(A);
-fptr_t fn1() { return [](A) {}; }
+void decayToFp(int (*f)(A));
+void test() {
+  auto ld = [](A a) {
+static int calls = 0;
+++calls;
+return a.x + calls;
+  };
+  decayToFp(ld);
+  ld(A{});
+}
+
+// CHECK: define internal x86_thiscallcc noundef i32 
+// CHECK-SAME: @"??R@?0??test@@YAXXZ@QBE?A?@@UA@@@Z"
+// CHECK-SAME: (ptr noundef %this, ptr inalloca(<{ %struct.A }>) %[[ARG:.*]])
+// CHECK: %[[V:.*]] = getelementptr inbounds <{ %struct.A }>, ptr %[[ARG]], i32 0, i32 0
+// CHECK: %call = call x86_thiscallcc noundef i32 
+// CHECK-SAME: @"?__impl@@?0??test@@YAXXZ@QBE?A?@@UA@@@Z"
+// CHECK-SAME: (ptr noundef %this, ptr noundef %[[V]])
+
+// CHECK: define internal noundef i32
+// CHECK-SAME: @"?__invoke@@?0??test@@YAXXZ@CA?A?@@UA@@@Z"
+// CHECK-SAME: (ptr inalloca(<{ %struct.A }>) %[[ARG:.*]])
+// CHECK: %unused.capture = alloca %class.anon, align 1
+// CHECK: %[[VAR:.*]] = getelementptr inbounds <{ %struct.A }>, ptr %[[ARG]], i32 0, i32 0
+// CHECK: %call = call x86_thiscallcc noundef i32
+// CHECK-SAME: @"?__impl@@?0??test@@YAXXZ@QBE?A?@@UA@@@Z"
+// CHECK-SAME: (ptr noundef %unused.capture, ptr noundef %[[VAR]])
+// CHECK: ret i32 %call 
 
+// CHECK: define internal x86_thiscallcc noundef i32
+// CHECK-SAME: @"?__impl@@?0??test@@YAXXZ@QBE?A?@@UA@@@Z"
+// CHECK-SAME: (ptr noundef %this, ptr noundef %[[ARG:.*]])
+// CHECK: %this.addr = alloca ptr, align 4
+// CHECK: store ptr %this, ptr %this.addr, align 4
+// CHECK: %this1 = load ptr, ptr %this.addr, align 4
+// CHECK: %{{.*}} = load i32, ptr @"?calls@?1???R
+// CHECK: %inc = add nsw i32 %{{.*}}, 1
+// CHECK: store i32 %inc, ptr @"?calls@?1???R
+// CHECK: %{{.*}} = getelementptr inbounds %struct.A, ptr %{{.*}}, i32 0, i32 0
+// CHECK: %{{.*}} = load i32, ptr %{{.*}}, align 4
+// CHECK: %{{.*}} = load i32, ptr @"?calls@?1???R
+// CHECK: %add = add nsw i32 %{{.*}}, %{{.*}}
+// CHECK: ret i32 %add
Index: clang/lib/CodeGen/Targets/X86.cpp
===
--- clang/lib/CodeGen/Targets/X86.cpp
+++ clang/lib/CodeGen/Targets/X86.cpp
@@ -140,7 +140,8 @@
 
   Class classify(QualType Ty) const;
   ABIArgInfo classifyReturnType(QualType RetTy, CCState ) const;
-  ABIArgInfo classifyArgumentType(QualType RetTy, CCState ) const;
+  ABIArgInfo classifyArgumentType(QualType RetTy, CCState ,
+  bool isDelegateCall) const;
 
   /// Updates the number of available free registers, returns
   /// true if any registers were allocated.
@@ -738,8 +739,8 @@
   }
 }
 
-ABIArgInfo X86_32ABIInfo::classifyArgumentType(QualType Ty,
-   CCState ) const {
+ABIArgInfo X86_32ABIInfo::classifyArgumentType(QualType Ty, CCState ,
+   bool isDelegateCall) const {
   // FIXME: Set alignment on indirect arguments.
   bool IsFastCall = State.CC == llvm::CallingConv::X86_FastCall;
   bool IsRegCall = State.CC == llvm::CallingConv::X86_RegCall;
@@ -752,7 +753,7 @@
   const RecordType *RT = Ty->getAs();
   if (RT) {
 CGCXXABI::RecordArgABI RAA = getRecordArgABI(RT, getCXXABI());
-if (RAA == CGCXXABI::RAA_Indirect) {
+if (RAA == CGCXXABI::RAA_Indirect || isDelegateCall) {
   return getIndirectResult(Ty, false, State);
 } else if (RAA == CGCXXABI::RAA_DirectInMemory) {
   // The field index doesn't matter, we'll fix it up later.
@@ -941,7 +942,8 @@
 if (State.IsPreassigned.test(I))
   continue;
 
-Args[I].info = classifyArgumentType(Args[I].type, State);
+Args[I].info =
+

[clang] 0150493 - Try to implement lambdas with inalloca parameters by forwarding without use of inallocas.

2023-06-20 Thread Amy Huang via cfe-commits

Author: Amy Huang
Date: 2023-06-20T17:30:20-07:00
New Revision: 015049338d7e8e0e81f2ad2f94e5a43e2e3f5220

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

LOG: Try to implement lambdas with inalloca parameters by forwarding without 
use of inallocas.

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

Added: 


Modified: 
clang/include/clang/CodeGen/CGFunctionInfo.h
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CGCall.h
clang/lib/CodeGen/CGClass.cpp
clang/lib/CodeGen/CGDeclCXX.cpp
clang/lib/CodeGen/CodeGenABITypes.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/CodeGen/CodeGenTypes.h
clang/lib/CodeGen/Targets/X86.cpp
clang/test/CodeGenCXX/inalloca-lambda.cpp

Removed: 




diff  --git a/clang/include/clang/CodeGen/CGFunctionInfo.h 
b/clang/include/clang/CodeGen/CGFunctionInfo.h
index 39c7a578c8c4e..b8971d5793f36 100644
--- a/clang/include/clang/CodeGen/CGFunctionInfo.h
+++ b/clang/include/clang/CodeGen/CGFunctionInfo.h
@@ -567,6 +567,10 @@ class CGFunctionInfo final
   /// Whether this is a chain call.
   unsigned ChainCall : 1;
 
+  /// Whether this function is called by forwarding arguments.
+  /// This doesn't support inalloca or varargs.
+  unsigned DelegateCall : 1;
+
   /// Whether this function is a CMSE nonsecure call
   unsigned CmseNSCall : 1;
 
@@ -616,14 +620,11 @@ class CGFunctionInfo final
   CGFunctionInfo() : Required(RequiredArgs::All) {}
 
 public:
-  static CGFunctionInfo *create(unsigned llvmCC,
-bool instanceMethod,
-bool chainCall,
-const FunctionType::ExtInfo ,
-ArrayRef paramInfos,
-CanQualType resultType,
-ArrayRef argTypes,
-RequiredArgs required);
+  static CGFunctionInfo *
+  create(unsigned llvmCC, bool instanceMethod, bool chainCall,
+ bool delegateCall, const FunctionType::ExtInfo ,
+ ArrayRef paramInfos, CanQualType resultType,
+ ArrayRef argTypes, RequiredArgs required);
   void operator delete(void *p) { ::operator delete(p); }
 
   // Friending class TrailingObjects is apparently not good enough for MSVC,
@@ -663,6 +664,8 @@ class CGFunctionInfo final
 
   bool isChainCall() const { return ChainCall; }
 
+  bool isDelegateCall() const { return DelegateCall; }
+
   bool isCmseNSCall() const { return CmseNSCall; }
 
   bool isNoReturn() const { return NoReturn; }
@@ -749,6 +752,7 @@ class CGFunctionInfo final
 ID.AddInteger(getASTCallingConvention());
 ID.AddBoolean(InstanceMethod);
 ID.AddBoolean(ChainCall);
+ID.AddBoolean(DelegateCall);
 ID.AddBoolean(NoReturn);
 ID.AddBoolean(ReturnsRetained);
 ID.AddBoolean(NoCallerSavedRegs);
@@ -766,17 +770,16 @@ class CGFunctionInfo final
 for (const auto  : arguments())
   I.type.Profile(ID);
   }
-  static void Profile(llvm::FoldingSetNodeID ,
-  bool InstanceMethod,
-  bool ChainCall,
+  static void Profile(llvm::FoldingSetNodeID , bool InstanceMethod,
+  bool ChainCall, bool IsDelegateCall,
   const FunctionType::ExtInfo ,
   ArrayRef paramInfos,
-  RequiredArgs required,
-  CanQualType resultType,
+  RequiredArgs required, CanQualType resultType,
   ArrayRef argTypes) {
 ID.AddInteger(info.getCC());
 ID.AddBoolean(InstanceMethod);
 ID.AddBoolean(ChainCall);
+ID.AddBoolean(IsDelegateCall);
 ID.AddBoolean(info.getNoReturn());
 ID.AddBoolean(info.getProducesResult());
 ID.AddBoolean(info.getNoCallerSavedRegs());

diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 61029c9226d7b..a9af9916b8c70 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -111,8 +111,7 @@ 
CodeGenTypes::arrangeFreeFunctionType(CanQual FTNP) {
   // When translating an unprototyped function type, always use a
   // variadic type.
   return arrangeLLVMFunctionInfo(FTNP->getReturnType().getUnqualifiedType(),
- /*instanceMethod=*/false,
- /*chainCall=*/false, std::nullopt,
+ FnInfoOpts::None, std::nullopt,
  FTNP->getExtInfo(), {}, RequiredArgs(0));
 }
 
@@ -188,10 +187,10 @@ arrangeLLVMFunctionInfo(CodeGenTypes , bool 
instanceMethod,
   appendParameterTypes(CGT, prefix, paramInfos, FTP);
   CanQualType resultType = FTP->getReturnType().getUnqualifiedType();
 
-  return 

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

2023-06-20 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

I'll just leave this tiny bit of analysis here, that we did on the whiteboard a 
while ago.

> The "intermediate" overload `void f(std::span, int *)` stays there but 
> usually is not useful. If there are more than two parameters need to be 
> fixed, there will be more such useless "intermediate" overloads.

This isn't even the biggest problem. The bigger problem is that //the process 
doesn't actually stop at Step 2//.

Let me rewrite this more slowly.

Step 0 - the initial code:

  // original body, original signature
  void foo(int *p, int *q, size_t sz) {
 int i = p[5]; // warning: unsafe buffer usage over 'p'
 int j = q[5]; // warning: unsafe buffer usage over 'q'
  }

Step 1 - fix parameter `p`:

  // FIXED: original body, new signature
  void foo(span p, int *q, size_t sz) {
 int i = p[5];
 int j = q[5]; // warning: unsafe buffer usage over 'q'
  }
  
  // NEW: compatibility overload from step 1 - original signature
  [[unsafe_buffer_usage]]
  void f(int *p, int *q, size_t sz) {
 foo(span(p, <#size#>), q, sz);
  }

Step 2 - fix parameter `q` as well:

  // FIXED: original code, even newer signature
  void foo(span p, span q, size_t sz) {
 int i = p[5];
 int j = q[5];
  }
  
  // NEW: compatibility overload from step 2
  [[unsafe_buffer_usage]]
  void foo(span p, int *q, size_t sz) {
 foo(p, span(q, <#size#>), sz);
  }
  
  // UNCHANGED: compatibility overload from step 1 - still carries original 
signature
  [[unsafe_buffer_usage]]
  void foo(int *p, int *q, size_t sz) {
 foo(span(p, sz), q, sz); // warning: unsafe buffer usage over 'q'
  }

Step 3 - now we have a warning inside the overload from step 1 because it's no 
longer calling the newest safe function, but it's now calling the compatibility 
overload from step 2. So we need to change the parameter `q` of the bottom-most 
function to `span`.

  // UNCHANGED: original code, even newer signature - unchanged
  void foo(span p, span q, size_t sz) {
 int i = p[5];
 int j = q[5];
  }
  
  // UNCHANGED: compatibility overload from step 2
  [[unsafe_buffer_usage]]
  void foo(span p, int *q, size_t sz) {
 foo(p, span(q, sz), sz);
  }
  
  // FIXED: compatibility overload from step 1 - new safe signature
  [[unsafe_buffer_usage]]
  void foo(int *p, span q, size_t sz) {
 foo(span(p, sz), q, sz);
  }
  
  // NEW: compatibility overload from step 3 - original signature of the 
overload from step 1, aka simply original signature
  [[unsafe_buffer_usage]]
  [[unsafe_buffer_usage]] // sic!
  void foo(int *p, int *q, size_t sz) {
 foo(p, span(q, <#size#>), sz); // warning: unsafe buffer usage over 
'p'
  }

There are a few things that look wrong here.

The set of overloads still makes sense; we get ourselves 4 overloads in all 
combinations of spans and raw pointers. This on its own makes sense.

We've also somehow got the new raw overload (with two raw pointers) carry //two 
instances// of `[[unsafe_buffer_usage]]`. It lowkey makes sense because the 
function is unsafe with respect to both parameters, but we probably don't want 
people to write such code.

Now, here's where it gets really weird. You'd probably expect that new raw 
overload to call `foo(span(p, sz), span(q, sz), sz)`. If it just did 
that, it'd be perfectly reasonable code. But it doesn't do that! Indeed, by 
design the autogenerated compatibility overload calls the freshly-fixed 
function. Which in case of Step 3 was `foo(int *p, span q, size_t sz)`.

Also, the new raw overload //already has a warning in it//! This is completely 
unacceptable. This happened because the function under fix was already 
annotated as `[[unsafe_buffer_usage]]`. The autofix wouldn't remove the 
attribute; the attribute is still completely appropriate there.

Finally, because there's a new warning, //the process doesn't stop after Step 3 
either//. I'll leave imagining what Step 4 would look like as an easy exercise 
to the reader ^.^



So one way or another, we really don't want to be in the business of 
incrementally fixing parameters one-by-one. Fixing all parameters at once is 
much easier than fixing them incrementally and discarding all analysis state on 
each step. Analysis of "partially spanified" code is much harder than analysis 
of raw C-style code, so we prefer single-step transformation in most cases.

Another direction that we can explore is to avoid auto-fixing functions that 
already carry `[[unsafe_buffer_usage]]`. Indeed, it's already a compatibility 
overload and we know it; it's not *supposed* to be safe! This will prevent Step 
3 from breaking things, so it'll leave us with 3 overloads - not ideal, but not 
incorrect either. It'll also eliminate the "double attribute" problem.

And we ultimately need to explore this direction because no matter how hard we 
avoid automatic partial transformations, people will still do manual partial 
transformations! And when they do, we need to demonstrate some reasonable 

[PATCH] D149443: [ARM] add Thumb-1 8-bit movs/adds relocations to LLVM

2023-06-20 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added inline comments.



Comment at: llvm/test/MC/ARM/thumb-fixups.s:1
+@ RUN: llvm-mc -triple armv6m-unknown-unknown %s --show-encoding > %t
+@ RUN: FileCheck < %t %s

We normally just pipe the output to FileCheck, e.g. `| FileCheck %s`



Comment at: llvm/test/MC/ARM/thumb-fixups.s:9
+
+@ CHECK: movsr3, :upper8_15:_foo @ encoding: [A,0x23]
+@ CHECK-NEXT: @   fixup A - offset: 0, value: _foo, kind: 
fixup_arm_thumb_upper_8_15




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149443

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


[PATCH] D147732: [AMDGPU] Add type mangling for {read, write, readfirst, perm}lane intrinsics

2023-06-20 Thread Jeffrey Byrnes via Phabricator via cfe-commits
jrbyrnes updated this revision to Diff 533080.
jrbyrnes marked 5 inline comments as done.
jrbyrnes added a comment.

Address comments + enable selection of ptr types


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147732

Files:
  clang/include/clang/Basic/BuiltinsAMDGPU.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGenOpenCL/builtins-amdgcn-gfx10.cl
  clang/test/CodeGenOpenCL/builtins-amdgcn.cl
  clang/test/SemaOpenCL/builtins-amdgcn-error-gfx10-param.cl
  llvm/include/llvm/IR/IntrinsicsAMDGPU.td
  llvm/lib/Target/AMDGPU/AMDGPUAtomicOptimizer.cpp
  llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp
  llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
  llvm/lib/Target/AMDGPU/AMDGPULateCodeGenPrepare.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
  llvm/lib/Target/AMDGPU/SIInstructions.td
  llvm/lib/Target/AMDGPU/VOP3Instructions.td
  llvm/test/Analysis/UniformityAnalysis/AMDGPU/intrinsics.ll
  llvm/test/Assembler/autoupgrade-amdgpu-intrinsics.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/atomic_optimizations_mul_one.ll
  llvm/test/CodeGen/AMDGPU/GlobalISel/inst-select-amdgcn.readfirstlane.mir
  llvm/test/CodeGen/AMDGPU/atomic_optimizations_local_pointer.ll
  llvm/test/CodeGen/AMDGPU/global-atomic-scan.ll
  llvm/test/CodeGen/AMDGPU/llvm.amdgcn.permlane.ll
  llvm/test/CodeGen/AMDGPU/llvm.amdgcn.readfirstlane.ll
  llvm/test/CodeGen/AMDGPU/llvm.amdgcn.readlane.ll
  llvm/test/CodeGen/AMDGPU/llvm.amdgcn.writelane.ll
  llvm/test/CodeGen/AMDGPU/permlane-ptr.ll
  llvm/test/Transforms/InstCombine/AMDGPU/amdgcn-intrinsics.ll
  llvm/test/Verifier/AMDGPU/intrinsic-immarg.ll

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


[PATCH] D144911: adding bf16 support to NVPTX

2023-06-20 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: llvm/lib/Target/NVPTX/NVPTXInstrInfo.td:559-568
-multiclass CVT_FROM_FLOAT_SM80 {
-def _f32 :
-  NVPTXInst<(outs RC:$dst),
-(ins Float32Regs:$src, CvtMode:$mode),
-!strconcat("cvt${mode:base}${mode:relu}.",
-FromName, ".f32 \t$dst, $src;"), []>,
-Requires<[hasPTX<70>, hasSM<80>]>;

This is where cvt.rn.relu.bf16.f32  was used to be generated before.

Now we've replaced it with `CVT_FROM_ALL` which does not know anything about 
`relu`.



Comment at: llvm/lib/Target/NVPTX/NVPTXInstrInfo.td:595-596
 FromName, ".f16 \t$dst, $src;"), []>;
+def _bf16 :
+  NVPTXInst<(outs RC:$dst),
+(ins Int16Regs:$src, CvtMode:$mode),

While we're here, it also needs `Requires<[hasPTX<70>, hasSM<80>]>`



Comment at: llvm/lib/Target/NVPTX/NVPTXInstrInfo.td:601
 def _f32 :
   NVPTXInst<(outs RC:$dst),
 (ins Float32Regs:$src, CvtMode:$mode),

We may add an optional `list` argument  to the multiclass and 
do`defm CVT_bf16<... [hasPTX<70>, hasSM<80>]>`



Comment at: llvm/lib/Target/NVPTX/NVPTXInstrInfo.td:603
 (ins Float32Regs:$src, CvtMode:$mode),
 !strconcat("cvt${mode:base}${mode:ftz}${mode:sat}.",
 FromName, ".f32 \t$dst, $src;"), []>;

We also need to augment it with `${mode:relu}` 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144911

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


[PATCH] D137872: Implement lambdas with inalloca parameters by forwarding to function without inalloca calling convention.

2023-06-20 Thread Amy Huang via Phabricator via cfe-commits
akhuang updated this revision to Diff 533079.
akhuang added a comment.

rebase and clang format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137872

Files:
  clang/include/clang/CodeGen/CGFunctionInfo.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGCall.h
  clang/lib/CodeGen/CGClass.cpp
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CodeGenABITypes.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenTypes.h
  clang/lib/CodeGen/Targets/X86.cpp
  clang/test/CodeGenCXX/inalloca-lambda.cpp

Index: clang/test/CodeGenCXX/inalloca-lambda.cpp
===
--- clang/test/CodeGenCXX/inalloca-lambda.cpp
+++ clang/test/CodeGenCXX/inalloca-lambda.cpp
@@ -1,11 +1,50 @@
-// RUN: not %clang_cc1 -triple i686-windows-msvc -emit-llvm -o /dev/null %s  2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple i686-windows-msvc -emit-llvm -o - %s  2>&1 | FileCheck %s
 
-// PR28299
-// CHECK: error: cannot compile this forwarded non-trivially copyable parameter yet
-
-class A {
+struct A {
+  A();
   A(const A &);
+  int x;
 };
-typedef void (*fptr_t)(A);
-fptr_t fn1() { return [](A) {}; }
+void decayToFp(int (*f)(A));
+void test() {
+  auto ld = [](A a) {
+static int calls = 0;
+++calls;
+return a.x + calls;
+  };
+  decayToFp(ld);
+  ld(A{});
+}
+
+// CHECK: define internal x86_thiscallcc noundef i32 
+// CHECK-SAME: @"??R@?0??test@@YAXXZ@QBE?A?@@UA@@@Z"
+// CHECK-SAME: (ptr noundef %this, ptr inalloca(<{ %struct.A }>) %[[ARG:.*]])
+// CHECK: %[[V:.*]] = getelementptr inbounds <{ %struct.A }>, ptr %[[ARG]], i32 0, i32 0
+// CHECK: %call = call x86_thiscallcc noundef i32 
+// CHECK-SAME: @"?__impl@@?0??test@@YAXXZ@QBE?A?@@UA@@@Z"
+// CHECK-SAME: (ptr noundef %this, ptr noundef %[[V]])
+
+// CHECK: define internal noundef i32
+// CHECK-SAME: @"?__invoke@@?0??test@@YAXXZ@CA?A?@@UA@@@Z"
+// CHECK-SAME: (ptr inalloca(<{ %struct.A }>) %[[ARG:.*]])
+// CHECK: %unused.capture = alloca %class.anon, align 1
+// CHECK: %[[VAR:.*]] = getelementptr inbounds <{ %struct.A }>, ptr %[[ARG]], i32 0, i32 0
+// CHECK: %call = call x86_thiscallcc noundef i32
+// CHECK-SAME: @"?__impl@@?0??test@@YAXXZ@QBE?A?@@UA@@@Z"
+// CHECK-SAME: (ptr noundef %unused.capture, ptr noundef %[[VAR]])
+// CHECK: ret i32 %call 
 
+// CHECK: define internal x86_thiscallcc noundef i32
+// CHECK-SAME: @"?__impl@@?0??test@@YAXXZ@QBE?A?@@UA@@@Z"
+// CHECK-SAME: (ptr noundef %this, ptr noundef %[[ARG:.*]])
+// CHECK: %this.addr = alloca ptr, align 4
+// CHECK: store ptr %this, ptr %this.addr, align 4
+// CHECK: %this1 = load ptr, ptr %this.addr, align 4
+// CHECK: %{{.*}} = load i32, ptr @"?calls@?1???R
+// CHECK: %inc = add nsw i32 %{{.*}}, 1
+// CHECK: store i32 %inc, ptr @"?calls@?1???R
+// CHECK: %{{.*}} = getelementptr inbounds %struct.A, ptr %{{.*}}, i32 0, i32 0
+// CHECK: %{{.*}} = load i32, ptr %{{.*}}, align 4
+// CHECK: %{{.*}} = load i32, ptr @"?calls@?1???R
+// CHECK: %add = add nsw i32 %{{.*}}, %{{.*}}
+// CHECK: ret i32 %add
Index: clang/lib/CodeGen/Targets/X86.cpp
===
--- clang/lib/CodeGen/Targets/X86.cpp
+++ clang/lib/CodeGen/Targets/X86.cpp
@@ -140,7 +140,8 @@
 
   Class classify(QualType Ty) const;
   ABIArgInfo classifyReturnType(QualType RetTy, CCState ) const;
-  ABIArgInfo classifyArgumentType(QualType RetTy, CCState ) const;
+  ABIArgInfo classifyArgumentType(QualType RetTy, CCState ,
+  bool isDelegateCall) const;
 
   /// Updates the number of available free registers, returns
   /// true if any registers were allocated.
@@ -738,8 +739,8 @@
   }
 }
 
-ABIArgInfo X86_32ABIInfo::classifyArgumentType(QualType Ty,
-   CCState ) const {
+ABIArgInfo X86_32ABIInfo::classifyArgumentType(QualType Ty, CCState ,
+   bool isDelegateCall) const {
   // FIXME: Set alignment on indirect arguments.
   bool IsFastCall = State.CC == llvm::CallingConv::X86_FastCall;
   bool IsRegCall = State.CC == llvm::CallingConv::X86_RegCall;
@@ -752,7 +753,7 @@
   const RecordType *RT = Ty->getAs();
   if (RT) {
 CGCXXABI::RecordArgABI RAA = getRecordArgABI(RT, getCXXABI());
-if (RAA == CGCXXABI::RAA_Indirect) {
+if (RAA == CGCXXABI::RAA_Indirect || isDelegateCall) {
   return getIndirectResult(Ty, false, State);
 } else if (RAA == CGCXXABI::RAA_DirectInMemory) {
   // The field index doesn't matter, we'll fix it up later.
@@ -941,7 +942,8 @@
 if (State.IsPreassigned.test(I))
   continue;
 
-Args[I].info = classifyArgumentType(Args[I].type, State);
+Args[I].info =
+classifyArgumentType(Args[I].type, State, FI.isDelegateCall());
 UsedInAlloca |= (Args[I].info.getKind() == ABIArgInfo::InAlloca);
   }
 
Index: 

[PATCH] D153233: clang: Add __builtin_elementwise_rint and nearbyint

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



Comment at: clang/docs/LanguageExtensions.rst:656
+  T __builtin_elementwise_nearbyint(T x) round x to the nearest  integer 
value in floating point format,  floating point types
+ rounding according to the current 
rounding direction.
+ May not raise the inexact 
floating-point exception. This is

bob80905 wrote:
> Nit: I don't think a "current rounding direction" exists, and personally 
> don't see the significance of the second half of this sentence.
It does exist, we just happen to ignore floating point environment most of the 
time. The current state of things is we have 3 LLVM intrinsics with the same 
behavior (nearbyint, rint and roundeven). The distinction only exists with fenv 
access / strictfp 



Comment at: clang/lib/Sema/SemaChecking.cpp:18583
   << Callee << CallerTCB;
 }
   }

bob80905 wrote:
> I don't believe you intended to remove all this code in your latest update, 
> did you?
I didn't delete any code?


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

https://reviews.llvm.org/D153233

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


[PATCH] D152504: [clang][ThreadSafety] Analyze cleanup functions

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



Comment at: clang/lib/Analysis/CFG.cpp:1945
+  auto DRE =
+  DeclRefExpr::Create(*Context, {}, {}, VD, false, SourceLocation(),
+  VD->getType(), VK_PRValue);

tbaeder wrote:
> NoQ wrote:
> > Is there a way to attach some valid source locations here, like the source 
> > location of the attribute's identifier argument?
> > 
> > I'm worried that the static analyzer may be unable to consume the CFG 
> > without them, it typically requires source locations for almost arbitrary 
> > statements. I'm still not sure how it'll react to synthetic statements, 
> > maybe turning them into a custom `CFGElement` subclass (like destructors) 
> > would be safer as it'll let all clients of the CFG to treat these in a 
> > custom manner. Otherwise it makes it look like a completely normal 
> > call-expression to the clients, which is not necessarily a good thing.
> Look like I can't query the attribute for any locations except its entire 
> range; I can also just pass `VD->getLocation()` to all locations here.
> 
> I thought doing this without creating fake AST nodes is better as well but I 
> wasn't sure how to do that properly, or if I have to update all consumers of 
> the CFG.
Based on the other comment thread, yeah I think it's better to have a new CFG 
element class than to build synthetic AST. The new element would replace like 
5-6 elements that the synthetic AST would otherwise imply. And it'll have the 
benefit of explicitly indicating that this isn't a "normal" call-expression, 
which is good because it's likely that many clients actually want *at least a 
little bit* of custom logic, that they'll otherwise be unable to implement.

If you don't want to update all clients, the usual thing to do is to add yet 
another flag in `CFG::BuildOptions`, and leave it off by default so that 
different clients could opt-in gradually as they implement support for the new 
element.

Given that thread-safety analysis is an analysis-based warning, and all 
analysis-based warnings share the same CFG, you'll probably still have to 
update the other analysis-based warnings. But there are like 4 of them and all 
their entry points are in the same function so you can easily see what they are.



Comment at: clang/lib/Analysis/CFG.cpp:1951-1952
+
+  SmallVector Args;
+  Args.push_back(DRE);
+  auto A = CallExpr::Create(*Context, F, Args, FD->getType(), VK_PRValue,

tbaeder wrote:
> NoQ wrote:
> > Shouldn't there be a unary operator `&` here somewhere? In your example the 
> > variable is `int` but the function accepts `int *`.
> Hm, I think you are right, but it doesn't make difference for the CFG (at 
> least not for thread anysis), does it? Is there a way for me to test that I 
> pass the right parameter value?
> it doesn't make difference for the CFG

Hmm wait no that's not how it's supposed to be. The CFG is supposed to have 
every sub-expression flattened. So if you're adding
```
CallExpr 'foo'
`- DeclRefExpr 'x'
```
to the CFG, you're supposed to be adding two elements: one for `DeclRefExpr`, 
then one for `CallExpr` *below* it:
```
[B1]
1. DeclRefExpr 'x'
2. CallExpr 'foo([B1.1])'
```
And if you also add a `UnaryOperator`:
```
CallExpr 'foo'
`- UnaryOperator '&'
   `- DeclRefExpr 'x'
```
then it's gotta be three CFG elements:
```
[B1]
1. DeclRefExpr 'x'
2. UnaryOperator '&[B1.1]'
3. CallExpr 'foo([B1.2])'
```

This is what clients expect. This probably doesn't matter for thread safety 
analysis because this `DeclRefExpr` doesn't have any effect on that analysis, 
but other clients expect these expressions to be fully flattened this way. 
(This is especially important in expressions with control flow such as `&&` or 
`?:`.)

Typically `CallExpr`s will also have a `DeclRefExpr` to the callee function as 
a child, probably with some function to pointer decay, which is a couple more 
elements.


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

https://reviews.llvm.org/D152504

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


[PATCH] D153179: [clang codegen] Fix ABI for HVA returns on AArch64 MSVC.

2023-06-20 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

The other thing I'm getting at here is that our TargetInfo.cpp abstraction is 
pretty well built out, even if it's a huge mess. The C++ rules are generally 
platform neutral, and we don't usually have to resort to these kinds of triple 
checks, but sometimes it's the most straightforward approach.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153179

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


[PATCH] D153179: [clang codegen] Fix ABI for HVA returns on AArch64 MSVC.

2023-06-20 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk 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/D153179/new/

https://reviews.llvm.org/D153179

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


[PATCH] D153379: Remove -flang-experimental-exec flag

2023-06-20 Thread Brad Richardson via Phabricator via cfe-commits
everythingfunctional created this revision.
everythingfunctional added reviewers: ktras, rouson, sscalpone, PeteSteinfeld, 
awarzynski.
everythingfunctional added projects: Flang, LLVM.
Herald added subscribers: sunshaoce, jdoerfert, mstorsjo.
Herald added a project: All.
everythingfunctional requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

This removes the need for the `-flang-experimental-exec` flag to generate 
executables.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153379

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  flang/docs/FlangDriver.md
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/linker-flags.f90

Index: flang/test/Driver/linker-flags.f90
===
--- flang/test/Driver/linker-flags.f90
+++ flang/test/Driver/linker-flags.f90
@@ -2,15 +2,15 @@
 ! invocation. These libraries are added on top of other standard runtime
 ! libraries that the Clang driver will include.
 
-! RUN: %flang -### -flang-experimental-exec -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,GNU
-! RUN: %flang -### -flang-experimental-exec -target aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,DARWIN
-! RUN: %flang -### -flang-experimental-exec -target x86_64-windows-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,MINGW
+! RUN: %flang -### -target ppc64le-linux-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,GNU
+! RUN: %flang -### -target aarch64-apple-darwin %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,DARWIN
+! RUN: %flang -### -target x86_64-windows-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,MINGW
 
 ! NOTE: Clang's driver library, clangDriver, usually adds 'libcmt' and
 !   'oldnames' on Windows, but they are not needed when compiling
 !   Fortran code and they might bring in additional dependencies.
 !   Make sure they're not added.
-! RUN: %flang -### -flang-experimental-exec -target aarch64-windows-msvc %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,MSVC --implicit-check-not libcmt --implicit-check-not oldnames
+! RUN: %flang -### -target aarch64-windows-msvc %S/Inputs/hello.f90 2>&1 | FileCheck %s --check-prefixes=CHECK,MSVC --implicit-check-not libcmt --implicit-check-not oldnames
 
 ! Compiler invocation to generate the object file
 ! CHECK-LABEL: {{.*}} "-emit-obj"
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -39,8 +39,6 @@
 ! CHECK-NEXT: -finput-charset= Specify the default character set for source files
 ! CHECK-NEXT: -fintrinsic-modules-path 
 ! CHECK-NEXT:Specify where to find the compiled intrinsic modules
-! CHECK-NEXT: -flang-experimental-exec
-! CHECK-NEXT:Enable support for generating executables (experimental)
 ! CHECK-NEXT: -flang-experimental-hlfir
 ! CHECK-NEXT:Use HLFIR lowering (experimental)
 ! CHECK-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
Index: flang/docs/FlangDriver.md
===
--- flang/docs/FlangDriver.md
+++ flang/docs/FlangDriver.md
@@ -149,11 +149,6 @@
 +- 3: backend, {2}, assembler
 4: assembler, {3}, object
 ```
-Note that currently Flang does not support code-generation and `flang-new` will
-fail during the second step above with the following error:
-```bash
-error: code-generation is not available yet
-```
 The other phases are printed nonetheless when using `-ccc-print-phases`, as
 that reflects what `clangDriver`, the library, will try to create and run.
 
@@ -330,16 +325,13 @@
 supported Fortran compiler. You can configure your CMake projects to use
 `flang-new` as follows:
 ```bash
-cmake -DCMAKE_Fortran_FLAGS="-flang-experimental-exec" -DCMAKE_Fortran_COMPILER= 
+cmake -DCMAKE_Fortran_COMPILER= 
 ```
 You should see the following in the output:
 ```
 -- The Fortran compiler identification is LLVMFlang 
 ```
-where `` corresponds to the LLVM Flang version. Note that while
-generating executables remains experimental, you will need to inform CMake to
-use the `-flang-experimental-exec` flag when invoking `flang-new` as in the
-example above.
+where `` corresponds to the LLVM Flang version.
 
 # Testing
 In LIT, we define two variables that you can use to invoke Flang's drivers:
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -935,12 +935,6 @@
 void 

[PATCH] D153179: [clang codegen] Fix ABI for HVA returns on AArch64 MSVC.

2023-06-20 Thread Eli Friedman via Phabricator via cfe-commits
efriedma updated this revision to Diff 533050.
efriedma added a comment.

Upload correct diff.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153179

Files:
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/test/CodeGenCXX/homogeneous-aggregates.cpp


Index: clang/test/CodeGenCXX/homogeneous-aggregates.cpp
===
--- clang/test/CodeGenCXX/homogeneous-aggregates.cpp
+++ clang/test/CodeGenCXX/homogeneous-aggregates.cpp
@@ -285,3 +285,20 @@
 double foo(HFA v) { return v.x + v.y; }
 // WOA64: define dso_local noundef double 
@"?foo@non_empty_field@@YANUHFA@1@@Z"([4 x double] %{{.*}})
 }
+
+namespace pr62223 {
+// HVAs don't follow the normal rules for return values. That means they can
+// have base classes, user-defined ctors, and protected/private members.
+// (The same restrictions that apply to HVA arguments still apply.)
+typedef double V __attribute((ext_vector_type(2)));
+struct base { V v; };
+struct test : base { test(double); protected: V v2;};
+test f(test *x) { return *x; }
+// WOA64: define dso_local %"struct.pr62223::test" 
@"?f@pr62223@@YA?AUtest@1@PEAU21@@Z"(ptr noundef %{{.*}})
+
+// The above rule only apples to HVAs, not HFAs.
+struct base2 { double v; };
+struct test2 : base2 { test2(double); protected: double v2;};
+test2 f(test2 *x) { return *x; }
+// WOA64: define dso_local void @"?f@pr62223@@YA?AUtest2@1@PEAU21@@Z"(ptr 
inreg noalias sret(%"struct.pr62223::test2") align 8 %{{.*}}, ptr noundef 
%{{.*}})
+}
Index: clang/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -13,6 +13,7 @@
 //
 
//===--===//
 
+#include "ABIInfo.h"
 #include "CGCXXABI.h"
 #include "CGCleanup.h"
 #include "CGVTables.h"
@@ -1099,7 +1100,19 @@
   return isDeletingDtor(GD);
 }
 
-static bool isTrivialForMSVC(const CXXRecordDecl *RD) {
+static bool isTrivialForMSVC(const CXXRecordDecl *RD, QualType Ty,
+ CodeGenModule ) {
+  // On AArch64, HVAs that can be passed in registers can also be returned
+  // in registers. (Note this is using the MSVC definition of an HVA; see
+  // isPermittedToBeHomogeneousAggregate().)
+  const Type *Base = nullptr;
+  uint64_t NumElts = 0;
+  if (CGM.getTarget().getTriple().isAArch64() &&
+  CGM.getTypes().getABIInfo().isHomogeneousAggregate(Ty, Base, NumElts) &&
+  isa(Base)) {
+return true;
+  }
+
   // We use the C++14 definition of an aggregate, so we also
   // check for:
   //   No private or protected non static data members.
@@ -1128,7 +1141,8 @@
   if (!RD)
 return false;
 
-  bool isTrivialForABI = RD->canPassInRegisters() && isTrivialForMSVC(RD);
+  bool isTrivialForABI = RD->canPassInRegisters() &&
+ isTrivialForMSVC(RD, FI.getReturnType(), CGM);
 
   // MSVC always returns structs indirectly from C++ instance methods.
   bool isIndirectReturn = !isTrivialForABI || FI.isInstanceMethod();


Index: clang/test/CodeGenCXX/homogeneous-aggregates.cpp
===
--- clang/test/CodeGenCXX/homogeneous-aggregates.cpp
+++ clang/test/CodeGenCXX/homogeneous-aggregates.cpp
@@ -285,3 +285,20 @@
 double foo(HFA v) { return v.x + v.y; }
 // WOA64: define dso_local noundef double @"?foo@non_empty_field@@YANUHFA@1@@Z"([4 x double] %{{.*}})
 }
+
+namespace pr62223 {
+// HVAs don't follow the normal rules for return values. That means they can
+// have base classes, user-defined ctors, and protected/private members.
+// (The same restrictions that apply to HVA arguments still apply.)
+typedef double V __attribute((ext_vector_type(2)));
+struct base { V v; };
+struct test : base { test(double); protected: V v2;};
+test f(test *x) { return *x; }
+// WOA64: define dso_local %"struct.pr62223::test" @"?f@pr62223@@YA?AUtest@1@PEAU21@@Z"(ptr noundef %{{.*}})
+
+// The above rule only apples to HVAs, not HFAs.
+struct base2 { double v; };
+struct test2 : base2 { test2(double); protected: double v2;};
+test2 f(test2 *x) { return *x; }
+// WOA64: define dso_local void @"?f@pr62223@@YA?AUtest2@1@PEAU21@@Z"(ptr inreg noalias sret(%"struct.pr62223::test2") align 8 %{{.*}}, ptr noundef %{{.*}})
+}
Index: clang/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -13,6 +13,7 @@
 //
 //===--===//
 
+#include "ABIInfo.h"
 #include "CGCXXABI.h"
 #include "CGCleanup.h"
 #include "CGVTables.h"
@@ -1099,7 +1100,19 @@
   return isDeletingDtor(GD);
 }
 
-static bool isTrivialForMSVC(const CXXRecordDecl *RD) {
+static bool isTrivialForMSVC(const 

[PATCH] D144911: adding bf16 support to NVPTX

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

fixing bf16 test cases


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/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,142 @@
+; 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 %}
+
+; LDST: .b8 bfloat_array[8] = {1, 2, 3, 4, 5, 6, 7, 8};
+@"bfloat_array" = addrspace(1) constant [4 x bfloat]
+[bfloat 0xR0201, bfloat 0xR0403, bfloat 0xR0605, bfloat 0xR0807]
+  
+; 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
+}
+
+; CHECK-LABEL: test_extract_0(
+; CHECK:  ld.param.b16[[A:%rs[0-9]+]], [test_extract_0_param_0];
+; CHECK:  st.param.b16[func_retval0+0], [[A]];
+; CHECK:  ret;
+
+define bfloat @test_extract_0(<2 x bfloat> %a) #0 {
+  %e = extractelement <2 x bfloat> %a, i32 0
+  ret bfloat %e
+}
+
+; CHECK-LABEL: test_extract_1(
+; CHECK:  

[PATCH] D153179: [clang codegen] Fix ABI for HVA returns on AArch64 MSVC.

2023-06-20 Thread Eli Friedman via Phabricator via cfe-commits
efriedma updated this revision to Diff 533049.
efriedma added a comment.

Fix typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153179

Files:
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/test/CodeGenCXX/homogeneous-aggregates.cpp


Index: clang/test/CodeGenCXX/homogeneous-aggregates.cpp
===
--- clang/test/CodeGenCXX/homogeneous-aggregates.cpp
+++ clang/test/CodeGenCXX/homogeneous-aggregates.cpp
@@ -285,3 +285,20 @@
 double foo(HFA v) { return v.x + v.y; }
 // WOA64: define dso_local noundef double 
@"?foo@non_empty_field@@YANUHFA@1@@Z"([4 x double] %{{.*}})
 }
+
+namespace pr62223 {
+// HVAs don't follow the normal rules for return values. That means they can
+// have base classes, user-defined ctors, and protected/private members.
+// (The same restrictions that apply to HVA arguments still apply.)
+typedef double V __attribute((ext_vector_type(2)));
+struct base { V v; };
+struct test : base { test(double); protected: V v2;};
+test f(test *x) { return *x; }
+// WOA64: define dso_local %"struct.pr62223::test" 
@"?f@pr62223@@YA?AUtest@1@PEAU21@@Z"(ptr noundef %{{.*}})
+
+// The above rule only apples to HVAs, not HFAs.
+struct base2 { double v; };
+struct test2 : base2 { test2(double); protected: double v2;};
+test2 f(test2 *x) { return *x; }
+// WOA64: define dso_local void @"?f@pr62223@@YA?AUtest2@1@PEAU21@@Z"(ptr 
inreg noalias sret(%"struct.pr62223::test2") align 16 %{{.*}}, ptr noundef 
%{{.*}})
+}
Index: clang/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -13,6 +13,7 @@
 //
 
//===--===//
 
+#include "ABIInfo.h"
 #include "CGCXXABI.h"
 #include "CGCleanup.h"
 #include "CGVTables.h"
@@ -1099,7 +1100,19 @@
   return isDeletingDtor(GD);
 }
 
-static bool isTrivialForMSVC(const CXXRecordDecl *RD) {
+static bool isTrivialForMSVC(const CXXRecordDecl *RD, QualType Ty,
+ CodeGenModule ) {
+  // On AArch64, HVAs that can be passed in registers can also be returned
+  // in registers. (Note this is using the MSVC definition of an HVA; see
+  // isPermittedToBeHomogeneousAggregate().)
+  const Type *Base = nullptr;
+  uint64_t NumElts = 0;
+  if (CGM.getTarget().getTriple().isAArch64() &&
+  CGM.getTypes().getABIInfo().isHomogeneousAggregate(Ty, Base, NumElts) &&
+  isa(Base)) {
+return true;
+  }
+
   // We use the C++14 definition of an aggregate, so we also
   // check for:
   //   No private or protected non static data members.
@@ -1128,7 +1141,8 @@
   if (!RD)
 return false;
 
-  bool isTrivialForABI = RD->canPassInRegisters() && isTrivialForMSVC(RD);
+  bool isTrivialForABI = RD->canPassInRegisters() &&
+ isTrivialForMSVC(RD, FI.getReturnType(), CGM);
 
   // MSVC always returns structs indirectly from C++ instance methods.
   bool isIndirectReturn = !isTrivialForABI || FI.isInstanceMethod();


Index: clang/test/CodeGenCXX/homogeneous-aggregates.cpp
===
--- clang/test/CodeGenCXX/homogeneous-aggregates.cpp
+++ clang/test/CodeGenCXX/homogeneous-aggregates.cpp
@@ -285,3 +285,20 @@
 double foo(HFA v) { return v.x + v.y; }
 // WOA64: define dso_local noundef double @"?foo@non_empty_field@@YANUHFA@1@@Z"([4 x double] %{{.*}})
 }
+
+namespace pr62223 {
+// HVAs don't follow the normal rules for return values. That means they can
+// have base classes, user-defined ctors, and protected/private members.
+// (The same restrictions that apply to HVA arguments still apply.)
+typedef double V __attribute((ext_vector_type(2)));
+struct base { V v; };
+struct test : base { test(double); protected: V v2;};
+test f(test *x) { return *x; }
+// WOA64: define dso_local %"struct.pr62223::test" @"?f@pr62223@@YA?AUtest@1@PEAU21@@Z"(ptr noundef %{{.*}})
+
+// The above rule only apples to HVAs, not HFAs.
+struct base2 { double v; };
+struct test2 : base2 { test2(double); protected: double v2;};
+test2 f(test2 *x) { return *x; }
+// WOA64: define dso_local void @"?f@pr62223@@YA?AUtest2@1@PEAU21@@Z"(ptr inreg noalias sret(%"struct.pr62223::test2") align 16 %{{.*}}, ptr noundef %{{.*}})
+}
Index: clang/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -13,6 +13,7 @@
 //
 //===--===//
 
+#include "ABIInfo.h"
 #include "CGCXXABI.h"
 #include "CGCleanup.h"
 #include "CGVTables.h"
@@ -1099,7 +1100,19 @@
   return isDeletingDtor(GD);
 }
 
-static bool isTrivialForMSVC(const CXXRecordDecl *RD) {
+static bool isTrivialForMSVC(const CXXRecordDecl 

[PATCH] D152741: [WPD] implement -fskip-vtable-filepaths

2023-06-20 Thread Di Mo via Phabricator via cfe-commits
modimo updated this revision to Diff 533048.
modimo added a comment.

Remove leftover code from original implementation


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152741

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGVTables.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenCXX/type-metadata-skip-vtable-filepaths.cpp
  clang/test/Driver/fskip-vtable-filepaths.c
  llvm/include/llvm/IR/GlobalObject.h
  llvm/lib/IR/Metadata.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  llvm/test/ThinLTO/X86/devirt.ll

Index: llvm/test/ThinLTO/X86/devirt.ll
===
--- llvm/test/ThinLTO/X86/devirt.ll
+++ llvm/test/ThinLTO/X86/devirt.ll
@@ -42,9 +42,11 @@
 ; RUN:   -r=%t2.o,_ZN1B1fEi,p \
 ; RUN:   -r=%t2.o,_ZN1C1fEi,p \
 ; RUN:   -r=%t2.o,_ZN1D1mEi,p \
+; RUN:   -r=%t2.o,_ZN1E1nEi,p \
 ; RUN:   -r=%t2.o,_ZTV1B,px \
 ; RUN:   -r=%t2.o,_ZTV1C,px \
-; RUN:   -r=%t2.o,_ZTV1D,px 2>&1 | FileCheck %s --check-prefix=REMARK
+; RUN:   -r=%t2.o,_ZTV1D,px \
+; RUN:   -r=%t2.o,_ZTV1F,px 2>&1 | FileCheck %s --check-prefix=REMARK
 ; RUN: llvm-dis %t3.1.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR
 
 ; Check that we're able to prevent specific function from being
@@ -58,9 +60,11 @@
 ; RUN:   -r=%t2.o,_ZN1B1fEi,p \
 ; RUN:   -r=%t2.o,_ZN1C1fEi,p \
 ; RUN:   -r=%t2.o,_ZN1D1mEi,p \
+; RUN:   -r=%t2.o,_ZN1E1nEi,p \
 ; RUN:   -r=%t2.o,_ZTV1B,px \
 ; RUN:   -r=%t2.o,_ZTV1C,px \
-; RUN:   -r=%t2.o,_ZTV1D,px 2>&1 | FileCheck %s --check-prefix=SKIP
+; RUN:   -r=%t2.o,_ZTV1D,px \
+; RUN:   -r=%t2.o,_ZTV1F,px 2>&1 | FileCheck %s --check-prefix=SKIP
 
 ; RUN: llvm-lto2 run %t.o -save-temps -pass-remarks=. \
 ; RUN:   -whole-program-visibility \
@@ -70,16 +74,20 @@
 ; RUN:   -r=%t.o,_ZN1B1fEi,p \
 ; RUN:   -r=%t.o,_ZN1C1fEi,p \
 ; RUN:   -r=%t.o,_ZN1D1mEi,p \
+; RUN:   -r=%t.o,_ZN1E1nEi,p \
 ; RUN:   -r=%t.o,_ZTV1B, \
 ; RUN:   -r=%t.o,_ZTV1C, \
 ; RUN:   -r=%t.o,_ZTV1D, \
+; RUN:   -r=%t.o,_ZTV1F, \
 ; RUN:   -r=%t.o,_ZN1A1nEi, \
 ; RUN:   -r=%t.o,_ZN1B1fEi, \
 ; RUN:   -r=%t.o,_ZN1C1fEi, \
 ; RUN:   -r=%t.o,_ZN1D1mEi, \
+; RUN:   -r=%t.o,_ZN1E1nEi, \
 ; RUN:   -r=%t.o,_ZTV1B,px \
 ; RUN:   -r=%t.o,_ZTV1C,px \
-; RUN:   -r=%t.o,_ZTV1D,px 2>&1 | FileCheck %s --check-prefix=REMARK --dump-input=fail
+; RUN:   -r=%t.o,_ZTV1D,px \
+; RUN:   -r=%t.o,_ZTV1F,px 2>&1 | FileCheck %s --check-prefix=REMARK --dump-input=fail
 ; RUN: llvm-dis %t3.1.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR
 
 ; REMARK-DAG: single-impl: devirtualized a call to _ZN1A1nEi
@@ -95,13 +103,18 @@
 %struct.C = type { %struct.A }
 %struct.D = type { ptr }
 
+%struct.E = type { ptr }
+%struct.F = type { %struct.E }
+
 @_ZTV1B = constant { [4 x ptr] } { [4 x ptr] [ptr null, ptr undef, ptr @_ZN1B1fEi, ptr @_ZN1A1nEi] }, !type !0, !type !1
 @_ZTV1C = constant { [4 x ptr] } { [4 x ptr] [ptr null, ptr undef, ptr @_ZN1C1fEi, ptr @_ZN1A1nEi] }, !type !0, !type !2
 @_ZTV1D = constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr undef, ptr @_ZN1D1mEi] }, !type !3
 
+@_ZTV1F = constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr undef, ptr @_ZN1E1nEi] }, !type !5, !vcall_visibility !6
+
 
 ; CHECK-IR-LABEL: define i32 @test
-define i32 @test(ptr %obj, ptr %obj2, i32 %a) {
+define i32 @test(ptr %obj, ptr %obj2, ptr %obj3, i32 %a) {
 entry:
   %vtable = load ptr, ptr %obj
   %p = call i1 @llvm.type.test(ptr %vtable, metadata !"_ZTS1A")
@@ -114,7 +127,7 @@
   ; Ensure !prof and !callees metadata for indirect call promotion removed.
   ; CHECK-IR-NOT: prof
   ; CHECK-IR-NOT: callees
-  %call = tail call i32 %fptr1(ptr nonnull %obj, i32 %a), !prof !5, !callees !6
+  %call = tail call i32 %fptr1(ptr nonnull %obj, i32 %a), !prof !7, !callees !8
 
   %fptr22 = load ptr, ptr %vtable, align 8
 
@@ -131,7 +144,18 @@
   ; Check that the call was devirtualized.
   ; CHECK-IR: %call4 = tail call i32 @_ZN1D1mEi
   %call4 = tail call i32 %fptr33(ptr nonnull %obj2, i32 %call3)
-  ret i32 %call4
+
+  %vtable1 = load ptr, ptr %obj3
+  %p3 = call i1 @llvm.type.test(ptr %vtable1, metadata !"_ZTS1E")
+  call void @llvm.assume(i1 %p3)
+  %fptrptr1 = getelementptr ptr, ptr %vtable1, i32 0
+  %fptr44 = load ptr, ptr %fptrptr1, align 8
+
+  ; Check that the call was not devirtualized because of "unknown"
+  ; vcall_visibility.
+  ; CHECK-IR: %call5 = tail call i32 %fptr44
+  %call5 = tail call i32 %fptr44(ptr nonnull %obj, i32 %call4)
+  ret i32 %call5
 }
 ; CHECK-IR-LABEL: ret i32
 ; CHECK-IR-LABEL: }
@@ -155,6 +179,10 @@
ret i32 0;
 }
 
+define i32 @_ZN1E1nEi(ptr %this, i32 %a) #0 {
+   ret i32 0;
+}
+
 ; Make sure we don't inline or otherwise optimize out the direct calls.
 attributes #0 = { noinline optnone }
 
@@ -163,5 +191,7 @@
 !2 = !{i64 16, !"_ZTS1C"}
 !3 = !{i64 16, !4}
 !4 = distinct 

[PATCH] D146148: Float_t and double_t types shouldn't be modified by #pragma clang fp eval_method

2023-06-20 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:6784
+  if (II->getInterestingIdentifierID() != 0)
+NewTD->addAttr(AvailableOnlyInDefaultEvalMethodAttr::Create(Context));
 }

zahiraam wrote:
> rjmccall wrote:
> > Please switch over the interesting identifiers here; we don't want to 
> > assume this feature is only used for these two names.
> > 
> > In fact, should we go ahead and immediately apply it to the four 
> > identifiers above this?  That would be nice, because then we could actually 
> > do this in two patches: one patch that does the refactor to track 
> > interesting identifiers but doesn't cause any functionality changes and a 
> > second, very small patch that just introduces the new special treatment for 
> > `float_t` and `double_t`.
> > Please switch over the interesting identifiers here; we don't want to 
> > assume this feature is only used for these two names.
> > 
> > In fact, should we go ahead and immediately apply it to the four 
> > identifiers above this?  That would be nice, because then we could actually 
> > do this in two patches: one patch that does the refactor to track 
> > interesting identifiers but doesn't cause any functionality changes and a 
> > second, very small patch that just introduces the new special treatment for 
> > `float_t` and `double_t`.
> 
> Are you saying that "FILE", "jmp_buf"," sigjmp_buf" and "ucontext_t" are also 
> interesting identifiers? If yes, they should be added to the list of 
> interesting identifiers in TokenKinds.def?
Right.  The basic idea of interesting identifiers is to replace these sorts of 
identifier comparisons in performance-critical code.  So your first patch would 
*only* add those four identifiers as interesting identifiers, handling them 
here by registering the `typedef` with the ASTContext like the code is already 
doing.  Then you'd make a follow-up patch that adds `float_t` and `double_t` 
and handles them here by implicitly adding your new attribute.


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

https://reviews.llvm.org/D146148

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


[PATCH] D152785: [COFF] Support -gsplit-dwarf for COFF on Windows

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

Looking


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152785

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


[PATCH] D153179: [clang codegen] Fix ABI for HVA returns on AArch64 MSVC.

2023-06-20 Thread Eli Friedman via Phabricator via cfe-commits
efriedma updated this revision to Diff 533045.
efriedma added a comment.

Updated testcase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153179

Files:
  clang/lib/CodeGen/MicrosoftCXXABI.cpp
  clang/test/CodeGenCXX/homogeneous-aggregates.cpp


Index: clang/test/CodeGenCXX/homogeneous-aggregates.cpp
===
--- clang/test/CodeGenCXX/homogeneous-aggregates.cpp
+++ clang/test/CodeGenCXX/homogeneous-aggregates.cpp
@@ -285,3 +285,20 @@
 double foo(HFA v) { return v.x + v.y; }
 // WOA64: define dso_local noundef double 
@"?foo@non_empty_field@@YANUHFA@1@@Z"([4 x double] %{{.*}})
 }
+
+namespace pr62223 {
+// HVAs don't follow the normal rules for return values. That means they can
+// have base classes, user-defined ctors, and protected/private members.
+// (The same restrictions that apply to HVA arguments still apply.)
+typedef double V __attribute((ext_vector_type(2)));
+struct base { V v; };
+struct test : base { test(double); protected: V v2;};
+test f(test *x) { return *x; }
+// WOA64: define dso_local %"struct.pr62223::test" 
@"?f@pr62223@@YA?AUtest@1@PEAU21@@Z"(ptr noundef %{{.*}})
+
+// The above rule only apples to HVAs, not HFAs.
+struct base2 { double v; };
+struct test2 : base2 { test2(double); protected: double v2;};
+test2 f(test2 *x) { return *x; }
+// WOA64: define dso_local void @"?f@pr62223@@YA?AUtest2@1@PEAU21@@Z"(ptr 
inreg noalias sret(%"struct.pr62223::test2") align 16 %{{.*}}, ptr noundef 
%{{.*}})
+}
Index: clang/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -13,6 +13,7 @@
 //
 
//===--===//
 
+#include "ABIInfo.h"
 #include "CGCXXABI.h"
 #include "CGCleanup.h"
 #include "CGVTables.h"
@@ -1099,7 +1100,19 @@
   return isDeletingDtor(GD);
 }
 
-static bool isTrivialForMSVC(const CXXRecordDecl *RD) {
+static bool isTrivialForMSVC(const CXXRecordDecl *RD, QualType Ty,
+ CodeGenModule ) {
+  // On AArch64, HVAs that can be passed in registers can also be returned
+  // in registers. (Note this is using the MSVC definition of an HVA; see
+  // isPermittedToBeHomogeneousAggregate().)
+  const Type *Base = nullptr;
+  uint64_t NumElts = 0;
+  if (CGM.getTarget().getTriple().isAArch64() &&
+  CGM.getTypes().getABIInfo().isHomogeneousAggregate(Ty, Base, NumElts) &&
+  isa(Base)) {
+return true;
+  }
+
   // We use the C++14 definition of an aggregate, so we also
   // check for:
   //   No private or protected non static data members.
@@ -1128,7 +1141,8 @@
   if (!RD)
 return false;
 
-  bool isTrivialForABI = RD->canPassInRegisters() && isTrivialForMSVC(RD);
+  bool isTrivialForABI = RD->canPassInRegisters() &&
+ isTrivialForMSVC(RD, FI.getReturnType(), CGM);
 
   // MSVC always returns structs indirectly from C++ instance methods.
   bool isIndirectReturn = !isTrivialForABI || FI.isInstanceMethod();


Index: clang/test/CodeGenCXX/homogeneous-aggregates.cpp
===
--- clang/test/CodeGenCXX/homogeneous-aggregates.cpp
+++ clang/test/CodeGenCXX/homogeneous-aggregates.cpp
@@ -285,3 +285,20 @@
 double foo(HFA v) { return v.x + v.y; }
 // WOA64: define dso_local noundef double @"?foo@non_empty_field@@YANUHFA@1@@Z"([4 x double] %{{.*}})
 }
+
+namespace pr62223 {
+// HVAs don't follow the normal rules for return values. That means they can
+// have base classes, user-defined ctors, and protected/private members.
+// (The same restrictions that apply to HVA arguments still apply.)
+typedef double V __attribute((ext_vector_type(2)));
+struct base { V v; };
+struct test : base { test(double); protected: V v2;};
+test f(test *x) { return *x; }
+// WOA64: define dso_local %"struct.pr62223::test" @"?f@pr62223@@YA?AUtest@1@PEAU21@@Z"(ptr noundef %{{.*}})
+
+// The above rule only apples to HVAs, not HFAs.
+struct base2 { double v; };
+struct test2 : base2 { test2(double); protected: double v2;};
+test2 f(test2 *x) { return *x; }
+// WOA64: define dso_local void @"?f@pr62223@@YA?AUtest2@1@PEAU21@@Z"(ptr inreg noalias sret(%"struct.pr62223::test2") align 16 %{{.*}}, ptr noundef %{{.*}})
+}
Index: clang/lib/CodeGen/MicrosoftCXXABI.cpp
===
--- clang/lib/CodeGen/MicrosoftCXXABI.cpp
+++ clang/lib/CodeGen/MicrosoftCXXABI.cpp
@@ -13,6 +13,7 @@
 //
 //===--===//
 
+#include "ABIInfo.h"
 #include "CGCXXABI.h"
 #include "CGCleanup.h"
 #include "CGVTables.h"
@@ -1099,7 +1100,19 @@
   return isDeletingDtor(GD);
 }
 
-static bool isTrivialForMSVC(const CXXRecordDecl *RD) {
+static bool isTrivialForMSVC(const 

[PATCH] D153179: [clang codegen] Fix ABI for HVA returns on AArch64 MSVC.

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

Filed https://github.com/llvm/llvm-project/issues/63417 .  (On a related note, 
I also filed https://github.com/llvm/llvm-project/issues/63360 for an issue I 
stumbled over involving deleted copy constructors.)

> Interesting. In Clang, we basically layer the C++ rules over the C rules: if 
> C++ aspects of a class allow it to be passed directly transparently, then we 
> defer down to the C rules, which deal with HVAs, structs, and things like 
> that.

Yes... clearly MSVC is doing something very different if they're getting 
results like this by accident.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153179

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


[PATCH] D153233: clang: Add __builtin_elementwise_rint and nearbyint

2023-06-20 Thread Joshua Batista via Phabricator via cfe-commits
bob80905 added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:656
+  T __builtin_elementwise_nearbyint(T x) round x to the nearest  integer 
value in floating point format,  floating point types
+ rounding according to the current 
rounding direction.
+ May not raise the inexact 
floating-point exception. This is

Nit: I don't think a "current rounding direction" exists, and personally don't 
see the significance of the second half of this sentence.



Comment at: clang/lib/Sema/SemaChecking.cpp:18583
   << Callee << CallerTCB;
 }
   }

I don't believe you intended to remove all this code in your latest update, did 
you?


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

https://reviews.llvm.org/D153233

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


[PATCH] D153184: [NFC][clang] Refactor FileCheck metadata references in pragma-followup_inner.cpp

2023-06-20 Thread John McIver 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 rG148075cf87c7: [clang][test] Refactor FileCheck metadata in 
pragma-followup_inner.cpp (authored by jmciver).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153184

Files:
  clang/test/CodeGenCXX/pragma-followup_inner.cpp


Index: clang/test/CodeGenCXX/pragma-followup_inner.cpp
===
--- clang/test/CodeGenCXX/pragma-followup_inner.cpp
+++ clang/test/CodeGenCXX/pragma-followup_inner.cpp
@@ -20,23 +20,23 @@
 
 // CHECK-DAG: ![[ACCESSGROUP_2:[0-9]+]] = distinct !{}
 
-// CHECK-DAG: ![[INNERLOOP_3:[0-9]+]] = distinct !{![[INNERLOOP_3:[0-9]+]], 
![[PARALLEL_ACCESSES_4:[0-9]+]], ![[DISTRIBUTE_5:[0-9]+]], 
![[DISTRIBUTE_FOLLOWUP_6:[0-9]+]]}
-// CHECK-DAG: ![[PARALLEL_ACCESSES_4:[0-9]+]] = 
!{!"llvm.loop.parallel_accesses", !2}
-// CHECK-DAG: ![[DISTRIBUTE_5:[0-9]+]] = !{!"llvm.loop.distribute.enable", i1 
true}
-// CHECK-DAG: ![[DISTRIBUTE_FOLLOWUP_6:[0-9]+]] = 
!{!"llvm.loop.distribute.followup_all", ![[LOOP_7:[0-9]+]]}
-
-// CHECK-DAG: ![[LOOP_7:[0-9]+]] = distinct !{![[LOOP_7:[0-9]+]], 
![[PARALLEL_ACCESSES_4:[0-9]+]], ![[VECTORIZE_8:[0-9]+]]}
-// CHECK-DAG: ![[VECTORIZE_8:[0-9]+]] = !{!"llvm.loop.vectorize.enable", i1 
true}
-
-// CHECK-DAG: ![[OUTERLOOP_9:[0-9]+]] = distinct !{![[OUTERLOOP_9:[0-9]+]], 
[[MP:![0-9]+]], ![[UNROLLANDJAM_COUNT_10:[0-9]+]], 
![[UNROLLANDJAM_FOLLOWUPINNER_11:[0-9]+]]}
-// CHECK-DAG: ![[UNROLLANDJAM_COUNT_10:[0-9]+]] = 
!{!"llvm.loop.unroll_and_jam.count", i32 4}
-// CHECK-DAG: ![[UNROLLANDJAM_FOLLOWUPINNER_11:[0-9]+]] = 
!{!"llvm.loop.unroll_and_jam.followup_inner", !13}
-
-// CHECK-DAG: ![[LOOP_12:[0-9]+]] = distinct !{![[LOOP_12:[0-9]+]], 
![[PARALLEL_ACCESSES_4:[0-9]+]], ![[ISVECTORIZED_13:[0-9]+]], 
![[UNROLL_COUNT_13:[0-9]+]], ![[UNROLL_FOLLOWUP_14:[0-9]+]]}
-// CHECK-DAG: ![[ISVECTORIZED_13:[0-9]+]] = !{!"llvm.loop.isvectorized"}
-// CHECK-DAG: ![[UNROLL_COUNT_13:[0-9]+]] = !{!"llvm.loop.unroll.count", i32 4}
-// CHECK-DAG: ![[UNROLL_FOLLOWUP_14:[0-9]+]] = 
!{!"llvm.loop.unroll.followup_all", ![[LOOP_15:[0-9]+]]}
-
-// CHECK-DAG: ![[LOOP_15:[0-9]+]] = distinct !{![[LOOP_15:[0-9]+]], 
![[PARALLEL_ACCESSES_4:[0-9]+]], ![[ISVECTORIZED_13:[0-9]+]], 
![[UNROLL_DISABLE_16:[0-9]+]], ![[PIPELINE_17:[0-9]+]]}
-// CHECK-DAG: ![[UNROLL_DISABLE_16:[0-9]+]] = !{!"llvm.loop.unroll.disable"}
-// CHECK-DAG: ![[PIPELINE_17:[0-9]+]] = 
!{!"llvm.loop.pipeline.initiationinterval", i32 10}
+// CHECK-DAG: ![[INNERLOOP_3]] = distinct !{![[INNERLOOP_3]], 
![[PARALLEL_ACCESSES_4:[0-9]+]], ![[DISTRIBUTE_5:[0-9]+]], 
![[DISTRIBUTE_FOLLOWUP_6:[0-9]+]]}
+// CHECK-DAG: ![[PARALLEL_ACCESSES_4]] = !{!"llvm.loop.parallel_accesses", 
![[ACCESSGROUP_2]]}
+// CHECK-DAG: ![[DISTRIBUTE_5]] = !{!"llvm.loop.distribute.enable", i1 true}
+// CHECK-DAG: ![[DISTRIBUTE_FOLLOWUP_6]] = 
!{!"llvm.loop.distribute.followup_all", ![[LOOP_7:[0-9]+]]}
+
+// CHECK-DAG: ![[LOOP_7]] = distinct !{![[LOOP_7]], ![[PARALLEL_ACCESSES_4]], 
![[VECTORIZE_8:[0-9]+]]}
+// CHECK-DAG: ![[VECTORIZE_8]] = !{!"llvm.loop.vectorize.enable", i1 true}
+
+// CHECK-DAG: ![[OUTERLOOP_9]] = distinct !{![[OUTERLOOP_9]], [[MP:![0-9]+]], 
![[UNROLLANDJAM_COUNT_10:[0-9]+]], ![[UNROLLANDJAM_FOLLOWUPINNER_11:[0-9]+]]}
+// CHECK-DAG: ![[UNROLLANDJAM_COUNT_10]] = 
!{!"llvm.loop.unroll_and_jam.count", i32 4}
+// CHECK-DAG: ![[UNROLLANDJAM_FOLLOWUPINNER_11]] = 
!{!"llvm.loop.unroll_and_jam.followup_inner", ![[LOOP_12:[0-9]+]]}
+
+// CHECK-DAG: ![[LOOP_12]] = distinct !{![[LOOP_12:[0-9]+]], 
![[PARALLEL_ACCESSES_4]], ![[ISVECTORIZED_13:[0-9]+]], 
![[UNROLL_COUNT_13:[0-9]+]], ![[UNROLL_FOLLOWUP_14:[0-9]+]]}
+// CHECK-DAG: ![[ISVECTORIZED_13]] = !{!"llvm.loop.isvectorized"}
+// CHECK-DAG: ![[UNROLL_COUNT_13]] = !{!"llvm.loop.unroll.count", i32 4}
+// CHECK-DAG: ![[UNROLL_FOLLOWUP_14]] = !{!"llvm.loop.unroll.followup_all", 
![[LOOP_15:[0-9]+]]}
+
+// CHECK-DAG: ![[LOOP_15]] = distinct !{![[LOOP_15]], 
![[PARALLEL_ACCESSES_4]], ![[ISVECTORIZED_13]], ![[UNROLL_DISABLE_16:[0-9]+]], 
![[PIPELINE_17:[0-9]+]]}
+// CHECK-DAG: ![[UNROLL_DISABLE_16]] = !{!"llvm.loop.unroll.disable"}
+// CHECK-DAG: ![[PIPELINE_17]] = !{!"llvm.loop.pipeline.initiationinterval", 
i32 10}


Index: clang/test/CodeGenCXX/pragma-followup_inner.cpp
===
--- clang/test/CodeGenCXX/pragma-followup_inner.cpp
+++ clang/test/CodeGenCXX/pragma-followup_inner.cpp
@@ -20,23 +20,23 @@
 
 // CHECK-DAG: ![[ACCESSGROUP_2:[0-9]+]] = distinct !{}
 
-// CHECK-DAG: ![[INNERLOOP_3:[0-9]+]] = distinct !{![[INNERLOOP_3:[0-9]+]], ![[PARALLEL_ACCESSES_4:[0-9]+]], ![[DISTRIBUTE_5:[0-9]+]], ![[DISTRIBUTE_FOLLOWUP_6:[0-9]+]]}
-// CHECK-DAG: ![[PARALLEL_ACCESSES_4:[0-9]+]] = !{!"llvm.loop.parallel_accesses", !2}
-// CHECK-DAG: ![[DISTRIBUTE_5:[0-9]+]] = 

[clang] 148075c - [clang][test] Refactor FileCheck metadata in pragma-followup_inner.cpp

2023-06-20 Thread John McIver via cfe-commits

Author: John McIver
Date: 2023-06-20T14:55:12-06:00
New Revision: 148075cf87c76672474306fa463aadd93b1c027a

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

LOG: [clang][test] Refactor FileCheck metadata in pragma-followup_inner.cpp

- FileCheck variables for metadata are defined and referenced rather than
  repeatedly redefined.
- All numeric metadata identifiers are refactored to a FileCheck variable.

Reviewed By: MaskRay

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

Added: 


Modified: 
clang/test/CodeGenCXX/pragma-followup_inner.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/pragma-followup_inner.cpp 
b/clang/test/CodeGenCXX/pragma-followup_inner.cpp
index 31c5c6ff97690..bdcf8a9cbcc07 100644
--- a/clang/test/CodeGenCXX/pragma-followup_inner.cpp
+++ b/clang/test/CodeGenCXX/pragma-followup_inner.cpp
@@ -20,23 +20,23 @@ extern "C" void followup_inner(int n, int *x) {
 
 // CHECK-DAG: ![[ACCESSGROUP_2:[0-9]+]] = distinct !{}
 
-// CHECK-DAG: ![[INNERLOOP_3:[0-9]+]] = distinct !{![[INNERLOOP_3:[0-9]+]], 
![[PARALLEL_ACCESSES_4:[0-9]+]], ![[DISTRIBUTE_5:[0-9]+]], 
![[DISTRIBUTE_FOLLOWUP_6:[0-9]+]]}
-// CHECK-DAG: ![[PARALLEL_ACCESSES_4:[0-9]+]] = 
!{!"llvm.loop.parallel_accesses", !2}
-// CHECK-DAG: ![[DISTRIBUTE_5:[0-9]+]] = !{!"llvm.loop.distribute.enable", i1 
true}
-// CHECK-DAG: ![[DISTRIBUTE_FOLLOWUP_6:[0-9]+]] = 
!{!"llvm.loop.distribute.followup_all", ![[LOOP_7:[0-9]+]]}
-
-// CHECK-DAG: ![[LOOP_7:[0-9]+]] = distinct !{![[LOOP_7:[0-9]+]], 
![[PARALLEL_ACCESSES_4:[0-9]+]], ![[VECTORIZE_8:[0-9]+]]}
-// CHECK-DAG: ![[VECTORIZE_8:[0-9]+]] = !{!"llvm.loop.vectorize.enable", i1 
true}
-
-// CHECK-DAG: ![[OUTERLOOP_9:[0-9]+]] = distinct !{![[OUTERLOOP_9:[0-9]+]], 
[[MP:![0-9]+]], ![[UNROLLANDJAM_COUNT_10:[0-9]+]], 
![[UNROLLANDJAM_FOLLOWUPINNER_11:[0-9]+]]}
-// CHECK-DAG: ![[UNROLLANDJAM_COUNT_10:[0-9]+]] = 
!{!"llvm.loop.unroll_and_jam.count", i32 4}
-// CHECK-DAG: ![[UNROLLANDJAM_FOLLOWUPINNER_11:[0-9]+]] = 
!{!"llvm.loop.unroll_and_jam.followup_inner", !13}
-
-// CHECK-DAG: ![[LOOP_12:[0-9]+]] = distinct !{![[LOOP_12:[0-9]+]], 
![[PARALLEL_ACCESSES_4:[0-9]+]], ![[ISVECTORIZED_13:[0-9]+]], 
![[UNROLL_COUNT_13:[0-9]+]], ![[UNROLL_FOLLOWUP_14:[0-9]+]]}
-// CHECK-DAG: ![[ISVECTORIZED_13:[0-9]+]] = !{!"llvm.loop.isvectorized"}
-// CHECK-DAG: ![[UNROLL_COUNT_13:[0-9]+]] = !{!"llvm.loop.unroll.count", i32 4}
-// CHECK-DAG: ![[UNROLL_FOLLOWUP_14:[0-9]+]] = 
!{!"llvm.loop.unroll.followup_all", ![[LOOP_15:[0-9]+]]}
-
-// CHECK-DAG: ![[LOOP_15:[0-9]+]] = distinct !{![[LOOP_15:[0-9]+]], 
![[PARALLEL_ACCESSES_4:[0-9]+]], ![[ISVECTORIZED_13:[0-9]+]], 
![[UNROLL_DISABLE_16:[0-9]+]], ![[PIPELINE_17:[0-9]+]]}
-// CHECK-DAG: ![[UNROLL_DISABLE_16:[0-9]+]] = !{!"llvm.loop.unroll.disable"}
-// CHECK-DAG: ![[PIPELINE_17:[0-9]+]] = 
!{!"llvm.loop.pipeline.initiationinterval", i32 10}
+// CHECK-DAG: ![[INNERLOOP_3]] = distinct !{![[INNERLOOP_3]], 
![[PARALLEL_ACCESSES_4:[0-9]+]], ![[DISTRIBUTE_5:[0-9]+]], 
![[DISTRIBUTE_FOLLOWUP_6:[0-9]+]]}
+// CHECK-DAG: ![[PARALLEL_ACCESSES_4]] = !{!"llvm.loop.parallel_accesses", 
![[ACCESSGROUP_2]]}
+// CHECK-DAG: ![[DISTRIBUTE_5]] = !{!"llvm.loop.distribute.enable", i1 true}
+// CHECK-DAG: ![[DISTRIBUTE_FOLLOWUP_6]] = 
!{!"llvm.loop.distribute.followup_all", ![[LOOP_7:[0-9]+]]}
+
+// CHECK-DAG: ![[LOOP_7]] = distinct !{![[LOOP_7]], ![[PARALLEL_ACCESSES_4]], 
![[VECTORIZE_8:[0-9]+]]}
+// CHECK-DAG: ![[VECTORIZE_8]] = !{!"llvm.loop.vectorize.enable", i1 true}
+
+// CHECK-DAG: ![[OUTERLOOP_9]] = distinct !{![[OUTERLOOP_9]], [[MP:![0-9]+]], 
![[UNROLLANDJAM_COUNT_10:[0-9]+]], ![[UNROLLANDJAM_FOLLOWUPINNER_11:[0-9]+]]}
+// CHECK-DAG: ![[UNROLLANDJAM_COUNT_10]] = 
!{!"llvm.loop.unroll_and_jam.count", i32 4}
+// CHECK-DAG: ![[UNROLLANDJAM_FOLLOWUPINNER_11]] = 
!{!"llvm.loop.unroll_and_jam.followup_inner", ![[LOOP_12:[0-9]+]]}
+
+// CHECK-DAG: ![[LOOP_12]] = distinct !{![[LOOP_12:[0-9]+]], 
![[PARALLEL_ACCESSES_4]], ![[ISVECTORIZED_13:[0-9]+]], 
![[UNROLL_COUNT_13:[0-9]+]], ![[UNROLL_FOLLOWUP_14:[0-9]+]]}
+// CHECK-DAG: ![[ISVECTORIZED_13]] = !{!"llvm.loop.isvectorized"}
+// CHECK-DAG: ![[UNROLL_COUNT_13]] = !{!"llvm.loop.unroll.count", i32 4}
+// CHECK-DAG: ![[UNROLL_FOLLOWUP_14]] = !{!"llvm.loop.unroll.followup_all", 
![[LOOP_15:[0-9]+]]}
+
+// CHECK-DAG: ![[LOOP_15]] = distinct !{![[LOOP_15]], 
![[PARALLEL_ACCESSES_4]], ![[ISVECTORIZED_13]], ![[UNROLL_DISABLE_16:[0-9]+]], 
![[PIPELINE_17:[0-9]+]]}
+// CHECK-DAG: ![[UNROLL_DISABLE_16]] = !{!"llvm.loop.unroll.disable"}
+// CHECK-DAG: ![[PIPELINE_17]] = !{!"llvm.loop.pipeline.initiationinterval", 
i32 10}



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


[PATCH] D153375: [Clang] Fix incorrect use of direct initialization with copy initialization

2023-06-20 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik created this revision.
shafik added reviewers: aaron.ballman, erichkeane, rsmith.
Herald added a project: All.
shafik requested review of this revision.

In `Sema::CreateBuiltinBinOp()` we were incorrectly using direct initialization 
instead of copy initialization. This led to a crash in a copy initialization 
case with an enum with a fixed underlying type.

see dcl.init.general p14 

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


https://reviews.llvm.org/D153375

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3.cpp


Index: clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3.cpp
===
--- clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3.cpp
+++ clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3.cpp
@@ -283,3 +283,12 @@
   F f4(const bool x) { return F{x}; }
 #endif
 }
+
+namespace GH62503 {
+enum class E {};
+
+void f() {
+  E e;
+  e = {0}; // expected-error {{cannot initialize a value of type 'E' with an 
rvalue of type 'int'}}
+}
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -15428,8 +15428,8 @@
 // C++11 5.17p9:
 //   The meaning of x = {v} [...] is that of x = T(v) [...]. The meaning
 //   of x = {} is x = T().
-InitializationKind Kind = InitializationKind::CreateDirectList(
-RHSExpr->getBeginLoc(), RHSExpr->getBeginLoc(), RHSExpr->getEndLoc());
+InitializationKind Kind =
+InitializationKind::CreateCopy(RHSExpr->getBeginLoc(), OpLoc);
 InitializedEntity Entity =
 InitializedEntity::InitializeTemporary(LHSExpr->getType());
 InitializationSequence InitSeq(*this, Entity, Kind, RHSExpr);


Index: clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3.cpp
===
--- clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3.cpp
+++ clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p3.cpp
@@ -283,3 +283,12 @@
   F f4(const bool x) { return F{x}; }
 #endif
 }
+
+namespace GH62503 {
+enum class E {};
+
+void f() {
+  E e;
+  e = {0}; // expected-error {{cannot initialize a value of type 'E' with an rvalue of type 'int'}}
+}
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -15428,8 +15428,8 @@
 // C++11 5.17p9:
 //   The meaning of x = {v} [...] is that of x = T(v) [...]. The meaning
 //   of x = {} is x = T().
-InitializationKind Kind = InitializationKind::CreateDirectList(
-RHSExpr->getBeginLoc(), RHSExpr->getBeginLoc(), RHSExpr->getEndLoc());
+InitializationKind Kind =
+InitializationKind::CreateCopy(RHSExpr->getBeginLoc(), OpLoc);
 InitializedEntity Entity =
 InitializedEntity::InitializeTemporary(LHSExpr->getType());
 InitializationSequence InitSeq(*this, Entity, Kind, RHSExpr);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D153362: [clang][DebugInfo] Emit DW_AT_defaulted for defaulted C++ member functions

2023-06-20 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl accepted this revision.
aprantl added a comment.
This revision is now accepted and ready to land.

Not sure if this is the driving motivation, but this would probably allow 
LLDB's expression evaluator to synthesize a default implementation for these 
functions if they were optimized away.




Comment at: clang/test/CodeGenCXX/debug-info-defaulted.cpp:31
+
+// All ctors/dtors are implicitly defatuled.
+// So no DW_AT_defaulted expected for these.

typo: defaulted


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153362

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


[PATCH] D153179: [clang codegen] Fix ABI for HVA returns on AArch64 MSVC.

2023-06-20 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Interesting. In Clang, we basically layer the C++ rules over the C rules: if 
C++ aspects of a class allow it to be passed directly transparently, then we 
defer down to the C rules, which deal with HVAs, structs, and things like that.

In D153179#4429813 , @efriedma wrote:

> Restrict to AArch64.
>
> Actually, it seems like something sort of similar happens with x86 
> vectorcall.  But I haven't tried to test all the permutations of that, so 
> don't modify the behavior for now.

Can you file an issue for that and cc me?




Comment at: clang/test/CodeGenCXX/homogeneous-aggregates.cpp:294
+typedef double V __attribute((ext_vector_type(2)));
+struct base { V v; };
+struct test { test(double); protected: V v2;};

Can you do the same test again with a non-vector field (double) for test 
coverage?



Comment at: clang/test/CodeGenCXX/homogeneous-aggregates.cpp:295
+struct base { V v; };
+struct test { test(double); protected: V v2;};
+test f(test *x) { return *x; }

Did you mean to inherit from `base` here to make a two-element HVA?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153179

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


[PATCH] D137872: Implement lambdas with inalloca parameters by forwarding to function without inalloca calling convention.

2023-06-20 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I'm really happy to see this limitation finally addressed! It's quite a bit of 
embarrassing tech debt that affects folks making Windows x86 builds.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137872

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


[PATCH] D142994: [UsersManual] Add llvm-progen as an alternative tool for AutoFDO profile generation.

2023-06-20 Thread Hongtao Yu 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 rG56e36e47f504: [UsersManual] Add llvm-progen as an 
alternative tool for AutoFDO profile… (authored by hoy).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142994

Files:
  clang/docs/UsersManual.rst


Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -2400,6 +2400,14 @@
without the ``-b`` flag, you need to use ``--use_lbr=false`` when
calling ``create_llvm_prof``.
 
+   Alternatively, the LLVM tool ``llvm-profgen`` can also be used to generate
+   the LLVM sample profile:
+
+   .. code-block:: console
+
+ $ llvm-profgen --binary=./code --output=code.prof--perfdata=perf.data
+
+
 4. Build the code again using the collected profile. This step feeds
the profile back to the optimizers. This should result in a binary
that executes faster than the original one. Note that you are not


Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -2400,6 +2400,14 @@
without the ``-b`` flag, you need to use ``--use_lbr=false`` when
calling ``create_llvm_prof``.
 
+   Alternatively, the LLVM tool ``llvm-profgen`` can also be used to generate
+   the LLVM sample profile:
+
+   .. code-block:: console
+
+ $ llvm-profgen --binary=./code --output=code.prof--perfdata=perf.data
+
+
 4. Build the code again using the collected profile. This step feeds
the profile back to the optimizers. This should result in a binary
that executes faster than the original one. Note that you are not
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 56e36e4 - [UsersManual] Add llvm-progen as an alternative tool for AutoFDO profile generation.

2023-06-20 Thread Hongtao Yu via cfe-commits

Author: Hongtao Yu
Date: 2023-06-20T13:26:30-07:00
New Revision: 56e36e47f50446f519dfa2132cf5a49cc0816866

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

LOG: [UsersManual] Add llvm-progen as an alternative tool for AutoFDO profile 
generation.

I'm adding llvm-profgen as an alternative AutoFDO profile generator to the user 
manual. llvm-profgen is widely used and tested by META as their default profile 
generator.

Reviewed By: davidxl

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

Added: 


Modified: 
clang/docs/UsersManual.rst

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index f8dbf819d6ff7..6a644eed6d32b 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -2400,6 +2400,14 @@ usual build cycle when using sample profilers for 
optimization:
without the ``-b`` flag, you need to use ``--use_lbr=false`` when
calling ``create_llvm_prof``.
 
+   Alternatively, the LLVM tool ``llvm-profgen`` can also be used to generate
+   the LLVM sample profile:
+
+   .. code-block:: console
+
+ $ llvm-profgen --binary=./code --output=code.prof--perfdata=perf.data
+
+
 4. Build the code again using the collected profile. This step feeds
the profile back to the optimizers. This should result in a binary
that executes faster than the original one. Note that you are not



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


[PATCH] D153362: [clang][DebugInfo] Emit DW_AT_defaulted for defaulted C++ member functions

2023-06-20 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Any particular use for this debug info in DWARF consumers?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153362

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


[PATCH] D153366: [dataflow] Add dedicated representation of boolean formulas

2023-06-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 533029.
sammccall added a comment.

clean up


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153366

Files:
  clang/include/clang/Analysis/FlowSensitive/Arena.h
  clang/include/clang/Analysis/FlowSensitive/DebugSupport.h
  clang/include/clang/Analysis/FlowSensitive/Formula.h
  clang/include/clang/Analysis/FlowSensitive/Solver.h
  clang/include/clang/Analysis/FlowSensitive/WatchedLiteralsSolver.h
  clang/lib/Analysis/FlowSensitive/Arena.cpp
  clang/lib/Analysis/FlowSensitive/CMakeLists.txt
  clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
  clang/lib/Analysis/FlowSensitive/DebugSupport.cpp
  clang/lib/Analysis/FlowSensitive/Formula.cpp
  clang/lib/Analysis/FlowSensitive/WatchedLiteralsSolver.cpp
  clang/unittests/Analysis/FlowSensitive/ArenaTest.cpp
  clang/unittests/Analysis/FlowSensitive/DebugSupportTest.cpp
  clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h

Index: clang/unittests/Analysis/FlowSensitive/TestingSupport.h
===
--- clang/unittests/Analysis/FlowSensitive/TestingSupport.h
+++ clang/unittests/Analysis/FlowSensitive/TestingSupport.h
@@ -42,6 +42,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Allocator.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Testing/Annotations/Annotations.h"
@@ -404,55 +405,43 @@
 
 /// Creates and owns constraints which are boolean values.
 class ConstraintContext {
-public:
-  // Creates an atomic boolean value.
-  BoolValue *atom() {
-Vals.push_back(std::make_unique());
-return Vals.back().get();
+  unsigned NextAtom = 0;
+  llvm::BumpPtrAllocator A;
+
+  const Formula *make(Formula::Kind K, llvm::ArrayRef Operands) {
+return ::create(A, K, Operands);
   }
 
-  // Creates an instance of the Top boolean value.
-  BoolValue *top() {
-Vals.push_back(std::make_unique());
-return Vals.back().get();
+public:
+  // Creates a reference to a fresh atomic variable.
+  const Formula *atom() {
+return ::create(A, Formula::AtomRef, {}, NextAtom++);
   }
 
   // Creates a boolean conjunction value.
-  BoolValue *conj(BoolValue *LeftSubVal, BoolValue *RightSubVal) {
-Vals.push_back(
-std::make_unique(*LeftSubVal, *RightSubVal));
-return Vals.back().get();
+  const Formula *conj(const Formula *LeftSubVal, const Formula *RightSubVal) {
+return make(Formula::And, {LeftSubVal, RightSubVal});
   }
 
   // Creates a boolean disjunction value.
-  BoolValue *disj(BoolValue *LeftSubVal, BoolValue *RightSubVal) {
-Vals.push_back(
-std::make_unique(*LeftSubVal, *RightSubVal));
-return Vals.back().get();
+  const Formula*disj(const Formula*LeftSubVal, const Formula*RightSubVal) {
+return make(Formula::Or, {LeftSubVal, RightSubVal});
   }
 
   // Creates a boolean negation value.
-  BoolValue *neg(BoolValue *SubVal) {
-Vals.push_back(std::make_unique(*SubVal));
-return Vals.back().get();
+  const Formula *neg(const Formula *SubVal) {
+return make(Formula::Not, {SubVal});
   }
 
   // Creates a boolean implication value.
-  BoolValue *impl(BoolValue *LeftSubVal, BoolValue *RightSubVal) {
-Vals.push_back(
-std::make_unique(*LeftSubVal, *RightSubVal));
-return Vals.back().get();
+  const Formula *impl(const Formula *LeftSubVal, const Formula *RightSubVal) {
+return make(Formula::Implies, {LeftSubVal, RightSubVal});
   }
 
   // Creates a boolean biconditional value.
-  BoolValue *iff(BoolValue *LeftSubVal, BoolValue *RightSubVal) {
-Vals.push_back(
-std::make_unique(*LeftSubVal, *RightSubVal));
-return Vals.back().get();
+  const Formula *iff(const Formula *LeftSubVal, const Formula *RightSubVal) {
+return make(Formula::Equal, {LeftSubVal, RightSubVal});
   }
-
-private:
-  std::vector> Vals;
 };
 
 } // namespace test
Index: clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
@@ -30,19 +30,23 @@
 
 // Checks if the conjunction of `Vals` is satisfiable and returns the
 // corresponding result.
-Solver::Result solve(llvm::DenseSet Vals) {
+Solver::Result solve(llvm::DenseSet Vals) {
   return WatchedLiteralsSolver().solve(std::move(Vals));
 }
 
-void expectUnsatisfiable(Solver::Result Result) {
-  EXPECT_EQ(Result.getStatus(), Solver::Result::Status::Unsatisfiable);
-  EXPECT_FALSE(Result.getSolution().has_value());
+MATCHER(unsat, "") {
+  return arg.getStatus() == Solver::Result::Status::Unsatisfiable;
 }
-
-template 
-void expectSatisfiable(Solver::Result Result, Matcher Solution) {
-  EXPECT_EQ(Result.getStatus(), 

[PATCH] D153366: [dataflow] Add dedicated representation of boolean formulas

2023-06-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 533028.
sammccall added a comment.

remove dead comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153366

Files:
  clang/include/clang/Analysis/FlowSensitive/Arena.h
  clang/include/clang/Analysis/FlowSensitive/DebugSupport.h
  clang/include/clang/Analysis/FlowSensitive/Formula.h
  clang/include/clang/Analysis/FlowSensitive/Solver.h
  clang/include/clang/Analysis/FlowSensitive/WatchedLiteralsSolver.h
  clang/lib/Analysis/FlowSensitive/Arena.cpp
  clang/lib/Analysis/FlowSensitive/CMakeLists.txt
  clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
  clang/lib/Analysis/FlowSensitive/DebugSupport.cpp
  clang/lib/Analysis/FlowSensitive/Formula.cpp
  clang/lib/Analysis/FlowSensitive/WatchedLiteralsSolver.cpp
  clang/unittests/Analysis/FlowSensitive/ArenaTest.cpp
  clang/unittests/Analysis/FlowSensitive/DebugSupportTest.cpp
  clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h

Index: clang/unittests/Analysis/FlowSensitive/TestingSupport.h
===
--- clang/unittests/Analysis/FlowSensitive/TestingSupport.h
+++ clang/unittests/Analysis/FlowSensitive/TestingSupport.h
@@ -42,6 +42,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Allocator.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Testing/Annotations/Annotations.h"
@@ -404,55 +405,43 @@
 
 /// Creates and owns constraints which are boolean values.
 class ConstraintContext {
-public:
-  // Creates an atomic boolean value.
-  BoolValue *atom() {
-Vals.push_back(std::make_unique());
-return Vals.back().get();
+  unsigned NextAtom = 0;
+  llvm::BumpPtrAllocator A;
+
+  const Formula *make(Formula::Kind K, llvm::ArrayRef Operands) {
+return ::create(A, K, Operands);
   }
 
-  // Creates an instance of the Top boolean value.
-  BoolValue *top() {
-Vals.push_back(std::make_unique());
-return Vals.back().get();
+public:
+  // Creates a reference to a fresh atomic variable.
+  const Formula *atom() {
+return ::create(A, Formula::AtomRef, {}, NextAtom++);
   }
 
   // Creates a boolean conjunction value.
-  BoolValue *conj(BoolValue *LeftSubVal, BoolValue *RightSubVal) {
-Vals.push_back(
-std::make_unique(*LeftSubVal, *RightSubVal));
-return Vals.back().get();
+  const Formula *conj(const Formula *LeftSubVal, const Formula *RightSubVal) {
+return make(Formula::And, {LeftSubVal, RightSubVal});
   }
 
   // Creates a boolean disjunction value.
-  BoolValue *disj(BoolValue *LeftSubVal, BoolValue *RightSubVal) {
-Vals.push_back(
-std::make_unique(*LeftSubVal, *RightSubVal));
-return Vals.back().get();
+  const Formula*disj(const Formula*LeftSubVal, const Formula*RightSubVal) {
+return make(Formula::Or, {LeftSubVal, RightSubVal});
   }
 
   // Creates a boolean negation value.
-  BoolValue *neg(BoolValue *SubVal) {
-Vals.push_back(std::make_unique(*SubVal));
-return Vals.back().get();
+  const Formula *neg(const Formula *SubVal) {
+return make(Formula::Not, {SubVal});
   }
 
   // Creates a boolean implication value.
-  BoolValue *impl(BoolValue *LeftSubVal, BoolValue *RightSubVal) {
-Vals.push_back(
-std::make_unique(*LeftSubVal, *RightSubVal));
-return Vals.back().get();
+  const Formula *impl(const Formula *LeftSubVal, const Formula *RightSubVal) {
+return make(Formula::Implies, {LeftSubVal, RightSubVal});
   }
 
   // Creates a boolean biconditional value.
-  BoolValue *iff(BoolValue *LeftSubVal, BoolValue *RightSubVal) {
-Vals.push_back(
-std::make_unique(*LeftSubVal, *RightSubVal));
-return Vals.back().get();
+  const Formula *iff(const Formula *LeftSubVal, const Formula *RightSubVal) {
+return make(Formula::Equal, {LeftSubVal, RightSubVal});
   }
-
-private:
-  std::vector> Vals;
 };
 
 } // namespace test
Index: clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
@@ -30,19 +30,23 @@
 
 // Checks if the conjunction of `Vals` is satisfiable and returns the
 // corresponding result.
-Solver::Result solve(llvm::DenseSet Vals) {
+Solver::Result solve(llvm::DenseSet Vals) {
   return WatchedLiteralsSolver().solve(std::move(Vals));
 }
 
-void expectUnsatisfiable(Solver::Result Result) {
-  EXPECT_EQ(Result.getStatus(), Solver::Result::Status::Unsatisfiable);
-  EXPECT_FALSE(Result.getSolution().has_value());
+MATCHER(unsat, "") {
+  return arg.getStatus() == Solver::Result::Status::Unsatisfiable;
 }
-
-template 
-void expectSatisfiable(Solver::Result Result, Matcher Solution) {
-  

[PATCH] D153366: [dataflow] Add dedicated representation of boolean formulas

2023-06-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 533027.
sammccall edited the summary of this revision.
sammccall added a comment.

more tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153366

Files:
  clang/include/clang/Analysis/FlowSensitive/Arena.h
  clang/include/clang/Analysis/FlowSensitive/DebugSupport.h
  clang/include/clang/Analysis/FlowSensitive/Formula.h
  clang/include/clang/Analysis/FlowSensitive/Solver.h
  clang/include/clang/Analysis/FlowSensitive/WatchedLiteralsSolver.h
  clang/lib/Analysis/FlowSensitive/Arena.cpp
  clang/lib/Analysis/FlowSensitive/CMakeLists.txt
  clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
  clang/lib/Analysis/FlowSensitive/DebugSupport.cpp
  clang/lib/Analysis/FlowSensitive/Formula.cpp
  clang/lib/Analysis/FlowSensitive/WatchedLiteralsSolver.cpp
  clang/unittests/Analysis/FlowSensitive/ArenaTest.cpp
  clang/unittests/Analysis/FlowSensitive/DebugSupportTest.cpp
  clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h

Index: clang/unittests/Analysis/FlowSensitive/TestingSupport.h
===
--- clang/unittests/Analysis/FlowSensitive/TestingSupport.h
+++ clang/unittests/Analysis/FlowSensitive/TestingSupport.h
@@ -42,6 +42,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Allocator.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Testing/Annotations/Annotations.h"
@@ -404,55 +405,43 @@
 
 /// Creates and owns constraints which are boolean values.
 class ConstraintContext {
-public:
-  // Creates an atomic boolean value.
-  BoolValue *atom() {
-Vals.push_back(std::make_unique());
-return Vals.back().get();
+  unsigned NextAtom = 0;
+  llvm::BumpPtrAllocator A;
+
+  const Formula *make(Formula::Kind K, llvm::ArrayRef Operands) {
+return ::create(A, K, Operands);
   }
 
-  // Creates an instance of the Top boolean value.
-  BoolValue *top() {
-Vals.push_back(std::make_unique());
-return Vals.back().get();
+public:
+  // Creates a reference to a fresh atomic variable.
+  const Formula *atom() {
+return ::create(A, Formula::AtomRef, {}, NextAtom++);
   }
 
   // Creates a boolean conjunction value.
-  BoolValue *conj(BoolValue *LeftSubVal, BoolValue *RightSubVal) {
-Vals.push_back(
-std::make_unique(*LeftSubVal, *RightSubVal));
-return Vals.back().get();
+  const Formula *conj(const Formula *LeftSubVal, const Formula *RightSubVal) {
+return make(Formula::And, {LeftSubVal, RightSubVal});
   }
 
   // Creates a boolean disjunction value.
-  BoolValue *disj(BoolValue *LeftSubVal, BoolValue *RightSubVal) {
-Vals.push_back(
-std::make_unique(*LeftSubVal, *RightSubVal));
-return Vals.back().get();
+  const Formula*disj(const Formula*LeftSubVal, const Formula*RightSubVal) {
+return make(Formula::Or, {LeftSubVal, RightSubVal});
   }
 
   // Creates a boolean negation value.
-  BoolValue *neg(BoolValue *SubVal) {
-Vals.push_back(std::make_unique(*SubVal));
-return Vals.back().get();
+  const Formula *neg(const Formula *SubVal) {
+return make(Formula::Not, {SubVal});
   }
 
   // Creates a boolean implication value.
-  BoolValue *impl(BoolValue *LeftSubVal, BoolValue *RightSubVal) {
-Vals.push_back(
-std::make_unique(*LeftSubVal, *RightSubVal));
-return Vals.back().get();
+  const Formula *impl(const Formula *LeftSubVal, const Formula *RightSubVal) {
+return make(Formula::Implies, {LeftSubVal, RightSubVal});
   }
 
   // Creates a boolean biconditional value.
-  BoolValue *iff(BoolValue *LeftSubVal, BoolValue *RightSubVal) {
-Vals.push_back(
-std::make_unique(*LeftSubVal, *RightSubVal));
-return Vals.back().get();
+  const Formula *iff(const Formula *LeftSubVal, const Formula *RightSubVal) {
+return make(Formula::Equal, {LeftSubVal, RightSubVal});
   }
-
-private:
-  std::vector> Vals;
 };
 
 } // namespace test
Index: clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
@@ -30,19 +30,23 @@
 
 // Checks if the conjunction of `Vals` is satisfiable and returns the
 // corresponding result.
-Solver::Result solve(llvm::DenseSet Vals) {
+Solver::Result solve(llvm::DenseSet Vals) {
   return WatchedLiteralsSolver().solve(std::move(Vals));
 }
 
-void expectUnsatisfiable(Solver::Result Result) {
-  EXPECT_EQ(Result.getStatus(), Solver::Result::Status::Unsatisfiable);
-  EXPECT_FALSE(Result.getSolution().has_value());
+MATCHER(unsat, "") {
+  return arg.getStatus() == Solver::Result::Status::Unsatisfiable;
 }
-
-template 
-void expectSatisfiable(Solver::Result Result, Matcher 

[PATCH] D153281: [flang] add -flang-experimental-polymorphism flag to flang-new

2023-06-20 Thread Valentin Clement via Phabricator via cfe-commits
clementval added a comment.

Looks ok to me. Note that some of the polymorphic TODOs will only be removed 
when HLFIR is in place.

Looks like you have a clang-format issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153281

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


[PATCH] D153366: [dataflow] Add dedicated representation of boolean formulas

2023-06-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 533025.
sammccall edited the summary of this revision.
sammccall added a comment.

updating description


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153366

Files:
  clang/include/clang/Analysis/FlowSensitive/Arena.h
  clang/include/clang/Analysis/FlowSensitive/DebugSupport.h
  clang/include/clang/Analysis/FlowSensitive/Formula.h
  clang/include/clang/Analysis/FlowSensitive/Solver.h
  clang/include/clang/Analysis/FlowSensitive/WatchedLiteralsSolver.h
  clang/lib/Analysis/FlowSensitive/Arena.cpp
  clang/lib/Analysis/FlowSensitive/CMakeLists.txt
  clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
  clang/lib/Analysis/FlowSensitive/DebugSupport.cpp
  clang/lib/Analysis/FlowSensitive/Formula.cpp
  clang/lib/Analysis/FlowSensitive/WatchedLiteralsSolver.cpp
  clang/unittests/Analysis/FlowSensitive/DebugSupportTest.cpp
  clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h

Index: clang/unittests/Analysis/FlowSensitive/TestingSupport.h
===
--- clang/unittests/Analysis/FlowSensitive/TestingSupport.h
+++ clang/unittests/Analysis/FlowSensitive/TestingSupport.h
@@ -42,6 +42,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Allocator.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Testing/Annotations/Annotations.h"
@@ -404,55 +405,43 @@
 
 /// Creates and owns constraints which are boolean values.
 class ConstraintContext {
-public:
-  // Creates an atomic boolean value.
-  BoolValue *atom() {
-Vals.push_back(std::make_unique());
-return Vals.back().get();
+  unsigned NextAtom = 0;
+  llvm::BumpPtrAllocator A;
+
+  const Formula *make(Formula::Kind K, llvm::ArrayRef Operands) {
+return ::create(A, K, Operands);
   }
 
-  // Creates an instance of the Top boolean value.
-  BoolValue *top() {
-Vals.push_back(std::make_unique());
-return Vals.back().get();
+public:
+  // Creates a reference to a fresh atomic variable.
+  const Formula *atom() {
+return ::create(A, Formula::AtomRef, {}, NextAtom++);
   }
 
   // Creates a boolean conjunction value.
-  BoolValue *conj(BoolValue *LeftSubVal, BoolValue *RightSubVal) {
-Vals.push_back(
-std::make_unique(*LeftSubVal, *RightSubVal));
-return Vals.back().get();
+  const Formula *conj(const Formula *LeftSubVal, const Formula *RightSubVal) {
+return make(Formula::And, {LeftSubVal, RightSubVal});
   }
 
   // Creates a boolean disjunction value.
-  BoolValue *disj(BoolValue *LeftSubVal, BoolValue *RightSubVal) {
-Vals.push_back(
-std::make_unique(*LeftSubVal, *RightSubVal));
-return Vals.back().get();
+  const Formula*disj(const Formula*LeftSubVal, const Formula*RightSubVal) {
+return make(Formula::Or, {LeftSubVal, RightSubVal});
   }
 
   // Creates a boolean negation value.
-  BoolValue *neg(BoolValue *SubVal) {
-Vals.push_back(std::make_unique(*SubVal));
-return Vals.back().get();
+  const Formula *neg(const Formula *SubVal) {
+return make(Formula::Not, {SubVal});
   }
 
   // Creates a boolean implication value.
-  BoolValue *impl(BoolValue *LeftSubVal, BoolValue *RightSubVal) {
-Vals.push_back(
-std::make_unique(*LeftSubVal, *RightSubVal));
-return Vals.back().get();
+  const Formula *impl(const Formula *LeftSubVal, const Formula *RightSubVal) {
+return make(Formula::Implies, {LeftSubVal, RightSubVal});
   }
 
   // Creates a boolean biconditional value.
-  BoolValue *iff(BoolValue *LeftSubVal, BoolValue *RightSubVal) {
-Vals.push_back(
-std::make_unique(*LeftSubVal, *RightSubVal));
-return Vals.back().get();
+  const Formula *iff(const Formula *LeftSubVal, const Formula *RightSubVal) {
+return make(Formula::Equal, {LeftSubVal, RightSubVal});
   }
-
-private:
-  std::vector> Vals;
 };
 
 } // namespace test
Index: clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
@@ -30,19 +30,23 @@
 
 // Checks if the conjunction of `Vals` is satisfiable and returns the
 // corresponding result.
-Solver::Result solve(llvm::DenseSet Vals) {
+Solver::Result solve(llvm::DenseSet Vals) {
   return WatchedLiteralsSolver().solve(std::move(Vals));
 }
 
-void expectUnsatisfiable(Solver::Result Result) {
-  EXPECT_EQ(Result.getStatus(), Solver::Result::Status::Unsatisfiable);
-  EXPECT_FALSE(Result.getSolution().has_value());
+MATCHER(unsat, "") {
+  return arg.getStatus() == Solver::Result::Status::Unsatisfiable;
 }
-
-template 
-void expectSatisfiable(Solver::Result Result, Matcher Solution) {
-  EXPECT_EQ(Result.getStatus(), 

[PATCH] D153294: [clang] Do not create ExprWithCleanups while checking immediate invocation

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

A constant expression (including the immediate invocations generated for 
`consteval` functions) is a full-expression, so destructors should be run at 
the end of evaluating it, not as part of the enclosing expression. That's 
presumably why the code is calling `MaybeCreateExprWithCleanups` -- to 
associate cleanups for the immediate invocation with that `ConstantExpr` rather 
than with the outer context. I think the problem is that we don't have an 
`ExpressionEvaluationContext` wrapping the immediate invocation, so we don't 
save and restore the enclosing cleanup state -- and we can't really wrap it, 
because we don't find out that we're building an immediate invocation until 
after we've already done so. Probably the best way to handle that is to create 
the inner `ExprWithCleanups` for the constant expression, but leave the 
cleanups flags alone so that we also create an outer `ExprWithCleanups`. 
That'll mean we sometimes create an `ExprWithCleanups` that doesn't actually 
run any cleanups, but that's OK, just redundant. One thing we will need to be 
careful about is assigning any block / compound literal cleanups to the right 
`ExprWithCleanups` node. We can figure out where to put them by doing a 
traversal of the `ConstantExpr`'s subexpression to see if it contains the 
`BlockDecl` / `CompoundLiteralExpr` being referenced by the cleanup.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153294

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


[PATCH] D153366: [dataflow] Add dedicated representation of boolean formulas

2023-06-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 533022.
sammccall added a comment.

update tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153366

Files:
  clang/include/clang/Analysis/FlowSensitive/Arena.h
  clang/include/clang/Analysis/FlowSensitive/DebugSupport.h
  clang/include/clang/Analysis/FlowSensitive/Formula.h
  clang/include/clang/Analysis/FlowSensitive/Solver.h
  clang/include/clang/Analysis/FlowSensitive/WatchedLiteralsSolver.h
  clang/lib/Analysis/FlowSensitive/Arena.cpp
  clang/lib/Analysis/FlowSensitive/CMakeLists.txt
  clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
  clang/lib/Analysis/FlowSensitive/DebugSupport.cpp
  clang/lib/Analysis/FlowSensitive/Formula.cpp
  clang/lib/Analysis/FlowSensitive/WatchedLiteralsSolver.cpp
  clang/unittests/Analysis/FlowSensitive/DebugSupportTest.cpp
  clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h

Index: clang/unittests/Analysis/FlowSensitive/TestingSupport.h
===
--- clang/unittests/Analysis/FlowSensitive/TestingSupport.h
+++ clang/unittests/Analysis/FlowSensitive/TestingSupport.h
@@ -42,6 +42,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Allocator.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Testing/Annotations/Annotations.h"
@@ -404,55 +405,43 @@
 
 /// Creates and owns constraints which are boolean values.
 class ConstraintContext {
-public:
-  // Creates an atomic boolean value.
-  BoolValue *atom() {
-Vals.push_back(std::make_unique());
-return Vals.back().get();
+  unsigned NextAtom = 0;
+  llvm::BumpPtrAllocator A;
+
+  const Formula *make(Formula::Kind K, llvm::ArrayRef Operands) {
+return ::create(A, K, Operands);
   }
 
-  // Creates an instance of the Top boolean value.
-  BoolValue *top() {
-Vals.push_back(std::make_unique());
-return Vals.back().get();
+public:
+  // Creates a reference to a fresh atomic variable.
+  const Formula *atom() {
+return ::create(A, Formula::AtomRef, {}, NextAtom++);
   }
 
   // Creates a boolean conjunction value.
-  BoolValue *conj(BoolValue *LeftSubVal, BoolValue *RightSubVal) {
-Vals.push_back(
-std::make_unique(*LeftSubVal, *RightSubVal));
-return Vals.back().get();
+  const Formula *conj(const Formula *LeftSubVal, const Formula *RightSubVal) {
+return make(Formula::And, {LeftSubVal, RightSubVal});
   }
 
   // Creates a boolean disjunction value.
-  BoolValue *disj(BoolValue *LeftSubVal, BoolValue *RightSubVal) {
-Vals.push_back(
-std::make_unique(*LeftSubVal, *RightSubVal));
-return Vals.back().get();
+  const Formula*disj(const Formula*LeftSubVal, const Formula*RightSubVal) {
+return make(Formula::Or, {LeftSubVal, RightSubVal});
   }
 
   // Creates a boolean negation value.
-  BoolValue *neg(BoolValue *SubVal) {
-Vals.push_back(std::make_unique(*SubVal));
-return Vals.back().get();
+  const Formula *neg(const Formula *SubVal) {
+return make(Formula::Not, {SubVal});
   }
 
   // Creates a boolean implication value.
-  BoolValue *impl(BoolValue *LeftSubVal, BoolValue *RightSubVal) {
-Vals.push_back(
-std::make_unique(*LeftSubVal, *RightSubVal));
-return Vals.back().get();
+  const Formula *impl(const Formula *LeftSubVal, const Formula *RightSubVal) {
+return make(Formula::Implies, {LeftSubVal, RightSubVal});
   }
 
   // Creates a boolean biconditional value.
-  BoolValue *iff(BoolValue *LeftSubVal, BoolValue *RightSubVal) {
-Vals.push_back(
-std::make_unique(*LeftSubVal, *RightSubVal));
-return Vals.back().get();
+  const Formula *iff(const Formula *LeftSubVal, const Formula *RightSubVal) {
+return make(Formula::Equal, {LeftSubVal, RightSubVal});
   }
-
-private:
-  std::vector> Vals;
 };
 
 } // namespace test
Index: clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
@@ -30,19 +30,23 @@
 
 // Checks if the conjunction of `Vals` is satisfiable and returns the
 // corresponding result.
-Solver::Result solve(llvm::DenseSet Vals) {
+Solver::Result solve(llvm::DenseSet Vals) {
   return WatchedLiteralsSolver().solve(std::move(Vals));
 }
 
-void expectUnsatisfiable(Solver::Result Result) {
-  EXPECT_EQ(Result.getStatus(), Solver::Result::Status::Unsatisfiable);
-  EXPECT_FALSE(Result.getSolution().has_value());
+MATCHER(unsat, "") {
+  return arg.getStatus() == Solver::Result::Status::Unsatisfiable;
 }
-
-template 
-void expectSatisfiable(Solver::Result Result, Matcher Solution) {
-  EXPECT_EQ(Result.getStatus(), Solver::Result::Status::Satisfiable);
-  

[PATCH] D153281: [flang] add -flang-experimental-polymorphism flag to flang-new

2023-06-20 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski accepted this revision.
awarzynski added a comment.

LGTM, thanks David!

Could you also add a test in 
https://github.com/llvm/llvm-project/blob/main/flang/test/Driver/frontend-forwarding.f90?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153281

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


[PATCH] D144006: [DebugMetadata][DwarfDebug] Support function-local types in lexical block scopes (4/7)

2023-06-20 Thread Hongtao Yu via Phabricator via cfe-commits
hoy added a comment.

Hello, I'm seeing a build failure that seems related to this patch. I'm seeing 
the patch has been relanded and reverted a couple times and not sure where it 
is right now. Can you please confirm if the failure is related and fixed? 
Thanks.

2023-06-20T05:19:14.441-07:00] Stderr: PLEASE submit a bug report to 
https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, 
preprocessed source, and associated run script.
[2023-06-20T05:19:14.441-07:00] Stack dump:
[2023-06-20T05:19:14.441-07:00] 1.  Running pass 'Function Pass Manager' on 
module 
'buck-out/v2/gen/fbcode/c475d21d0247c4b4/f3/share/udaf/aggregators/utils/__f3_udaf_aggregation_utils__/__objects__/HybridHistAdditiveNoiseDPState.cpp.o'.
[2023-06-20T05:19:14.441-07:00] 2.  Running pass 'X86 Assembly Printer' on 
function 
'@_ZN8facebook2f37xstream11aggregation5utils15HybridTopKStateIlE4bumpERKll'
[2023-06-20T05:19:14.441-07:00]  #0 0x055513d5 
llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
llvm-project/llvm/lib/Support/Unix/Signals.inc:602:13
[2023-06-20T05:19:14.441-07:00]  #1 0x055517d6 
llvm::sys::RunSignalHandlers() llvm-project/llvm/lib/Support/Signals.cpp:103:5
[2023-06-20T05:19:14.441-07:00]  #2 0x055517d6 SignalHandler(int) 
llvm-project/llvm/lib/Support/Unix/Signals.inc:403:3
[2023-06-20T05:19:14.441-07:00]  #3 0x7f028da4459f 
glibc/2.34/src/glibc-2.34/signal/../sysdeps/unix/sysv/linux/libc_sigaction.c:8:0
[2023-06-20T05:19:14.441-07:00]  #4 0x07c7411e 
llvm::DILexicalBlockFile::classof(llvm::Metadata const*) 
llvm-project/llvm/include/llvm/IR/DebugInfoMetadata.h:2271:32
[2023-06-20T05:19:14.441-07:00]  #5 0x07c7411e 
llvm::isa_impl::doit(llvm::DILocalScope const&) 
llvm-project/llvm/include/llvm/Support/Casting.h:64:53
[2023-06-20T05:19:14.441-07:00]  #6 0x07c7411e 
llvm::isa_impl_cl::doit(llvm::DILocalScope const*) 
llvm-project/llvm/include/llvm/Support/Casting.h:110:12
[2023-06-20T05:19:14.441-07:00]  #7 0x07c7411e 
llvm::isa_impl_wrap::doit(llvm::DILocalScope const* const&) 
llvm-project/llvm/include/llvm/Support/Casting.h:137:12
[2023-06-20T05:19:14.441-07:00]  #8 0x07c7411e 
llvm::isa_impl_wrap::doit(llvm::DILocalScope const* const&) 
llvm-project/llvm/include/llvm/Support/Casting.h:127:12
[2023-06-20T05:19:14.441-07:00]  #9 0x07c7411e 
llvm::CastIsPossible::isPossible(llvm::DILocalScope const* const&) 
llvm-project/llvm/include/llvm/Support/Casting.h:255:12
[2023-06-20T05:19:14.441-07:00] #10 0x07c7411e 
llvm::CastInfo::doCastIfPossible(llvm::DILocalScope const* const&) 
llvm-project/llvm/include/llvm/Support/Casting.h:493:10
[2023-06-20T05:19:14.441-07:00] #11 0x07c7411e decltype(auto) 
llvm::dyn_cast(llvm::DILocalScope const*) 
llvm-project/llvm/include/llvm/Support/Casting.h:663:10
[2023-06-20T05:19:14.441-07:00] #12 0x07c7411e 
llvm::DILocalScope::getNonLexicalBlockFileScope() const 
llvm-project/llvm/lib/IR/DebugInfoMetadata.cpp:1037:20
[2023-06-20T05:19:14.441-07:00] #13 0x07c7411e 
getRetainedNodeScope(llvm::MDNode const*) 
llvm-project/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:1549:33
[2023-06-20T05:19:14.441-07:00] #14 0x07c7411e 
llvm::DwarfDebug::endFunctionImpl(llvm::MachineFunction const*) 
llvm-project/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:2327:24
[2023-06-20T05:19:14.441-07:00] #15 0x07f45860 
llvm::DebugHandlerBase::endFunction(llvm::MachineFunction const*) 
llvm-project/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp:411:5
[2023-06-20T05:19:14.441-07:00] #16 0x07af45e7 
llvm::AsmPrinter::emitFunctionBody() 
llvm-project/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:1894:17
[2023-06-20T05:19:14.441-07:00] #17 0x07af30ca 
llvm::X86AsmPrinter::runOnMachineFunction(llvm::MachineFunction&) 
llvm-project/llvm/lib/Target/X86/X86AsmPrinter.cpp:86:3
[2023-06-20T05:19:14.441-07:00] #18 0x078612f5 
llvm::MachineFunctionPass::runOnFunction(llvm::Function&) 
llvm-project/llvm/lib/CodeGen/MachineFunctionPass.cpp:92:13
[2023-06-20T05:19:14.441-07:00] #19 0x07860981 
llvm::FPPassManager::runOnFunction(llvm::Function&) 
llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1455:27
[2023-06-20T05:19:14.441-07:00] #20 0x07860078 
llvm::FPPassManager::runOnModule(llvm::Module&) 
llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1514:16
[2023-06-20T05:19:14.441-07:00] #21 0x07de90b4 (anonymous 
namespace)::MPPassManager::runOnModule(llvm::Module&) 
llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1583:27
[2023-06-20T05:19:14.441-07:00] #22 0x07de90b4 
llvm::legacy::PassManagerImpl::run(llvm::Module&) 
llvm-project/llvm/lib/IR/LegacyPassManager.cpp:538:44
[2023-06-20T05:19:14.441-07:00] #23 0x05dd8d5a 
codegen(llvm::lto::Config const&, llvm::TargetMachine*, 
std::function>> (unsigned int, llvm::Twine 
const&)>, unsigned int, llvm::Module&, llvm::ModuleSummaryIndex const&) 

[PATCH] D153233: clang: Add __builtin_elementwise_rint and nearbyint

2023-06-20 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 533007.
arsenm marked an inline comment as done.
arsenm added a comment.

Keep fixing documentation


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

https://reviews.llvm.org/D153233

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

Index: clang/test/Sema/builtins-elementwise-math.c
===
--- clang/test/Sema/builtins-elementwise-math.c
+++ clang/test/Sema/builtins-elementwise-math.c
@@ -460,7 +460,6 @@
 }
 
 void test_builtin_elementwise_round(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
-
   struct Foo s = __builtin_elementwise_round(f);
   // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
 
@@ -485,6 +484,56 @@
   // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was '_Complex float')}}
 }
 
+void test_builtin_elementwise_rint(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
+  struct Foo s = __builtin_elementwise_rint(f);
+  // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
+
+  i = __builtin_elementwise_rint();
+  // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
+
+  i = __builtin_elementwise_rint(i);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
+
+  i = __builtin_elementwise_rint(f, f);
+  // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
+
+  u = __builtin_elementwise_rint(u);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}}
+
+  uv = __builtin_elementwise_rint(uv);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
+
+  // FIXME: Error should not mention integer
+  _Complex float c1, c2;
+  c1 = __builtin_elementwise_rint(c1);
+  // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was '_Complex float')}}
+}
+
+void test_builtin_elementwise_nearbyint(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
+  struct Foo s = __builtin_elementwise_nearbyint(f);
+  // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
+
+  i = __builtin_elementwise_nearbyint();
+  // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
+
+  i = __builtin_elementwise_nearbyint(i);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
+
+  i = __builtin_elementwise_nearbyint(f, f);
+  // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
+
+  u = __builtin_elementwise_nearbyint(u);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}}
+
+  uv = __builtin_elementwise_nearbyint(uv);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
+
+  // FIXME: Error should not mention integer
+  _Complex float c1, c2;
+  c1 = __builtin_elementwise_nearbyint(c1);
+  // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was '_Complex float')}}
+}
+
 void test_builtin_elementwise_sin(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
 
   struct Foo s = __builtin_elementwise_sin(f);
Index: clang/test/CodeGen/strictfp-elementwise-bulitins.cpp
===
--- /dev/null
+++ clang/test/CodeGen/strictfp-elementwise-bulitins.cpp
@@ -0,0 +1,216 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -frounding-math -ffp-exception-behavior=strict -O2 -emit-llvm -o - %s | FileCheck %s
+
+typedef float float4 __attribute__((ext_vector_type(4)));
+
+// Sanity check we're getting constrained ops for a non-builtin.
+// CHECK-LABEL: define dso_local noundef <4 x float> @_Z11strict_faddDv4_fS_
+// CHECK-SAME: (<4 x float> noundef [[A:%.*]], <4 x float> noundef [[B:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[ADD:%.*]] = tail call <4 x float> @llvm.experimental.constrained.fadd.v4f32(<4 x float> [[A]], <4 x float> [[B]], metadata !"round.dynamic", metadata !"fpexcept.strict") #[[ATTR4:[0-9]+]]
+// CHECK-NEXT:ret <4 x float> [[ADD]]
+//
+float4 strict_fadd(float4 a, float4 b) {
+  return a + b;
+}
+
+// CHECK-LABEL: define dso_local noundef <4 x float> @_Z22strict_elementwise_absDv4_f
+// CHECK-SAME: (<4 x float> noundef [[A:%.*]]) 

[PATCH] D150803: Add a new `wasm_custom` clang attribute for marking functions.

2023-06-20 Thread Brendan Dahl via Phabricator via cfe-commits
brendandahl added a comment.

@aaron.ballman or @erichkeane Did you want to re-review after that latest 
changes (more generic attribute) or are things good to go?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150803

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


[PATCH] D146148: Float_t and double_t types shouldn't be modified by #pragma clang fp eval_method

2023-06-20 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:6784
+  if (II->getInterestingIdentifierID() != 0)
+NewTD->addAttr(AvailableOnlyInDefaultEvalMethodAttr::Create(Context));
 }

rjmccall wrote:
> Please switch over the interesting identifiers here; we don't want to assume 
> this feature is only used for these two names.
> 
> In fact, should we go ahead and immediately apply it to the four identifiers 
> above this?  That would be nice, because then we could actually do this in 
> two patches: one patch that does the refactor to track interesting 
> identifiers but doesn't cause any functionality changes and a second, very 
> small patch that just introduces the new special treatment for `float_t` and 
> `double_t`.
> Please switch over the interesting identifiers here; we don't want to assume 
> this feature is only used for these two names.
> 
> In fact, should we go ahead and immediately apply it to the four identifiers 
> above this?  That would be nice, because then we could actually do this in 
> two patches: one patch that does the refactor to track interesting 
> identifiers but doesn't cause any functionality changes and a second, very 
> small patch that just introduces the new special treatment for `float_t` and 
> `double_t`.

Are you saying that "FILE", "jmp_buf"," sigjmp_buf" and "ucontext_t" are also 
interesting identifiers? If yes, they should be added to the list of 
interesting identifiers in TokenKinds.def?


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

https://reviews.llvm.org/D146148

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


[PATCH] D153369: [OpenMP] Always apply target declarations to canonical definitions

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

Fix logic


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153369

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/AST/dump.cpp


Index: clang/test/AST/dump.cpp
===
--- clang/test/AST/dump.cpp
+++ clang/test/AST/dump.cpp
@@ -79,11 +79,32 @@
 }
 #pragma omp end declare target
 
-// CHECK:   `-FunctionDecl {{.+}}  
line:[[@LINE-6]]:5 bar 'int ()'
-// CHECK-NEXT:  |-CompoundStmt {{.+}} 
-// CHECK-NEXT:  | |-DeclStmt {{.+}} 
-// CHECK-NEXT:  | | `-VarDecl {{.+}}  col:7 used f 'int'
-// CHECK-NEXT:  | `-ReturnStmt {{.+}} 
-// CHECK-NEXT:  |   `-ImplicitCastExpr {{.+}}  'int' 
-// CHECK-NEXT:  | `-DeclRefExpr {{.+}}  'int' lvalue Var {{.+}} 
'f' 'int'
-// CHECK-NEXT:  `-OMPDeclareTargetDeclAttr {{.+}}  Implicit MT_To 
DT_Any 1
+// CHECK:  |-FunctionDecl {{.+}}  
line:[[@LINE-6]]:5 bar 'int ()'
+// CHECK-NEXT: | |-CompoundStmt {{.+}} 
+// CHECK-NEXT: | | |-DeclStmt {{.+}} 
+// CHECK-NEXT: | | | `-VarDecl {{.+}}  col:7 used f 'int'
+// CHECK-NEXT: | | `-ReturnStmt {{.+}} 
+// CHECK-NEXT: | |   `-ImplicitCastExpr {{.+}}  'int' 
+// CHECK-NEXT: | | `-DeclRefExpr {{.+}}  'int' lvalue Var {{.+}} 
'f' 'int'
+// CHECK-NEXT: | `-OMPDeclareTargetDeclAttr {{.+}}  
Implicit MT_To DT_Any 1
+
+int dx;
+
+extern int dx;
+#pragma omp declare target to(dx)
+
+// CHECK:  |-VarDecl {{.+}}  col:5 dx 'int'
+// CHECK-NEXT: | `-OMPDeclareTargetDeclAttr {{.+}}  
Implicit MT_To DT_Any 4294967295
+// CHECK:  |-VarDecl {{.+}} prev {{.+}}  
col:12 dx 'int' extern
+// CHECK-NEXT: | `-OMPDeclareTargetDeclAttr {{.+}}  
Implicit MT_To DT_Any 4294967295
+
+int dy;
+
+#pragma omp begin declare target
+extern int dy;
+#pragma omp end declare target
+
+// CHECK:  |-VarDecl {{.+}}  col:5 dy 'int'
+// CHECK-NEXT: | `-OMPDeclareTargetDeclAttr {{.+}}  
Implicit MT_To DT_Any 1
+// CHECK:  `-VarDecl {{.+}} prev {{.+}}  
col:12 dy 'int' extern
+// CHECK-NEXT:   `-OMPDeclareTargetDeclAttr {{.+}}  
Implicit MT_To DT_Any 1
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -22988,6 +22988,15 @@
   ND->addAttr(A);
   if (ASTMutationListener *ML = Context.getASTMutationListener())
 ML->DeclarationMarkedOpenMPDeclareTarget(ND, A);
+
+  // If this was not a canonical definition we need to update it as well.
+  if (auto *CD = dyn_cast(ND->getCanonicalDecl())) {
+if (!CD->hasAttr()) {
+  CD->addAttr(A);
+  if (ASTMutationListener *ML = Context.getASTMutationListener())
+ML->DeclarationMarkedOpenMPDeclareTarget(CD, A);
+}
+  }
   checkDeclIsAllowedInOpenMPTarget(nullptr, ND, Loc);
 }
 
@@ -23092,6 +23101,15 @@
 D->addAttr(A);
 if (ASTMutationListener *ML = Context.getASTMutationListener())
   ML->DeclarationMarkedOpenMPDeclareTarget(D, A);
+
+// If this was not a canonical definition we need to update it as well.
+if (auto *CD = dyn_cast(D->getCanonicalDecl())) {
+  if (!CD->hasAttr()) {
+CD->addAttr(A);
+if (ASTMutationListener *ML = Context.getASTMutationListener())
+  ML->DeclarationMarkedOpenMPDeclareTarget(CD, A);
+  }
+}
   }
   return;
 }


Index: clang/test/AST/dump.cpp
===
--- clang/test/AST/dump.cpp
+++ clang/test/AST/dump.cpp
@@ -79,11 +79,32 @@
 }
 #pragma omp end declare target
 
-// CHECK:   `-FunctionDecl {{.+}}  line:[[@LINE-6]]:5 bar 'int ()'
-// CHECK-NEXT:  |-CompoundStmt {{.+}} 
-// CHECK-NEXT:  | |-DeclStmt {{.+}} 
-// CHECK-NEXT:  | | `-VarDecl {{.+}}  col:7 used f 'int'
-// CHECK-NEXT:  | `-ReturnStmt {{.+}} 
-// CHECK-NEXT:  |   `-ImplicitCastExpr {{.+}}  'int' 
-// CHECK-NEXT:  | `-DeclRefExpr {{.+}}  'int' lvalue Var {{.+}} 'f' 'int'
-// CHECK-NEXT:  `-OMPDeclareTargetDeclAttr {{.+}}  Implicit MT_To DT_Any 1
+// CHECK:  |-FunctionDecl {{.+}}  line:[[@LINE-6]]:5 bar 'int ()'
+// CHECK-NEXT: | |-CompoundStmt {{.+}} 
+// CHECK-NEXT: | | |-DeclStmt {{.+}} 
+// CHECK-NEXT: | | | `-VarDecl {{.+}}  col:7 used f 'int'
+// CHECK-NEXT: | | `-ReturnStmt {{.+}} 
+// CHECK-NEXT: | |   `-ImplicitCastExpr {{.+}}  'int' 
+// CHECK-NEXT: | | `-DeclRefExpr {{.+}}  'int' lvalue Var {{.+}} 'f' 'int'
+// CHECK-NEXT: | `-OMPDeclareTargetDeclAttr {{.+}}  Implicit MT_To DT_Any 1
+
+int dx;
+
+extern int dx;
+#pragma omp declare target to(dx)
+
+// CHECK:  |-VarDecl {{.+}}  col:5 dx 'int'
+// CHECK-NEXT: | `-OMPDeclareTargetDeclAttr {{.+}}  Implicit MT_To DT_Any 4294967295
+// CHECK:  |-VarDecl {{.+}} prev {{.+}}  col:12 dx 'int' extern
+// CHECK-NEXT: | `-OMPDeclareTargetDeclAttr {{.+}}  Implicit MT_To DT_Any 4294967295
+
+int dy;
+
+#pragma omp begin declare 

[PATCH] D153369: [OpenMP] Always apply target declarations to canonical definitions

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

Adding AST mutation listener to the other modified declaration to signal that 
it was changed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153369

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/AST/dump.cpp


Index: clang/test/AST/dump.cpp
===
--- clang/test/AST/dump.cpp
+++ clang/test/AST/dump.cpp
@@ -79,11 +79,32 @@
 }
 #pragma omp end declare target
 
-// CHECK:   `-FunctionDecl {{.+}}  
line:[[@LINE-6]]:5 bar 'int ()'
-// CHECK-NEXT:  |-CompoundStmt {{.+}} 
-// CHECK-NEXT:  | |-DeclStmt {{.+}} 
-// CHECK-NEXT:  | | `-VarDecl {{.+}}  col:7 used f 'int'
-// CHECK-NEXT:  | `-ReturnStmt {{.+}} 
-// CHECK-NEXT:  |   `-ImplicitCastExpr {{.+}}  'int' 
-// CHECK-NEXT:  | `-DeclRefExpr {{.+}}  'int' lvalue Var {{.+}} 
'f' 'int'
-// CHECK-NEXT:  `-OMPDeclareTargetDeclAttr {{.+}}  Implicit MT_To 
DT_Any 1
+// CHECK:  |-FunctionDecl {{.+}}  
line:[[@LINE-6]]:5 bar 'int ()'
+// CHECK-NEXT: | |-CompoundStmt {{.+}} 
+// CHECK-NEXT: | | |-DeclStmt {{.+}} 
+// CHECK-NEXT: | | | `-VarDecl {{.+}}  col:7 used f 'int'
+// CHECK-NEXT: | | `-ReturnStmt {{.+}} 
+// CHECK-NEXT: | |   `-ImplicitCastExpr {{.+}}  'int' 
+// CHECK-NEXT: | | `-DeclRefExpr {{.+}}  'int' lvalue Var {{.+}} 
'f' 'int'
+// CHECK-NEXT: | `-OMPDeclareTargetDeclAttr {{.+}}  
Implicit MT_To DT_Any 1
+
+int dx;
+
+extern int dx;
+#pragma omp declare target to(dx)
+
+// CHECK:  |-VarDecl {{.+}}  col:5 dx 'int'
+// CHECK-NEXT: | `-OMPDeclareTargetDeclAttr {{.+}}  
Implicit MT_To DT_Any 4294967295
+// CHECK:  |-VarDecl {{.+}} prev {{.+}}  
col:12 dx 'int' extern
+// CHECK-NEXT: | `-OMPDeclareTargetDeclAttr {{.+}}  
Implicit MT_To DT_Any 4294967295
+
+int dy;
+
+#pragma omp begin declare target
+extern int dy;
+#pragma omp end declare target
+
+// CHECK:  |-VarDecl {{.+}}  col:5 dy 'int'
+// CHECK-NEXT: | `-OMPDeclareTargetDeclAttr {{.+}}  
Implicit MT_To DT_Any 1
+// CHECK:  `-VarDecl {{.+}} prev {{.+}}  
col:12 dy 'int' extern
+// CHECK-NEXT:   `-OMPDeclareTargetDeclAttr {{.+}}  
Implicit MT_To DT_Any 1
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -22986,6 +22986,9 @@
   Context, MT, DTCI.DT, IndirectE, IsIndirect, Level,
   SourceRange(Loc, Loc));
   ND->addAttr(A);
+  if (auto *CD = dyn_cast(ND->getCanonicalDecl()))
+if (!CD->hasAttr())
+  CD->addAttr(A);
   if (ASTMutationListener *ML = Context.getASTMutationListener())
 ML->DeclarationMarkedOpenMPDeclareTarget(ND, A);
   checkDeclIsAllowedInOpenMPTarget(nullptr, ND, Loc);
@@ -23090,8 +23093,15 @@
 DTCI.DT, IndirectE, IsIndirect, Level,
 SourceRange(DTCI.Loc, DTCI.Loc));
 D->addAttr(A);
-if (ASTMutationListener *ML = Context.getASTMutationListener())
+if (auto *CD = dyn_cast(D->getCanonicalDecl()))
+  if (!CD->hasAttr())
+CD->addAttr(A);
+if (ASTMutationListener *ML = Context.getASTMutationListener()) {
   ML->DeclarationMarkedOpenMPDeclareTarget(D, A);
+  if (auto *CD = dyn_cast(D->getCanonicalDecl()))
+if (!CD->hasAttr())
+  ML->DeclarationMarkedOpenMPDeclareTarget(CD, A);
+}
   }
   return;
 }


Index: clang/test/AST/dump.cpp
===
--- clang/test/AST/dump.cpp
+++ clang/test/AST/dump.cpp
@@ -79,11 +79,32 @@
 }
 #pragma omp end declare target
 
-// CHECK:   `-FunctionDecl {{.+}}  line:[[@LINE-6]]:5 bar 'int ()'
-// CHECK-NEXT:  |-CompoundStmt {{.+}} 
-// CHECK-NEXT:  | |-DeclStmt {{.+}} 
-// CHECK-NEXT:  | | `-VarDecl {{.+}}  col:7 used f 'int'
-// CHECK-NEXT:  | `-ReturnStmt {{.+}} 
-// CHECK-NEXT:  |   `-ImplicitCastExpr {{.+}}  'int' 
-// CHECK-NEXT:  | `-DeclRefExpr {{.+}}  'int' lvalue Var {{.+}} 'f' 'int'
-// CHECK-NEXT:  `-OMPDeclareTargetDeclAttr {{.+}}  Implicit MT_To DT_Any 1
+// CHECK:  |-FunctionDecl {{.+}}  line:[[@LINE-6]]:5 bar 'int ()'
+// CHECK-NEXT: | |-CompoundStmt {{.+}} 
+// CHECK-NEXT: | | |-DeclStmt {{.+}} 
+// CHECK-NEXT: | | | `-VarDecl {{.+}}  col:7 used f 'int'
+// CHECK-NEXT: | | `-ReturnStmt {{.+}} 
+// CHECK-NEXT: | |   `-ImplicitCastExpr {{.+}}  'int' 
+// CHECK-NEXT: | | `-DeclRefExpr {{.+}}  'int' lvalue Var {{.+}} 'f' 'int'
+// CHECK-NEXT: | `-OMPDeclareTargetDeclAttr {{.+}}  Implicit MT_To DT_Any 1
+
+int dx;
+
+extern int dx;
+#pragma omp declare target to(dx)
+
+// CHECK:  |-VarDecl {{.+}}  col:5 dx 'int'
+// CHECK-NEXT: | `-OMPDeclareTargetDeclAttr {{.+}}  Implicit MT_To DT_Any 4294967295
+// CHECK:  |-VarDecl {{.+}} prev {{.+}}  col:12 dx 'int' extern
+// CHECK-NEXT: | `-OMPDeclareTargetDeclAttr {{.+}}  Implicit MT_To DT_Any 4294967295
+
+int 

[PATCH] D153369: [OpenMP] Always apply target declarations to canonical definitions

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



Comment at: clang/lib/Sema/SemaOpenMP.cpp:23099
+CD->addAttr(A);
 if (ASTMutationListener *ML = Context.getASTMutationListener())
   ML->DeclarationMarkedOpenMPDeclareTarget(D, A);

Need to use   ML->DeclarationMarkedOpenMPDeclareTarget for CD too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153369

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


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

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

Rebase to latest main.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152996

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

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


[PATCH] D152879: [RISCV] Model vxrm control for vsmul, vssra, vssrl, vnclip, and vnclipu

2023-06-20 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9ed668ad9321: [RISCV] Model vxrm control for vsmul, vssra, 
vssrl, vnclip, and vnclipu (authored by eopXD).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152879

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/Sema/SemaChecking.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vnclip.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vnclipu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssra.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssrl.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vnclip.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vnclipu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vssra.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vssrl.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vnclip.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vnclipu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vsmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vssra.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vssrl.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vnclip.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vnclipu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vsmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vssra.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vssrl.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vnclip-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vnclipu-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vsmul-eew64-overloaded.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vsmul-eew64.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vsmul-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vssra-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vssrl-out-of-range.c
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
  llvm/test/CodeGen/RISCV/rvv/masked-tama.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tamu.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tuma.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tumu.ll
  llvm/test/CodeGen/RISCV/rvv/mutate-prior-vsetvli-avl.ll
  llvm/test/CodeGen/RISCV/rvv/unmasked-tu.ll
  llvm/test/CodeGen/RISCV/rvv/vnclip.ll
  llvm/test/CodeGen/RISCV/rvv/vnclipu.ll
  llvm/test/CodeGen/RISCV/rvv/vsmul-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vsmul-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vssra-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vssra-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vssrl-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vssrl-rv64.ll

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


[PATCH] D151397: [3/3][RISCV][POC] Model vxrm in C intrinsics for RVV fixed-point instruction vaadd, vasub

2023-06-20 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5510f0b8f4b1: [3/3][RISCV][POC] Model vxrm in C intrinsics 
for RVV fixed-point instruction… (authored by eopXD).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151397

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/Sema/SemaChecking.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaaddu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vasub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vasubu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaaddu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vasub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vasubu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vaadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vaaddu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vasub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vasubu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vaadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vaaddu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vasub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vasubu.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vaadd-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vaaddu-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vasub-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vasubu-out-of-range.c
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
  llvm/test/CodeGen/RISCV/rvv/masked-tama.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tamu.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tuma.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tumu.ll
  llvm/test/CodeGen/RISCV/rvv/vaadd.ll
  llvm/test/CodeGen/RISCV/rvv/vaaddu.ll
  llvm/test/CodeGen/RISCV/rvv/vasub.ll
  llvm/test/CodeGen/RISCV/rvv/vasubu.ll

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


[PATCH] D152953: [clang-tidy] Introduce fuchsia-global-variables check

2023-06-20 Thread Caslyn Tonelli via Phabricator via cfe-commits
Caslyn created this revision.
Herald added subscribers: PiotrZSL, carlosgalvezp, abrachet, phosek, xazax.hun.
Herald added a reviewer: njames93.
Herald added a project: All.
Caslyn updated this revision to Diff 531489.
Caslyn added a comment.
Caslyn updated this revision to Diff 531932.
Caslyn updated this revision to Diff 532713.
Caslyn added reviewers: ymandel, Prabhuk.
Caslyn published this revision for review.
Herald added projects: LLVM, clang-tools-extra.
Herald added subscribers: cfe-commits, llvm-commits.

Fixes, cleanups.


Caslyn added a comment.

Include exception for variables declared in macros; cleanups.


Caslyn added a comment.

Add constinit exception, remove G3 exceptions


Introduce a clang-tidy check to the fuchsia module to warn of any static
or global variables that do not have trivial destructors.

The implementation is a pared down version of the Google3
check 

 with configurable options to add types for the check to ignore
(e.g. LazyRE2).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152953

Files:
  clang-tools-extra/clang-tidy/fuchsia/CMakeLists.txt
  clang-tools-extra/clang-tidy/fuchsia/FuchsiaTidyModule.cpp
  clang-tools-extra/clang-tidy/fuchsia/GlobalVariablesCheck.cpp
  clang-tools-extra/clang-tidy/fuchsia/GlobalVariablesCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/fuchsia/global-variables.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/fuchsia/global-variables.cpp
  llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/fuchsia/BUILD.gn

Index: llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/fuchsia/BUILD.gn
===
--- llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/fuchsia/BUILD.gn
+++ llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/fuchsia/BUILD.gn
@@ -16,6 +16,7 @@
 "DefaultArgumentsDeclarationsCheck.cpp",
 "FuchsiaTidyModule.cpp",
 "MultipleInheritanceCheck.cpp",
+"GlobalVariablesCheck.cpp",
 "OverloadedOperatorCheck.cpp",
 "StaticallyConstructedObjectsCheck.cpp",
 "TrailingReturnCheck.cpp",
Index: clang-tools-extra/test/clang-tidy/checkers/fuchsia/global-variables.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/fuchsia/global-variables.cpp
@@ -0,0 +1,160 @@
+// RUN: %check_clang_tidy %s fuchsia-global-variables %t \
+// RUN: -config="{CheckOptions: \
+// RUN:   [{key: fuchsia-global-variables.Ignore, value: 'LazyRE2;ThreadLocal'}] \
+// RUN:  }"
+
+using size_t = decltype(sizeof(int));
+
+namespace std {
+template
+struct array {
+  ~array() {};
+  T Element;
+};
+template
+struct array {};
+}  // namespace std */
+
+class TriviallyDestructibleClass {
+ public:
+  // This is a trivially destructible class.
+  TriviallyDestructibleClass() : I(0) {}
+  TriviallyDestructibleClass(int I) : I(I) {}
+
+  int I;
+  float F;
+  char C;
+  char Cs[10];
+};
+
+class NonTriviallyDestructibleClass {
+ public:
+  NonTriviallyDestructibleClass() : Var(0) {}
+  NonTriviallyDestructibleClass(int Var) : Var(Var) {}
+  // We need a destructor to make the class non trivially destructible.
+  ~NonTriviallyDestructibleClass() {}
+  int Var;
+};
+
+template 
+class NonTriviallyDestructibleTemplateClass {
+ public:
+  // We need a destructor to make the class non trivially destructible.
+  ~NonTriviallyDestructibleTemplateClass() {}
+  int Var;
+  T Var2;
+};
+
+int global_i;
+_Atomic size_t global_atomic;
+
+TriviallyDestructibleClass trivially_destructible_class;
+
+NonTriviallyDestructibleClass non_trivially_destructible;
+// CHECK-MESSAGES: [[@LINE-1]]:31: warning: static and global variables are forbidden unless they are trivially destructible [fuchsia-global-variables]
+
+[[clang::no_destroy]] NonTriviallyDestructibleClass non_trivially_destructible_no_destroy;
+
+TriviallyDestructibleClass trivially_destructible_array[2] = {
+TriviallyDestructibleClass(1), TriviallyDestructibleClass(2)};
+
+NonTriviallyDestructibleClass non_trivially_destructible_array[2] = {
+NonTriviallyDestructibleClass(1), NonTriviallyDestructibleClass(2)};
+// CHECK-MESSAGES: [[@LINE-2]]:31: warning: static and global variables are forbidden unless they are trivially destructible [fuchsia-global-variables]
+
+const TriviallyDestructibleClass trivially_destructible_const_array[2] = {
+TriviallyDestructibleClass(1), TriviallyDestructibleClass(2)};
+
+const NonTriviallyDestructibleClass non_trivially_destructible_const_array[2] = {
+NonTriviallyDestructibleClass(1), NonTriviallyDestructibleClass(2)};
+// CHECK-MESSAGES: [[@LINE-2]]:37: warning: static and global variables are forbidden unless they are trivially destructible [fuchsia-global-variables]
+
+TriviallyDestructibleClass 

[PATCH] D153370: [RISCV] Add support for custom instructions for Sifive S76.

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

Support for below instruction is added

1. CFLUSH.D.L1 
2. CDISCARD.D.L1 
3. CEASE

Additionally, Zihintpause extension is added to sifive s76 for pause
instruction.

Spec - 
https://sifive.cdn.prismic.io/sifive/767804da-53b2-4893-97d5-b7c030ae0a94_s76mc_core_complex_manual_21G3.pdf


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153370

Files:
  clang/test/Driver/riscv-cpus.c
  llvm/docs/RISCVUsage.rst
  llvm/docs/ReleaseNotes.rst
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
  llvm/lib/Target/RISCV/RISCVFeatures.td
  llvm/lib/Target/RISCV/RISCVInstrInfoXSf.td
  llvm/lib/Target/RISCV/RISCVProcessors.td
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/xsfcie-invalid.s
  llvm/test/MC/RISCV/xsfcie-valid.s

Index: llvm/test/MC/RISCV/xsfcie-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/xsfcie-valid.s
@@ -0,0 +1,38 @@
+# SFCIE - SiFive S76 Custom Instructions and CSRs.
+# RUN: llvm-mc %s -triple=riscv64 -mcpu=sifive-s76 -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ENC,CHECK-INST %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+xsfcie -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ENC,CHECK-INST %s
+# RUN: llvm-mc -filetype=obj -triple riscv64 -mcpu=sifive-s76 < %s \
+# RUN: | llvm-objdump --mcpu=sifive-s76 -M no-aliases -d - \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+xsfcie < %s \
+# RUN: | llvm-objdump --mattr=+xsfcie -M no-aliases -d - \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+
+# CHECK-INST: cflush.d.l1 zero
+# CHECK-ENC: encoding: [0x73,0x00,0x00,0xfc]
+# CHECK-INST: cflush.d.l1 zero
+# CHECK-ENC: encoding: [0x73,0x00,0x00,0xfc]
+cflush.d.l1 x0
+cflush.d.l1
+
+# CHECK-INST: cflush.d.l1 t2
+# CHECK-ENC: encoding: [0x73,0x80,0x03,0xfc]
+cflush.d.l1 x7
+
+# CHECK-INST: cdiscard.d.l1   zero
+# CHECK-ENC: encoding: [0x73,0x00,0x20,0xfc]
+# CHECK-INST: cdiscard.d.l1 zero
+# CHECK-ENC: encoding: [0x73,0x00,0x20,0xfc]
+cdiscard.d.l1 x0
+cdiscard.d.l1
+
+# CHECK-INST: cdiscard.d.l1   t2
+# CHECK-ENC: encoding: [0x73,0x80,0x23,0xfc]
+cdiscard.d.l1 x7
+
+# CHECK-INST: cease
+# CHECK-ENC: encoding: [0x73,0x00,0x50,0x30]
+cease
+
Index: llvm/test/MC/RISCV/xsfcie-invalid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/xsfcie-invalid.s
@@ -0,0 +1,24 @@
+# SFCIE - SiFive S76 Custom Instructions and CSRs.
+# RUN: not llvm-mc -triple riscv64 -mattr=-xsfcie < %s 2>&1 | FileCheck %s
+
+cflush.d.l1 0x10 # CHECK: :[[@LINE]]:13: error: invalid operand for instruction
+
+cdiscard.d.l1 0x10 # CHECK: :[[@LINE]]:15: error: invalid operand for instruction
+
+cflush.d.l1 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'XSfcie' (SiFive Custom Instruction Extension SFCIE for S76.)
+
+cdiscard.d.l1 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'XSfcie' (SiFive Custom Instruction Extension SFCIE for S76.)
+
+cflush.d.l1 x0 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'XSfcie' (SiFive Custom Instruction Extension SFCIE for S76.)
+
+cflush.d.l1 x7 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'XSfcie' (SiFive Custom Instruction Extension SFCIE for S76.)
+
+cdiscard.d.l1 x0 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'XSfcie' (SiFive Custom Instruction Extension SFCIE for S76.)
+
+cdiscard.d.l1 x7 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'XSfcie' (SiFive Custom Instruction Extension SFCIE for S76.)
+
+cease x1 # CHECK: :[[@LINE]]:7: error: invalid operand for instruction
+
+cease 0x10 # CHECK: :[[@LINE]]:7: error: invalid operand for instruction
+
+cease # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'XSfcie' (SiFive Custom Instruction Extension SFCIE for S76 MC)
Index: llvm/test/MC/RISCV/attribute-arch.s
===
--- llvm/test/MC/RISCV/attribute-arch.s
+++ llvm/test/MC/RISCV/attribute-arch.s
@@ -278,3 +278,6 @@
 
 .attribute arch, "rv32i_zvfbfwma0p6"
 # CHECK: .attribute 5, 

[PATCH] D150803: Add a new `wasm_custom` clang attribute for marking functions.

2023-06-20 Thread Dan Gohman via Phabricator via cfe-commits
sunfish added a comment.

In D150803#4419436 , @sbc100 wrote:

> Did you mean to comment on the old PR?  This new PR doesn't propose either 
> "jspi" or "async", but adds that ability to define custom attributes.. since 
> that was deemed more flexible and forward thinking.   The decision as to 
> which name emscripten will use for what can then be part of  different 
> discussion/PR we hope.

Ah, I think I somehow was looking at the old PR, and thought there was a test 
with `custom_section.func_attr.async` in it.

This patch looks ok, though my initial impression is that if we're going to 
have a fully general-purpose mechanism like this, we might want to plan ahead 
for attributes that have parameters. We don't need to implement it now though; 
if there's a reasonable way to evolve in that direction, then this LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150803

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


[PATCH] D153248: [clangd] Use resolveTypeToRecordDecl() to resolve the type of a base specifier during heuristic resolution

2023-06-20 Thread Nathan Ridge via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6fe9cfe4137b: [clangd] Use resolveTypeToRecordDecl() to 
resolve the type of a base specifier… (authored by nridge).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153248

Files:
  clang-tools-extra/clangd/HeuristicResolver.cpp
  clang-tools-extra/clangd/HeuristicResolver.h
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp

Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -893,6 +893,19 @@
 }
   )cpp";
   EXPECT_DECLS("CXXDependentScopeMemberExpr", "void find()");
+
+  Code = R"cpp(
+struct Waldo {
+  void find();
+};
+template 
+using Wally = Waldo;
+template 
+struct S : Wally {
+  void Foo() { this->[[find]](); }
+};
+  )cpp";
+  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void find()");
 }
 
 TEST_F(TargetDeclTest, DependentTypes) {
Index: clang-tools-extra/clangd/HeuristicResolver.h
===
--- clang-tools-extra/clangd/HeuristicResolver.h
+++ clang-tools-extra/clangd/HeuristicResolver.h
@@ -16,6 +16,7 @@
 
 class ASTContext;
 class CallExpr;
+class CXXBasePath;
 class CXXDependentScopeMemberExpr;
 class DeclarationName;
 class DependentScopeDeclRefExpr;
@@ -99,6 +100,20 @@
   // which takes a possibly-dependent type `T` and heuristically
   // resolves it to a CXXRecordDecl in which we can try name lookup.
   CXXRecordDecl *resolveTypeToRecordDecl(const Type *T) const;
+
+  // This is a reimplementation of CXXRecordDecl::lookupDependentName()
+  // so that the implementation can call into other HeuristicResolver helpers.
+  // FIXME: Once HeuristicResolver is upstreamed to the clang libraries
+  // (https://github.com/clangd/clangd/discussions/1662),
+  // CXXRecordDecl::lookupDepenedentName() can be removed, and its call sites
+  // can be modified to benefit from the more comprehensive heuristics offered
+  // by HeuristicResolver instead.
+  std::vector lookupDependentName(
+  CXXRecordDecl *RD, DeclarationName Name,
+  llvm::function_ref Filter) const;
+  bool findOrdinaryMemberInDependentClasses(const CXXBaseSpecifier *Specifier,
+CXXBasePath ,
+DeclarationName Name) const;
 };
 
 } // namespace clangd
Index: clang-tools-extra/clangd/HeuristicResolver.cpp
===
--- clang-tools-extra/clangd/HeuristicResolver.cpp
+++ clang-tools-extra/clangd/HeuristicResolver.cpp
@@ -8,6 +8,7 @@
 
 #include "HeuristicResolver.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/AST/CXXInheritance.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/Type.h"
@@ -264,6 +265,68 @@
   return nullptr;
 }
 
+namespace {
+
+bool isOrdinaryMember(const NamedDecl *ND) {
+  return ND->isInIdentifierNamespace(Decl::IDNS_Ordinary | Decl::IDNS_Tag |
+ Decl::IDNS_Member);
+}
+
+bool findOrdinaryMember(const CXXRecordDecl *RD, CXXBasePath ,
+DeclarationName Name) {
+  Path.Decls = RD->lookup(Name).begin();
+  for (DeclContext::lookup_iterator I = Path.Decls, E = I.end(); I != E; ++I)
+if (isOrdinaryMember(*I))
+  return true;
+
+  return false;
+}
+
+} // namespace
+
+bool HeuristicResolver::findOrdinaryMemberInDependentClasses(
+const CXXBaseSpecifier *Specifier, CXXBasePath ,
+DeclarationName Name) const {
+  CXXRecordDecl *RD =
+  resolveTypeToRecordDecl(Specifier->getType().getTypePtr());
+  if (!RD)
+return false;
+  return findOrdinaryMember(RD, Path, Name);
+}
+
+std::vector HeuristicResolver::lookupDependentName(
+CXXRecordDecl *RD, DeclarationName Name,
+llvm::function_ref Filter) const {
+  std::vector Results;
+
+  // Lookup in the class.
+  bool AnyOrdinaryMembers = false;
+  for (const NamedDecl *ND : RD->lookup(Name)) {
+if (isOrdinaryMember(ND))
+  AnyOrdinaryMembers = true;
+if (Filter(ND))
+  Results.push_back(ND);
+  }
+  if (AnyOrdinaryMembers)
+return Results;
+
+  // Perform lookup into our base classes.
+  CXXBasePaths Paths;
+  Paths.setOrigin(RD);
+  if (!RD->lookupInBases(
+  [&](const CXXBaseSpecifier *Specifier, CXXBasePath ) {
+return findOrdinaryMemberInDependentClasses(Specifier, Path, Name);
+  },
+  Paths, /*LookupInDependent=*/true))
+return Results;
+  for (DeclContext::lookup_iterator I = Paths.front().Decls, E = I.end();
+   I != E; ++I) {
+if (isOrdinaryMember(*I) && Filter(*I))
+  Results.push_back(*I);
+  }
+  

[clang-tools-extra] 6fe9cfe - [clangd] Use resolveTypeToRecordDecl() to resolve the type of a base specifier during heuristic resolution

2023-06-20 Thread Nathan Ridge via cfe-commits

Author: Nathan Ridge
Date: 2023-06-20T13:40:26-04:00
New Revision: 6fe9cfe4137bc140c909850c26b52e9406495566

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

LOG: [clangd] Use resolveTypeToRecordDecl() to resolve the type of a base 
specifier during heuristic resolution

The code for resolving the type of a base specifier was inside
CXXRecordDecl::lookupDependentName(), so this patch reimplements
lookupDependentName() in HeuristicResolver.

Fixes https://github.com/clangd/clangd/issues/1657

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

Added: 


Modified: 
clang-tools-extra/clangd/HeuristicResolver.cpp
clang-tools-extra/clangd/HeuristicResolver.h
clang-tools-extra/clangd/unittests/FindTargetTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/HeuristicResolver.cpp 
b/clang-tools-extra/clangd/HeuristicResolver.cpp
index 7960ab92ba9e6..719094dbf2b7e 100644
--- a/clang-tools-extra/clangd/HeuristicResolver.cpp
+++ b/clang-tools-extra/clangd/HeuristicResolver.cpp
@@ -8,6 +8,7 @@
 
 #include "HeuristicResolver.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/AST/CXXInheritance.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/Type.h"
@@ -264,6 +265,68 @@ const Type 
*HeuristicResolver::resolveNestedNameSpecifierToType(
   return nullptr;
 }
 
+namespace {
+
+bool isOrdinaryMember(const NamedDecl *ND) {
+  return ND->isInIdentifierNamespace(Decl::IDNS_Ordinary | Decl::IDNS_Tag |
+ Decl::IDNS_Member);
+}
+
+bool findOrdinaryMember(const CXXRecordDecl *RD, CXXBasePath ,
+DeclarationName Name) {
+  Path.Decls = RD->lookup(Name).begin();
+  for (DeclContext::lookup_iterator I = Path.Decls, E = I.end(); I != E; ++I)
+if (isOrdinaryMember(*I))
+  return true;
+
+  return false;
+}
+
+} // namespace
+
+bool HeuristicResolver::findOrdinaryMemberInDependentClasses(
+const CXXBaseSpecifier *Specifier, CXXBasePath ,
+DeclarationName Name) const {
+  CXXRecordDecl *RD =
+  resolveTypeToRecordDecl(Specifier->getType().getTypePtr());
+  if (!RD)
+return false;
+  return findOrdinaryMember(RD, Path, Name);
+}
+
+std::vector HeuristicResolver::lookupDependentName(
+CXXRecordDecl *RD, DeclarationName Name,
+llvm::function_ref Filter) const {
+  std::vector Results;
+
+  // Lookup in the class.
+  bool AnyOrdinaryMembers = false;
+  for (const NamedDecl *ND : RD->lookup(Name)) {
+if (isOrdinaryMember(ND))
+  AnyOrdinaryMembers = true;
+if (Filter(ND))
+  Results.push_back(ND);
+  }
+  if (AnyOrdinaryMembers)
+return Results;
+
+  // Perform lookup into our base classes.
+  CXXBasePaths Paths;
+  Paths.setOrigin(RD);
+  if (!RD->lookupInBases(
+  [&](const CXXBaseSpecifier *Specifier, CXXBasePath ) {
+return findOrdinaryMemberInDependentClasses(Specifier, Path, Name);
+  },
+  Paths, /*LookupInDependent=*/true))
+return Results;
+  for (DeclContext::lookup_iterator I = Paths.front().Decls, E = I.end();
+   I != E; ++I) {
+if (isOrdinaryMember(*I) && Filter(*I))
+  Results.push_back(*I);
+  }
+  return Results;
+}
+
 std::vector HeuristicResolver::resolveDependentMember(
 const Type *T, DeclarationName Name,
 llvm::function_ref Filter) const {
@@ -277,7 +340,7 @@ std::vector 
HeuristicResolver::resolveDependentMember(
 if (!RD->hasDefinition())
   return {};
 RD = RD->getDefinition();
-return RD->lookupDependentName(Name, Filter);
+return lookupDependentName(RD, Name, Filter);
   }
   return {};
 }

diff  --git a/clang-tools-extra/clangd/HeuristicResolver.h 
b/clang-tools-extra/clangd/HeuristicResolver.h
index 6e3a8349a8606..dc04123d37593 100644
--- a/clang-tools-extra/clangd/HeuristicResolver.h
+++ b/clang-tools-extra/clangd/HeuristicResolver.h
@@ -16,6 +16,7 @@ namespace clang {
 
 class ASTContext;
 class CallExpr;
+class CXXBasePath;
 class CXXDependentScopeMemberExpr;
 class DeclarationName;
 class DependentScopeDeclRefExpr;
@@ -99,6 +100,20 @@ class HeuristicResolver {
   // which takes a possibly-dependent type `T` and heuristically
   // resolves it to a CXXRecordDecl in which we can try name lookup.
   CXXRecordDecl *resolveTypeToRecordDecl(const Type *T) const;
+
+  // This is a reimplementation of CXXRecordDecl::lookupDependentName()
+  // so that the implementation can call into other HeuristicResolver helpers.
+  // FIXME: Once HeuristicResolver is upstreamed to the clang libraries
+  // (https://github.com/clangd/clangd/discussions/1662),
+  // CXXRecordDecl::lookupDepenedentName() can be removed, and its call sites
+  // can be modified to benefit from the more comprehensive heuristics offered
+  // by HeuristicResolver 

[PATCH] D146148: Float_t and double_t types shouldn't be modified by #pragma clang fp eval_method

2023-06-20 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:6784
+  if (II->getInterestingIdentifierID() != 0)
+NewTD->addAttr(AvailableOnlyInDefaultEvalMethodAttr::Create(Context));
 }

Please switch over the interesting identifiers here; we don't want to assume 
this feature is only used for these two names.

In fact, should we go ahead and immediately apply it to the four identifiers 
above this?  That would be nice, because then we could actually do this in two 
patches: one patch that does the refactor to track interesting identifiers but 
doesn't cause any functionality changes and a second, very small patch that 
just introduces the new special treatment for `float_t` and `double_t`.


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

https://reviews.llvm.org/D146148

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


[PATCH] D153369: [OpenMP] Always apply target declarations to canonical definitions

2023-06-20 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, tianshilei1992, JonChesterfield, tra, 
ABataev, carlo.bertolli.
Herald added subscribers: sunshaoce, guansong.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, jplehr, sstefan1.
Herald added a project: clang.

This patch changes the handling of OpenMP to add the device attributes
to the canonical definitions when we encounter a non-canonical
definition. Previously, the following code would not work because it
would find the non-canonical definition first which would then not be
used anywhere else.

  int x;
  extern int x;

This patch now adds the attribute to both of them. This allows us to
perform the following operation if, for example, there were an
implementation of `stderr` on the device.

  #include 
  
  // List of libc symbols supported on the device.
  extern FILE *stderr;

Unfortunately I cannot think of an equivalent solution to HIP / CUDA
device declarations as those are done with simple attributes. Attributes
themselves cannot be used to affect a definition once its canonical
definition has already been seen. Some help on that front would be
appreciated.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153369

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/AST/dump.cpp


Index: clang/test/AST/dump.cpp
===
--- clang/test/AST/dump.cpp
+++ clang/test/AST/dump.cpp
@@ -79,11 +79,32 @@
 }
 #pragma omp end declare target
 
-// CHECK:   `-FunctionDecl {{.+}}  
line:[[@LINE-6]]:5 bar 'int ()'
-// CHECK-NEXT:  |-CompoundStmt {{.+}} 
-// CHECK-NEXT:  | |-DeclStmt {{.+}} 
-// CHECK-NEXT:  | | `-VarDecl {{.+}}  col:7 used f 'int'
-// CHECK-NEXT:  | `-ReturnStmt {{.+}} 
-// CHECK-NEXT:  |   `-ImplicitCastExpr {{.+}}  'int' 
-// CHECK-NEXT:  | `-DeclRefExpr {{.+}}  'int' lvalue Var {{.+}} 
'f' 'int'
-// CHECK-NEXT:  `-OMPDeclareTargetDeclAttr {{.+}}  Implicit MT_To 
DT_Any 1
+// CHECK:  |-FunctionDecl {{.+}}  
line:[[@LINE-6]]:5 bar 'int ()'
+// CHECK-NEXT: | |-CompoundStmt {{.+}} 
+// CHECK-NEXT: | | |-DeclStmt {{.+}} 
+// CHECK-NEXT: | | | `-VarDecl {{.+}}  col:7 used f 'int'
+// CHECK-NEXT: | | `-ReturnStmt {{.+}} 
+// CHECK-NEXT: | |   `-ImplicitCastExpr {{.+}}  'int' 
+// CHECK-NEXT: | | `-DeclRefExpr {{.+}}  'int' lvalue Var {{.+}} 
'f' 'int'
+// CHECK-NEXT: | `-OMPDeclareTargetDeclAttr {{.+}}  
Implicit MT_To DT_Any 1
+
+int dx;
+
+extern int dx;
+#pragma omp declare target to(dx)
+
+// CHECK:  |-VarDecl {{.+}}  col:5 dx 'int'
+// CHECK-NEXT: | `-OMPDeclareTargetDeclAttr {{.+}}  
Implicit MT_To DT_Any 4294967295
+// CHECK:  |-VarDecl {{.+}} prev {{.+}}  
col:12 dx 'int' extern
+// CHECK-NEXT: | `-OMPDeclareTargetDeclAttr {{.+}}  
Implicit MT_To DT_Any 4294967295
+
+int dy;
+
+#pragma omp begin declare target
+extern int dy;
+#pragma omp end declare target
+
+// CHECK:  |-VarDecl {{.+}}  col:5 dy 'int'
+// CHECK-NEXT: | `-OMPDeclareTargetDeclAttr {{.+}}  
Implicit MT_To DT_Any 1
+// CHECK:  `-VarDecl {{.+}} prev {{.+}}  
col:12 dy 'int' extern
+// CHECK-NEXT:   `-OMPDeclareTargetDeclAttr {{.+}}  
Implicit MT_To DT_Any 1
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -22986,6 +22986,9 @@
   Context, MT, DTCI.DT, IndirectE, IsIndirect, Level,
   SourceRange(Loc, Loc));
   ND->addAttr(A);
+  if (auto *CD = dyn_cast(ND->getCanonicalDecl()))
+if (!CD->hasAttr())
+  CD->addAttr(A);
   if (ASTMutationListener *ML = Context.getASTMutationListener())
 ML->DeclarationMarkedOpenMPDeclareTarget(ND, A);
   checkDeclIsAllowedInOpenMPTarget(nullptr, ND, Loc);
@@ -23090,6 +23093,9 @@
 DTCI.DT, IndirectE, IsIndirect, Level,
 SourceRange(DTCI.Loc, DTCI.Loc));
 D->addAttr(A);
+if (auto *CD = dyn_cast(D->getCanonicalDecl()))
+  if (!CD->hasAttr())
+CD->addAttr(A);
 if (ASTMutationListener *ML = Context.getASTMutationListener())
   ML->DeclarationMarkedOpenMPDeclareTarget(D, A);
   }


Index: clang/test/AST/dump.cpp
===
--- clang/test/AST/dump.cpp
+++ clang/test/AST/dump.cpp
@@ -79,11 +79,32 @@
 }
 #pragma omp end declare target
 
-// CHECK:   `-FunctionDecl {{.+}}  line:[[@LINE-6]]:5 bar 'int ()'
-// CHECK-NEXT:  |-CompoundStmt {{.+}} 
-// CHECK-NEXT:  | |-DeclStmt {{.+}} 
-// CHECK-NEXT:  | | `-VarDecl {{.+}}  col:7 used f 'int'
-// CHECK-NEXT:  | `-ReturnStmt {{.+}} 
-// CHECK-NEXT:  |   `-ImplicitCastExpr {{.+}}  'int' 
-// CHECK-NEXT:  | `-DeclRefExpr {{.+}}  'int' lvalue Var {{.+}} 'f' 'int'
-// CHECK-NEXT:  `-OMPDeclareTargetDeclAttr {{.+}}  Implicit MT_To DT_Any 1
+// CHECK:  |-FunctionDecl {{.+}}  

[PATCH] D142994: [UsersManual] Add llvm-progen as an alternative tool for AutoFDO profile generation.

2023-06-20 Thread David Li via Phabricator via cfe-commits
davidxl accepted this revision.
davidxl 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/D142994/new/

https://reviews.llvm.org/D142994

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


[PATCH] D153205: [clang-format] Add new block type ListInit

2023-06-20 Thread Gedare Bloom via Phabricator via cfe-commits
gedare updated this revision to Diff 532967.
gedare added a comment.

Do not use temporary variable for getBlockKind().
Fix test case syntax errors.
Fix formatting.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153205

Files:
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/FormatToken.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -4929,7 +4929,7 @@
"  \"\"};\n",
Style);
   // Designated initializers.
-  verifyFormat("int LongVariable[1] = {\n"
+  verifyFormat("int LongVariable[2] = {\n"
"  [0] = 1000, [1] = 2000};",
Style);
   verifyFormat("SomeStruct s{\n"
@@ -5039,7 +5039,7 @@
"bar,\n"
"  },\n"
"  SomeArrayT{},\n"
-   "}\n",
+   "};\n",
Style);
   verifyFormat("SomeArrayT a[3] = {\n"
"  {foo},\n"
@@ -5056,7 +5056,7 @@
"},\n"
"  },\n"
"  {baz},\n"
-   "}\n",
+   "};\n",
Style);
 
   // Aligning after open braces unaffected by BracedInitializerIndentWidth.
@@ -25494,6 +25494,155 @@
Style);
 }
 
+TEST_F(FormatTest, AlignAfterOpenBracketBlockIndentInitializers) {
+  auto Style = getLLVMStyleWithColumns(60);
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
+  // Aggregate initialization.
+  verifyFormat("int LongVariable[2] = {\n"
+   "1000, 2000\n"
+   "};",
+   Style);
+  verifyFormat("SomeStruct s{\n"
+   "\"\", \"\",\n"
+   "\"\"\n"
+   "};",
+   Style);
+  // Designated initializers.
+  verifyFormat("int LongVariable[2] = {\n"
+   "[0] = 1000, [1] = 2000\n"
+   "};",
+   Style);
+  verifyFormat("SomeStruct s{\n"
+   ".foo = \"x\",\n"
+   ".bar = \"y\",\n"
+   ".baz = \"z\"\n"
+   "};\n",
+   Style);
+  // List initialization.
+  verifyFormat("SomeStruct s{\n"
+   "\"x\",\n"
+   "\"y\",\n"
+   "\"z\",\n"
+   "};\n",
+   Style);
+  verifyFormat("SomeStruct{\n"
+   "\"x\",\n"
+   "\"y\",\n"
+   "\"z\",\n"
+   "};\n",
+   Style);
+  verifyFormat("new SomeStruct{\n"
+   "\"x\",\n"
+   "\"y\",\n"
+   "\"z\",\n"
+   "};\n",
+   Style);
+  // Member initializer.
+  verifyFormat("class SomeClass {\n"
+   "  SomeStruct s{\n"
+   "  \"x\",\n"
+   "  \"y\",\n"
+   "  \"z\",\n"
+   "  };\n"
+   "};\n",
+   Style);
+  // Constructor member initializer.
+  verifyFormat("SomeClass::SomeClass : strct{\n"
+   "   \"x\",\n"
+   "   \"y\",\n"
+   "   \"z\",\n"
+   "   } {}\n",
+   Style);
+  // Copy initialization.
+  verifyFormat("SomeStruct s = SomeStruct{\n"
+   "\"x\",\n"
+   "\"y\",\n"
+   "\"z\",\n"
+   "};\n",
+   Style);
+  // Copy list initialization.
+  verifyFormat("SomeStruct s = {\n"
+   "\"x\",\n"
+   "\"y\",\n"
+   "\"z\",\n"
+   "};\n",
+   Style);
+  // Assignment operand initialization.
+  verifyFormat("s = {\n"
+   "\"x\",\n"
+   "\"y\",\n"
+   "\"z\",\n"
+   "};\n",
+   Style);
+  // Returned object initialization.
+  verifyFormat("return {\n"
+   "\"x\",\n"
+   "\"y\",\n"
+   "\"z\",\n"
+   "};\n",
+ 

[PATCH] D153205: [clang-format] Add new block type ListInit

2023-06-20 Thread Gedare Bloom via Phabricator via cfe-commits
gedare added a comment.

In D153205#4431235 , 
@HazardyKnusperkeks wrote:

> You add a lot of checks and I honestly can't say if it does not affect other 
> code that is not covered by the tests.

Not much I can do about that. I guess it is worth noting that all the checks I 
add are predicated on either BK_ListInit or BK_BracedInit.  I have reduced the 
checks to what minimally works to address the Issue.  Technically, this has two 
distinct changes included:

- Allow BlockIndent to work with Braces.
- Allow BlockIndent to work with array/struct initializers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153205

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


[PATCH] D152900: [clangd] Update symbol collector to use include-cleaner.

2023-06-20 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo added a comment.

Thanks for the comments!




Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:393-395
+const auto *FileEntry = SM.getFileEntryForID(FID);
+for (const auto *Export : PI.getExporters(FileEntry, SM.getFileManager()))
+  return toURI(Export->tryGetRealPathName());

kadircet wrote:
> sorry i don't understand what this logic is trying to achieve.
> 
> we seem to be prefering "first" exporting header, over the headers that 
> directly provide the symbol. Also comment says it's done for objc, but 
> there's nothing limiting this logic to ObjC. any chance this is unintended?
No, this was intended, but possibly I didn't get it right.

>  comment says it's done for objc, but there's nothing limiting this logic to 
> objc

AFAIU this whole code path will now only be reachable for objc symbols.  I have 
removed pragma includes from the canonical include mapping now, leaving the 
pragma handling to include cleaner. However, that only triggers for C/C++, so 
in case we need the `export` and `private` pragmas for objc, we need to 
re-insert the handling for them somewhere. 
There is no pre-existing test case for pragmas in objc and there is no usage of 
these pragmas for objc code in the code base either,  so I have no way of 
knowing if this is actually needed. But I believe you've mentioned in some 
discussion we should still handle the pragmas for objc.

> we seem to be preferring "first" exporting header, over the headers that 
> directly provide the symbol.

Isn't that correct if there's an `IWYU export` pragma involved? The snippet 
comes from `include_cleaner::findHeaders`, with the only difference that it 
stops at the first exporter (since the canonical include mapping also just 
stored one mapping for the header).

Let me know how to do it better, or maybe if this is necessary at all. 
Honestly, I am not sure about this, since, as mentioned, there are no `export` 
or `private/public` pragmas in objc files in the codebase atm.




Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:903
+NewSym = *S;
+if (!IncludeHeader.empty()) {
   NewSym.IncludeHeaders.push_back({IncludeHeader, 1, Directives});

kadircet wrote:
> this is using legacy mappings for non-objc symbols too
Removed this whole passage.



Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:934-936
+  SymbolIncludeSpelling[SID] = HeaderFileURIs->getIncludeHeader(
+  ASTCtx->getSourceManager().getOrCreateFileID(
+  H.physical(), SrcMgr::CharacteristicKind::C_User));

kadircet wrote:
> we actually only want to use `HeaderFileURIs->toURI` here and not the 
> `getIncludeHeader`, because:
> - We want to make use of mapping logic in include-cleaner solely, and we 
> already have all that information in Providers mapping.
> - The extra logic we want to apply for ObjC symbols are already applied 
> before reaching here.
> 
> the way we create a FileID here is a little bit iffy, by using `toURI`, 
> hopefully we can avoid that conversion.
> 
> the only remaining issue is, we actually still want to use system header 
> mappings inside `CanonicalIncludes` until we have better support for them in 
> include-cleaner library itself. So I think we should still call 
> `Includes->mapHeader(H.physical())` before using `toURI`.
Ok SGTM. It seems, though, that we still need the "iffy" FID for the canonical 
mapping.. Let me know if you know a better way. 





Comment at: clang-tools-extra/clangd/index/SymbolCollector.h:131
+  }
+  void setPreprocessor(Preprocessor ) {
+this->PP = 

kadircet wrote:
> unfortunately this alternative is called after we've parsed the file, from 
> `clangd/index/FileIndex.cpp`, `indexSymbols`. hence attaching `PI` to 
> `PPCallbacks` won't have any effect.
> 
> This is working unintentionally because we're still populating 
> `CanonicalIncludes` with legacy IWYUPragmaHandler in clangd, and using that 
> to perform private -> public mappings.
> 
> We should instead propagate the `PragmaIncludes` we have in `ParsedAST` and 
> in preamble builds here. You should be able to test the new behaviour 
> `clang-tools-extra/clangd/unittests/FileIndexTests.cpp` to make sure pragma 
> handling through dynamic indexing code paths keep working as expected using 
> an `export` pragma.
Ok thank you. I'm using `PragmaIncludes` from AST and preamble builds for the 
dynamic index now.

For the background index, I've finally managed to move pragma recording to the 
`IndexAction` now.

I've also removed the redundant (to include cleaner) comment handlers from the 
AST build and preamble building logic. 

Also removed the `mapSymbol` method from `CanonicalIncludes`, since it had one 
usage which should now be covered by the include cleaner, I believe. 


Repository:
  rG LLVM Github Monorepo

[PATCH] D152900: [clangd] Update symbol collector to use include-cleaner.

2023-06-20 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo updated this revision to Diff 532964.
VitaNuo marked 8 inline comments as done.
VitaNuo added a comment.
Herald added a subscriber: javed.absar.

Address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152900

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/Preamble.h
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/index/CanonicalIncludes.cpp
  clang-tools-extra/clangd/index/CanonicalIncludes.h
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/FileIndex.h
  clang-tools-extra/clangd/index/IndexAction.cpp
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/index/SymbolCollector.h
  clang-tools-extra/clangd/tool/Check.cpp
  clang-tools-extra/clangd/unittests/CanonicalIncludesTests.cpp
  clang-tools-extra/clangd/unittests/FileIndexTests.cpp
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
  clang-tools-extra/clangd/unittests/TestTU.cpp
  clang-tools-extra/clangd/unittests/TestWorkspace.cpp

Index: clang-tools-extra/clangd/unittests/TestWorkspace.cpp
===
--- clang-tools-extra/clangd/unittests/TestWorkspace.cpp
+++ clang-tools-extra/clangd/unittests/TestWorkspace.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "TestWorkspace.h"
+#include "clang-include-cleaner/Record.h"
 #include "index/FileIndex.h"
 #include "gtest/gtest.h"
 #include 
@@ -22,9 +23,10 @@
 TU.Code = Input.second.Code;
 TU.Filename = Input.first().str();
 TU.preamble([&](ASTContext , Preprocessor ,
-const CanonicalIncludes ) {
+const CanonicalIncludes ,
+const include_cleaner::PragmaIncludes *PI) {
   Index->updatePreamble(testPath(Input.first()), "null", Ctx, PP,
-CanonIncludes);
+CanonIncludes, PI);
 });
 ParsedAST MainAST = TU.build();
 Index->updateMain(testPath(Input.first()), MainAST);
Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -164,9 +164,9 @@
 
 SymbolSlab TestTU::headerSymbols() const {
   auto AST = build();
-  return std::get<0>(indexHeaderSymbols(/*Version=*/"null", AST.getASTContext(),
-AST.getPreprocessor(),
-AST.getCanonicalIncludes()));
+  return std::get<0>(indexHeaderSymbols(
+  /*Version=*/"null", AST.getASTContext(), AST.getPreprocessor(),
+  AST.getCanonicalIncludes(), AST.getPragmaIncludes()));
 }
 
 RefSlab TestTU::headerRefs() const {
@@ -179,7 +179,7 @@
   auto Idx = std::make_unique();
   Idx->updatePreamble(testPath(Filename), /*Version=*/"null",
   AST.getASTContext(), AST.getPreprocessor(),
-  AST.getCanonicalIncludes());
+  AST.getCanonicalIncludes(), AST.getPragmaIncludes());
   Idx->updateMain(testPath(Filename), AST);
   return std::move(Idx);
 }
Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -18,6 +18,7 @@
 #include "TUScheduler.h"
 #include "TestFS.h"
 #include "TestIndex.h"
+#include "clang-include-cleaner/Record.h"
 #include "support/Cancellation.h"
 #include "support/Context.h"
 #include "support/Path.h"
@@ -1131,7 +1132,8 @@
 : BlockVersion(BlockVersion), N(N) {}
 void onPreambleAST(PathRef Path, llvm::StringRef Version,
const CompilerInvocation &, ASTContext ,
-   Preprocessor &, const CanonicalIncludes &) override {
+   Preprocessor &, const CanonicalIncludes &,
+   const include_cleaner::PragmaIncludes *) override {
   if (Version == BlockVersion)
 N.wait();
 }
@@ -1210,7 +1212,8 @@
 
 void onPreambleAST(PathRef Path, llvm::StringRef Version,
const CompilerInvocation &, ASTContext ,
-   Preprocessor &, const CanonicalIncludes &) override {
+   Preprocessor &, const CanonicalIncludes &,
+   const include_cleaner::PragmaIncludes *) override {
   if (BuildBefore)
 ASSERT_TRUE(UnblockPreamble.wait(timeoutSeconds(5)))
 << "Expected notification";
@@ -1564,7 +1567,8 @@
 : 

[PATCH] D153294: [clang] Do not create ExprWithCleanups while checking immediate invocation

2023-06-20 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

As mentioned in the GH issue, I think this change looks fine.
But I would suggest waiting for feedback from @rsmith to ensure there isn't a 
reason for cleanups being removed that we are missing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153294

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


[PATCH] D153366: [dataflow] Add dedicated representation of boolean formulas

2023-06-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
Herald added subscribers: martong, mgrang, xazax.hun.
Herald added a reviewer: NoQ.
Herald added a project: All.
sammccall requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is the first step in untangling the two current jobs of BoolValue:

- BoolValue will model C++ booleans e.g. held in StorageLocations. this 
includes describing uncertainty (e.g. "top" is a Value concern)
- Formula describes analysis-level assertions in terms of SAT atoms.

These can still be linked together: a BoolValue may have a corresponding
SAT atom which is constrained by formulas.

For now, BoolValue is left intact, Formula is just the input type to the
SAT solver, and we build formulas as needed to invoke the solver.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153366

Files:
  clang/include/clang/Analysis/FlowSensitive/Arena.h
  clang/include/clang/Analysis/FlowSensitive/DebugSupport.h
  clang/include/clang/Analysis/FlowSensitive/Formula.h
  clang/include/clang/Analysis/FlowSensitive/Solver.h
  clang/include/clang/Analysis/FlowSensitive/WatchedLiteralsSolver.h
  clang/lib/Analysis/FlowSensitive/Arena.cpp
  clang/lib/Analysis/FlowSensitive/CMakeLists.txt
  clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
  clang/lib/Analysis/FlowSensitive/DebugSupport.cpp
  clang/lib/Analysis/FlowSensitive/Formula.cpp
  clang/lib/Analysis/FlowSensitive/WatchedLiteralsSolver.cpp
  clang/unittests/Analysis/FlowSensitive/DebugSupportTest.cpp
  clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h

Index: clang/unittests/Analysis/FlowSensitive/TestingSupport.h
===
--- clang/unittests/Analysis/FlowSensitive/TestingSupport.h
+++ clang/unittests/Analysis/FlowSensitive/TestingSupport.h
@@ -42,6 +42,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Allocator.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Testing/Annotations/Annotations.h"
@@ -404,55 +405,51 @@
 
 /// Creates and owns constraints which are boolean values.
 class ConstraintContext {
-public:
-  // Creates an atomic boolean value.
-  BoolValue *atom() {
-Vals.push_back(std::make_unique());
-return Vals.back().get();
+  unsigned NextAtom;
+  llvm::BumpPtrAllocator A;
+
+  const Formula *make(Formula::Kind K, llvm::ArrayRef Operands) {
+return ::create(A, K, Operands);
   }
 
+public:
+#if 0 // XXX
   // Creates an instance of the Top boolean value.
   BoolValue *top() {
 Vals.push_back(std::make_unique());
 return Vals.back().get();
   }
+#endif
+
+  // Creates a reference to a fresh atomic variable.
+  const Formula *atom() {
+return ::create(A, Formula::AtomRef, {}, ++NextAtom);
+  }
 
   // Creates a boolean conjunction value.
-  BoolValue *conj(BoolValue *LeftSubVal, BoolValue *RightSubVal) {
-Vals.push_back(
-std::make_unique(*LeftSubVal, *RightSubVal));
-return Vals.back().get();
+  const Formula *conj(const Formula *LeftSubVal, const Formula *RightSubVal) {
+return make(Formula::And, {LeftSubVal, RightSubVal});
   }
 
   // Creates a boolean disjunction value.
-  BoolValue *disj(BoolValue *LeftSubVal, BoolValue *RightSubVal) {
-Vals.push_back(
-std::make_unique(*LeftSubVal, *RightSubVal));
-return Vals.back().get();
+  const Formula*disj(const Formula*LeftSubVal, const Formula*RightSubVal) {
+return make(Formula::Or, {LeftSubVal, RightSubVal});
   }
 
   // Creates a boolean negation value.
-  BoolValue *neg(BoolValue *SubVal) {
-Vals.push_back(std::make_unique(*SubVal));
-return Vals.back().get();
+  const Formula *neg(const Formula *SubVal) {
+return make(Formula::Not, {SubVal});
   }
 
   // Creates a boolean implication value.
-  BoolValue *impl(BoolValue *LeftSubVal, BoolValue *RightSubVal) {
-Vals.push_back(
-std::make_unique(*LeftSubVal, *RightSubVal));
-return Vals.back().get();
+  const Formula *impl(const Formula *LeftSubVal, const Formula *RightSubVal) {
+return make(Formula::Implies, {LeftSubVal, RightSubVal});
   }
 
   // Creates a boolean biconditional value.
-  BoolValue *iff(BoolValue *LeftSubVal, BoolValue *RightSubVal) {
-Vals.push_back(
-std::make_unique(*LeftSubVal, *RightSubVal));
-return Vals.back().get();
+  const Formula *iff(const Formula *LeftSubVal, const Formula *RightSubVal) {
+return make(Formula::Equal, {LeftSubVal, RightSubVal});
   }
-
-private:
-  std::vector> Vals;
 };
 
 } // namespace test
Index: clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
@@ -30,19 +30,23 @@
 
 // Checks if the 

[PATCH] D153235: [RISCV] Change the type of argument to clz and ctz from ZiZi/WiWi to iUZi/iUWi

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

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153235

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


[PATCH] D153236: [NFC] Fix potential dereferencing of nullptr.

2023-06-20 Thread Sindhu Chittireddy via Phabricator via cfe-commits
schittir added inline comments.



Comment at: clang/lib/Parse/ParseStmt.cpp:887
+  else {
+assert(DeepestParsedCaseStmt && "DeepestParsedCaseStmt cannot be 
null");
 Actions.ActOnCaseStmtBody(DeepestParsedCaseStmt, Case.get());

Fznamznon wrote:
> The assert that looks like `assert(x && "x should not be null")` seems 
> strange. Failed `assert(x)` implies that `x` should not be null. If there is 
> a message, a message saying what is wrong and why is much more useful.
Would you suggest removing the message and changing it to 
```
assert(DeepestParsedCaseStmt);
``` 


I am not sure what message would be useful here. 



Comment at: clang/lib/Sema/SemaExprObjC.cpp:2441
 
+  assert(receiverTypeInfo && "receiverTypeInfo cannot be null");
   return BuildClassMessage(receiverTypeInfo, ReceiverType,

Fznamznon wrote:
> That seems to be a strange place before and after changes. With or without 
> change, when `ReceiverType.isNull()` is true we just end up passing `nullptr` 
>  as `receiverTypeInfo ` to the `BuildClassMessage` which doesn't seem to be 
> checking its non-nullness before dereferencing it, even though its 
> description says that `receiverTypeInfo` can be null. 
> I guess it is fine to pass `nullptr` to a function whose description says so, 
> but the non-nullness check inside of it should be probably a bit more obvious 
> than it is right now.
I see your point about passing `ReceiverTypeInfo` as nullptr to 
`BuildClassMessage` method - it seems ok to do that. 
Would it make sense to add an `assert(ReceiverTypeInfo);` inside the method as 
way of making the non-nullness check more obvious? 


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

https://reviews.llvm.org/D153236

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


[PATCH] D151963: [clang][NFC] Remove trailing whitespaces and enforce it in lib, include and docs

2023-06-20 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth accepted this revision.
paulkirth added a comment.
Herald added a subscriber: wangpc.

Also LGTM for the changes in MisExpect.rst, modulo feedback from @erichkeane.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151963

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


[PATCH] D92797: APINotes: add initial stub of APINotesWriter

2023-06-20 Thread Egor Zhdan via Phabricator via cfe-commits
egorzhdan added a comment.

@compnerd @martong would you be OK with merging this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92797

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


[PATCH] D153362: [clang][DebugInfo] Emit DW_AT_defaulted for defaulted C++ member functions

2023-06-20 Thread Michael Buch via Phabricator via cfe-commits
Michael137 updated this revision to Diff 532957.
Michael137 added a comment.

- clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153362

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-defaulted.cpp


Index: clang/test/CodeGenCXX/debug-info-defaulted.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/debug-info-defaulted.cpp
@@ -0,0 +1,38 @@
+// Test for debug info for C++ defaulted member functions
+
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-linux-gnu %s -o - \
+// RUN:   -O0 -debug-info-kind=standalone -std=c++20 | FileCheck %s
+
+// CHECK: DISubprogram(name: "defaulted", {{.*}}, flags: DIFlagPrototyped, 
spFlags: DISPFlagDefaultedInClass)
+// CHECK: DISubprogram(name: "~defaulted", {{.*}}, flags: 
DIFlagPrototyped, spFlags: DISPFlagDefaultedOutOfClass)
+// CHECK: DISubprogram(name: "operator=", {{.*}}, flags: DIFlagPrototyped, 
spFlags: 0)
+// CHECK: DISubprogram(name: "operator=", {{.*}}, flags: DIFlagPrototyped, 
spFlags: 0)
+// CHECK: DISubprogram(name: "operator==", {{.*}}, flags: 
DIFlagPrototyped, spFlags: DISPFlagDefaultedInClass)
+// CHECK-NOT: DISubprogram(name: "implicit_defaulted"
+struct defaulted {
+  // inline defaulted
+  defaulted() = default;
+
+  // out-of-line defaulted (inline keyword
+  // shouldn't change that)
+  inline ~defaulted();
+
+  // These shouldn't produce a defaulted-ness DI flag
+  // (though technically they are DW_DEFAULTED_no)
+  defaulted& operator=(defaulted const&) { return *this; }
+  defaulted& operator=(defaulted &&);
+
+  bool operator==(defaulted const&) const = default;
+};
+
+defaulted::~defaulted() = default;
+defaulted& defaulted::operator=(defaulted &&) { return *this; }
+
+// All ctors/dtors are implicitly defatuled.
+// So no DW_AT_defaulted expected for these.
+struct implicit_defaulted {};
+
+void foo() {
+  defaulted d;
+  implicit_defaulted i;
+}
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1948,6 +1948,14 @@
   if (Method->getCanonicalDecl()->isDeleted())
 SPFlags |= llvm::DISubprogram::SPFlagDeleted;
 
+  // The defaulted-ness of an out-of-class method is a property of its
+  // definition. Hence, query the definition instead.
+  if (auto const *Def = Method->getDefinition())
+if (Def->isExplicitlyDefaulted())
+  SPFlags |= (Def->isOutOfLine())
+ ? llvm::DISubprogram::SPFlagDefaultedOutOfClass
+ : llvm::DISubprogram::SPFlagDefaultedInClass;
+
   if (Method->isNoReturn())
 Flags |= llvm::DINode::FlagNoReturn;
 


Index: clang/test/CodeGenCXX/debug-info-defaulted.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/debug-info-defaulted.cpp
@@ -0,0 +1,38 @@
+// Test for debug info for C++ defaulted member functions
+
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-linux-gnu %s -o - \
+// RUN:   -O0 -debug-info-kind=standalone -std=c++20 | FileCheck %s
+
+// CHECK: DISubprogram(name: "defaulted", {{.*}}, flags: DIFlagPrototyped, spFlags: DISPFlagDefaultedInClass)
+// CHECK: DISubprogram(name: "~defaulted", {{.*}}, flags: DIFlagPrototyped, spFlags: DISPFlagDefaultedOutOfClass)
+// CHECK: DISubprogram(name: "operator=", {{.*}}, flags: DIFlagPrototyped, spFlags: 0)
+// CHECK: DISubprogram(name: "operator=", {{.*}}, flags: DIFlagPrototyped, spFlags: 0)
+// CHECK: DISubprogram(name: "operator==", {{.*}}, flags: DIFlagPrototyped, spFlags: DISPFlagDefaultedInClass)
+// CHECK-NOT: DISubprogram(name: "implicit_defaulted"
+struct defaulted {
+  // inline defaulted
+  defaulted() = default;
+
+  // out-of-line defaulted (inline keyword
+  // shouldn't change that)
+  inline ~defaulted();
+
+  // These shouldn't produce a defaulted-ness DI flag
+  // (though technically they are DW_DEFAULTED_no)
+  defaulted& operator=(defaulted const&) { return *this; }
+  defaulted& operator=(defaulted &&);
+
+  bool operator==(defaulted const&) const = default;
+};
+
+defaulted::~defaulted() = default;
+defaulted& defaulted::operator=(defaulted &&) { return *this; }
+
+// All ctors/dtors are implicitly defatuled.
+// So no DW_AT_defaulted expected for these.
+struct implicit_defaulted {};
+
+void foo() {
+  defaulted d;
+  implicit_defaulted i;
+}
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1948,6 +1948,14 @@
   if (Method->getCanonicalDecl()->isDeleted())
 SPFlags |= llvm::DISubprogram::SPFlagDeleted;
 
+  // The defaulted-ness of an out-of-class method is a property of its
+  // definition. Hence, query the definition instead.
+  if (auto const 

[PATCH] D153363: [clang][analyzer] No end-of-file when seek to file begin.

2023-06-20 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.

If `fseek` is used with 0 position and SEEK_SET it sets the position
to the start of the file. This should not cause FEOF (end of file) error.
The case of an empty file is not handled for simplification.
It is not exactly defined in what cases `fseek` produces the different
error states. Normally feof should not happen at all because it is
possible to set the position after the end of file, but previous tests
showed that still feof (and any other error cases) can happen.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153363

Files:
  clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
  clang/test/Analysis/stream-error.c

Index: clang/test/Analysis/stream-error.c
===
--- clang/test/Analysis/stream-error.c
+++ clang/test/Analysis/stream-error.c
@@ -146,7 +146,7 @@
   FILE *F = fopen("file", "r");
   if (!F)
 return;
-  int rc = fseek(F, 0, SEEK_SET);
+  int rc = fseek(F, 1, SEEK_SET);
   if (rc) {
 int IsFEof = feof(F), IsFError = ferror(F);
 // Get feof or ferror or no error.
@@ -173,6 +173,35 @@
   fclose(F);
 }
 
+void error_fseek_0(void) {
+  FILE *F = fopen("file", "r");
+  if (!F)
+return;
+  int rc = fseek(F, 0, SEEK_SET);
+  if (rc) {
+int IsFEof = feof(F), IsFError = ferror(F);
+// Get ferror or no error, but not feof.
+clang_analyzer_eval(IsFError);
+// expected-warning@-1 {{FALSE}}
+// expected-warning@-2 {{TRUE}}
+clang_analyzer_eval(IsFEof);
+// expected-warning@-1 {{FALSE}}
+// Error flags should not change.
+clang_analyzer_eval(feof(F)); // expected-warning {{FALSE}}
+if (IsFError)
+  clang_analyzer_eval(ferror(F)); // expected-warning {{TRUE}}
+else
+  clang_analyzer_eval(ferror(F)); // expected-warning {{FALSE}}
+  } else {
+clang_analyzer_eval(feof(F));   // expected-warning {{FALSE}}
+clang_analyzer_eval(ferror(F)); // expected-warning {{FALSE}}
+// Error flags should not change.
+clang_analyzer_eval(feof(F));   // expected-warning {{FALSE}}
+clang_analyzer_eval(ferror(F)); // expected-warning {{FALSE}}
+  }
+  fclose(F);
+}
+
 void error_indeterminate(void) {
   FILE *F = fopen("file", "r+");
   if (!F)
Index: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -285,7 +285,14 @@
 0}},
   };
 
+  /// Expanded value of EOF, empty before initialization.
   mutable std::optional EofVal;
+  /// Expanded value of SEEK_SET, 0 if not found.
+  mutable int SeekSetVal = 0;
+  /// Expanded value of SEEK_CUR, 1 if not found.
+  mutable int SeekCurVal = 1;
+  /// Expanded value of SEEK_END, 2 if not found.
+  mutable int SeekEndVal = 2;
 
   void evalFopen(const FnDescription *Desc, const CallEvent ,
  CheckerContext ) const;
@@ -432,7 +439,7 @@
 });
   }
 
-  void initEof(CheckerContext ) const {
+  void initMacroValues(CheckerContext ) const {
 if (EofVal)
   return;
 
@@ -441,6 +448,15 @@
   EofVal = *OptInt;
 else
   EofVal = -1;
+if (const std::optional OptInt =
+tryExpandAsInteger("SEEK_SET", C.getPreprocessor()))
+  SeekSetVal = *OptInt;
+if (const std::optional OptInt =
+tryExpandAsInteger("SEEK_END", C.getPreprocessor()))
+  SeekEndVal = *OptInt;
+if (const std::optional OptInt =
+tryExpandAsInteger("SEEK_CUR", C.getPreprocessor()))
+  SeekCurVal = *OptInt;
   }
 
   /// Searches for the ExplodedNode where the file descriptor was acquired for
@@ -488,7 +504,7 @@
 
 void StreamChecker::checkPreCall(const CallEvent ,
  CheckerContext ) const {
-  initEof(C);
+  initMacroValues(C);
 
   const FnDescription *Desc = lookupFn(Call);
   if (!Desc || !Desc->PreFn)
@@ -786,6 +802,11 @@
   if (!State->get(StreamSym))
 return;
 
+  const llvm::APSInt *PosV =
+  C.getSValBuilder().getKnownValue(State, Call.getArgSVal(1));
+  const llvm::APSInt *WhenceV =
+  C.getSValBuilder().getKnownValue(State, Call.getArgSVal(2));
+
   DefinedSVal RetVal = makeRetVal(C, CE);
 
   // Make expression result.
@@ -804,9 +825,12 @@
   // It is possible that fseek fails but sets none of the error flags.
   // If fseek failed, assume that the file position becomes indeterminate in any
   // case.
+  StreamErrorState NewErrS = ErrorNone | ErrorFError;
+  // Setting the position to start of file never produces EOF 

[PATCH] D153205: [clang-format] Add new block type ListInit

2023-06-20 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

In principle I like this as its annoyed me for years


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153205

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


[PATCH] D153205: [clang-format] Add new block type ListInit

2023-06-20 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:25511
+  // Designated initializers.
+  verifyFormat("int LongVariable[1] = {\n"
+   "[0] = 1000, [1] = 2000\n"

nit [2]


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153205

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


[PATCH] D153205: [clang-format] Add new block type ListInit

2023-06-20 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/lib/Format/FormatToken.cpp:79
 bool FormatToken::opensBlockOrBlockTypeList(const FormatStyle ) const {
+  auto bk = getBlockKind();
   // C# Does not indent object initialisers as continuations.

HazardyKnusperkeks wrote:
> 
why pull this out? if you are worried about speed now you do it EVERY time 
whereas before we wouldn't do it unless limited conditions, for me I'd get rid 
of bk and just use getBlockKind() directly everytime, the compiler should I 
hope optimise it away



Comment at: clang/unittests/Format/FormatTest.cpp:25625
+   "SomeArrayT{},\n"
+   "}\n",
+   Style);

should there be a semi colon here?



Comment at: clang/unittests/Format/FormatTest.cpp:25642
+   "{baz},\n"
+   "}\n",
+   Style);

should there be a semi colon here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153205

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


[PATCH] D153362: [clang][DebugInfo] Emit DW_AT_defaulted for defaulted C++ member functions

2023-06-20 Thread Michael Buch via Phabricator via cfe-commits
Michael137 updated this revision to Diff 532952.
Michael137 added a comment.
Herald added a subscriber: ormris.

- remove redundant includes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153362

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-defaulted.cpp
  llvm/include/llvm/IR/DebugInfoFlags.def
  llvm/include/llvm/IR/DebugInfoMetadata.h
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  llvm/test/DebugInfo/DW_AT_defaulted.ll

Index: llvm/test/DebugInfo/DW_AT_defaulted.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/DW_AT_defaulted.ll
@@ -0,0 +1,130 @@
+; RUN: llc < %s -filetype=obj -o %t
+; RUN: llvm-dwarfdump -v %t | FileCheck %s
+
+; C++ source to regenerate:
+; struct defaulted {
+;   // inline defaulted
+;   defaulted() = default;
+; 
+;   // out-of-line defaulted (inline keyword
+;   // shouldn't change that)
+;   inline ~defaulted();
+; 
+;   // These shouldn't produce a defaulted-ness DI flag
+;   // (though technically they are DW_DEFAULTED_no)
+;   defaulted& operator=(defaulted const&) { return *this; }
+;   defaulted& operator=(defaulted &&);
+; 
+;   bool operator==(defaulted const&) const = default;
+; };
+; 
+; defaulted::~defaulted() = default;
+; defaulted& defaulted::operator=(defaulted &&) { return *this; }
+; 
+; void foo() {
+;   defaulted d;
+; }
+; $ clang++ -O0 -g -gdwarf-5 debug-info-defaulted.cpp -c
+
+; CHECK: .debug_info contents:
+
+; CHECK:  DW_TAG_structure_type
+; CHECK:DW_AT_name [DW_FORM_strx1]	(indexed ({{.*}}) string = "defaulted")
+
+; CHECK:DW_TAG_subprogram [5]
+; CHECK:  DW_AT_name [DW_FORM_strx1]	(indexed ({{.*}}) string = "defaulted")
+; CHECK:  DW_AT_defaulted [DW_FORM_data1]	(DW_DEFAULTED_in_class)
+; CHECK:  NULL
+
+; CHECK:DW_TAG_subprogram [5]
+; CHECK:  DW_AT_name [DW_FORM_strx1]	(indexed ({{.*}}) string = "~defaulted")
+; CHECK:  DW_AT_defaulted [DW_FORM_data1]	(DW_DEFAULTED_out_of_class)
+; CHECK:  NULL
+
+; CHECK:DW_TAG_subprogram [7]
+; CHECK:  DW_AT_name [DW_FORM_strx1]	(indexed ({{.*}}) string = "operator=")
+; CHECK-NOT:  DW_AT_defaulted
+; CHECK:  NULL
+
+; CHECK:DW_TAG_subprogram [7]
+; CHECK:  DW_AT_name [DW_FORM_strx1]	(indexed ({{.*}}) string = "operator=")
+; CHECK-NOT:  DW_AT_defaulted
+; CHECK:  NULL
+
+; CHECK:DW_TAG_subprogram [9]
+; CHECK:  DW_AT_name [DW_FORM_strx1]	(indexed ({{.*}}) string = "operator==")
+; CHECK:  DW_AT_defaulted [DW_FORM_data1]	(DW_DEFAULTED_in_class)
+; CHECK:  NULL
+
+; CHECK:NULL
+
+%struct.defaulted = type { i8 }
+
+declare void @llvm.dbg.declare(metadata, metadata, metadata)
+
+define void @_Z3foov() !dbg !39 {
+entry:
+  %d = alloca %struct.defaulted, align 1
+  call void @llvm.dbg.declare(metadata ptr %d, metadata !42, metadata !DIExpression()), !dbg !43
+  ret void, !dbg !47
+}
+
+!llvm.dbg.cu = !{!0}
+!llvm.linker.options = !{}
+!llvm.module.flags = !{!2, !3, !4, !5, !6, !7}
+!llvm.ident = !{!8}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 17.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: Apple, sysroot: "/")
+!1 = !DIFile(filename: "../llvm-project/clang/test/CodeGenCXX/debug-info-defaulted.cpp", directory: "/tmp", checksumkind: CSK_MD5, checksum: "ee982c44dd268333101243e050103fb8")
+!2 = !{i32 7, !"Dwarf Version", i32 5}
+!3 = !{i32 2, !"Debug Info Version", i32 3}
+!4 = !{i32 1, !"wchar_size", i32 4}
+!5 = !{i32 8, !"PIC Level", i32 2}
+!6 = !{i32 7, !"uwtable", i32 1}
+!7 = !{i32 7, !"frame-pointer", i32 1}
+!8 = !{!"clang version 17.0.0"}
+!9 = distinct !DISubprogram(name: "operator=", linkageName: "_ZN9defaultedaSEOS_", scope: !10, file: !1, line: 29, type: !24, scopeLine: 29, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, declaration: !23, retainedNodes: !32)
+!10 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "defaulted", file: !1, line: 12, size: 8, flags: DIFlagTypePassByReference | DIFlagNonTrivial, elements: !11, identifier: "_ZTS9defaulted")
+!11 = !{!12, !16, !17, !23, !27}
+!12 = !DISubprogram(name: "defaulted", scope: !10, file: !1, line: 14, type: !13, scopeLine: 14, flags: DIFlagPrototyped, spFlags: DISPFlagDefaultedInClass)
+!13 = !DISubroutineType(types: !14)
+!14 = !{null, !15}
+!15 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
+!16 = !DISubprogram(name: "~defaulted", scope: !10, file: !1, line: 18, type: !13, scopeLine: 18, flags: DIFlagPrototyped, spFlags: DISPFlagDefaultedOutOfClass)
+!17 = !DISubprogram(name: "operator=", linkageName: "_ZN9defaultedaSERKS_", scope: !10, file: !1, line: 22, type: !18, scopeLine: 22, flags: DIFlagPrototyped, spFlags: 0)
+!18 = !DISubroutineType(types: !19)
+!19 = !{!20, !15, !21}
+!20 

[PATCH] D153362: [clang][DebugInfo] Emit DW_AT_defaulted for defaulted C++ member functions

2023-06-20 Thread Michael Buch via Phabricator via cfe-commits
Michael137 created this revision.
Michael137 added reviewers: dblaikie, aprantl.
Herald added a subscriber: hiraditya.
Herald added a project: All.
Michael137 requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

This patch implements the DWARFv5 feature where a
`DW_AT_defaulted` is attached to `DW_TAG_subprogram`s
which are explicitly defaulted in C++, i.e., member
functions such as the following:

  class C {
C() = default;
~C() = default;
  };

We add two new `spFlags`, one for each possible value of
`DW_AT_defaulted` (see table in section 5.7.8 of DWARFv5
specification).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153362

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-defaulted.cpp
  llvm/include/llvm/IR/DebugInfoFlags.def
  llvm/include/llvm/IR/DebugInfoMetadata.h
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  llvm/test/DebugInfo/DW_AT_defaulted.ll

Index: llvm/test/DebugInfo/DW_AT_defaulted.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/DW_AT_defaulted.ll
@@ -0,0 +1,130 @@
+; RUN: llc < %s -filetype=obj -o %t
+; RUN: llvm-dwarfdump -v %t | FileCheck %s
+
+; C++ source to regenerate:
+; struct defaulted {
+;   // inline defaulted
+;   defaulted() = default;
+; 
+;   // out-of-line defaulted (inline keyword
+;   // shouldn't change that)
+;   inline ~defaulted();
+; 
+;   // These shouldn't produce a defaulted-ness DI flag
+;   // (though technically they are DW_DEFAULTED_no)
+;   defaulted& operator=(defaulted const&) { return *this; }
+;   defaulted& operator=(defaulted &&);
+; 
+;   bool operator==(defaulted const&) const = default;
+; };
+; 
+; defaulted::~defaulted() = default;
+; defaulted& defaulted::operator=(defaulted &&) { return *this; }
+; 
+; void foo() {
+;   defaulted d;
+; }
+; $ clang++ -O0 -g -gdwarf-5 debug-info-defaulted.cpp -c
+
+; CHECK: .debug_info contents:
+
+; CHECK:  DW_TAG_structure_type
+; CHECK:DW_AT_name [DW_FORM_strx1]	(indexed ({{.*}}) string = "defaulted")
+
+; CHECK:DW_TAG_subprogram [5]
+; CHECK:  DW_AT_name [DW_FORM_strx1]	(indexed ({{.*}}) string = "defaulted")
+; CHECK:  DW_AT_defaulted [DW_FORM_data1]	(DW_DEFAULTED_in_class)
+; CHECK:  NULL
+
+; CHECK:DW_TAG_subprogram [5]
+; CHECK:  DW_AT_name [DW_FORM_strx1]	(indexed ({{.*}}) string = "~defaulted")
+; CHECK:  DW_AT_defaulted [DW_FORM_data1]	(DW_DEFAULTED_out_of_class)
+; CHECK:  NULL
+
+; CHECK:DW_TAG_subprogram [7]
+; CHECK:  DW_AT_name [DW_FORM_strx1]	(indexed ({{.*}}) string = "operator=")
+; CHECK-NOT:  DW_AT_defaulted
+; CHECK:  NULL
+
+; CHECK:DW_TAG_subprogram [7]
+; CHECK:  DW_AT_name [DW_FORM_strx1]	(indexed ({{.*}}) string = "operator=")
+; CHECK-NOT:  DW_AT_defaulted
+; CHECK:  NULL
+
+; CHECK:DW_TAG_subprogram [9]
+; CHECK:  DW_AT_name [DW_FORM_strx1]	(indexed ({{.*}}) string = "operator==")
+; CHECK:  DW_AT_defaulted [DW_FORM_data1]	(DW_DEFAULTED_in_class)
+; CHECK:  NULL
+
+; CHECK:NULL
+
+%struct.defaulted = type { i8 }
+
+declare void @llvm.dbg.declare(metadata, metadata, metadata)
+
+define void @_Z3foov() !dbg !39 {
+entry:
+  %d = alloca %struct.defaulted, align 1
+  call void @llvm.dbg.declare(metadata ptr %d, metadata !42, metadata !DIExpression()), !dbg !43
+  ret void, !dbg !47
+}
+
+!llvm.dbg.cu = !{!0}
+!llvm.linker.options = !{}
+!llvm.module.flags = !{!2, !3, !4, !5, !6, !7}
+!llvm.ident = !{!8}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 17.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: Apple, sysroot: "/")
+!1 = !DIFile(filename: "../llvm-project/clang/test/CodeGenCXX/debug-info-defaulted.cpp", directory: "/tmp", checksumkind: CSK_MD5, checksum: "ee982c44dd268333101243e050103fb8")
+!2 = !{i32 7, !"Dwarf Version", i32 5}
+!3 = !{i32 2, !"Debug Info Version", i32 3}
+!4 = !{i32 1, !"wchar_size", i32 4}
+!5 = !{i32 8, !"PIC Level", i32 2}
+!6 = !{i32 7, !"uwtable", i32 1}
+!7 = !{i32 7, !"frame-pointer", i32 1}
+!8 = !{!"clang version 17.0.0"}
+!9 = distinct !DISubprogram(name: "operator=", linkageName: "_ZN9defaultedaSEOS_", scope: !10, file: !1, line: 29, type: !24, scopeLine: 29, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, declaration: !23, retainedNodes: !32)
+!10 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "defaulted", file: !1, line: 12, size: 8, flags: DIFlagTypePassByReference | DIFlagNonTrivial, elements: !11, identifier: "_ZTS9defaulted")
+!11 = !{!12, !16, !17, !23, !27}
+!12 = !DISubprogram(name: "defaulted", scope: !10, file: !1, line: 14, type: !13, scopeLine: 14, flags: DIFlagPrototyped, spFlags: DISPFlagDefaultedInClass)
+!13 = !DISubroutineType(types: !14)
+!14 = !{null, !15}
+!15 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, 

[PATCH] D153208: [clang-format] Add InsertNewlineAtEOF to .clang-format files

2023-06-20 Thread Owen Pan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbca11bafba97: [clang-format] Add InsertNewlineAtEOF to 
.clang-format files (authored by owenpan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153208

Files:
  clang/include/clang/Format/.clang-format
  clang/lib/Format/.clang-format
  clang/tools/clang-format/.clang-format
  clang/unittests/Format/.clang-format
  clang/unittests/Format/FormatTestMacroExpansion.cpp


Index: clang/unittests/Format/FormatTestMacroExpansion.cpp
===
--- clang/unittests/Format/FormatTestMacroExpansion.cpp
+++ clang/unittests/Format/FormatTestMacroExpansion.cpp
@@ -259,4 +259,4 @@
 } // namespace
 } // namespace test
 } // namespace format
-} // namespace clang
\ No newline at end of file
+} // namespace clang
Index: clang/unittests/Format/.clang-format
===
--- clang/unittests/Format/.clang-format
+++ clang/unittests/Format/.clang-format
@@ -1,4 +1,5 @@
 BasedOnStyle: LLVM
 InsertBraces: true
+InsertNewlineAtEOF: true
 LineEnding: LF
 RemoveBracesLLVM: true
Index: clang/tools/clang-format/.clang-format
===
--- clang/tools/clang-format/.clang-format
+++ clang/tools/clang-format/.clang-format
@@ -1,4 +1,5 @@
 BasedOnStyle: LLVM
 InsertBraces: true
+InsertNewlineAtEOF: true
 LineEnding: LF
 RemoveBracesLLVM: true
Index: clang/lib/Format/.clang-format
===
--- clang/lib/Format/.clang-format
+++ clang/lib/Format/.clang-format
@@ -1,4 +1,5 @@
 BasedOnStyle: LLVM
 InsertBraces: true
+InsertNewlineAtEOF: true
 LineEnding: LF
 RemoveBracesLLVM: true
Index: clang/include/clang/Format/.clang-format
===
--- clang/include/clang/Format/.clang-format
+++ clang/include/clang/Format/.clang-format
@@ -1,4 +1,5 @@
 BasedOnStyle: LLVM
 InsertBraces: true
+InsertNewlineAtEOF: true
 LineEnding: LF
 RemoveBracesLLVM: true


Index: clang/unittests/Format/FormatTestMacroExpansion.cpp
===
--- clang/unittests/Format/FormatTestMacroExpansion.cpp
+++ clang/unittests/Format/FormatTestMacroExpansion.cpp
@@ -259,4 +259,4 @@
 } // namespace
 } // namespace test
 } // namespace format
-} // namespace clang
\ No newline at end of file
+} // namespace clang
Index: clang/unittests/Format/.clang-format
===
--- clang/unittests/Format/.clang-format
+++ clang/unittests/Format/.clang-format
@@ -1,4 +1,5 @@
 BasedOnStyle: LLVM
 InsertBraces: true
+InsertNewlineAtEOF: true
 LineEnding: LF
 RemoveBracesLLVM: true
Index: clang/tools/clang-format/.clang-format
===
--- clang/tools/clang-format/.clang-format
+++ clang/tools/clang-format/.clang-format
@@ -1,4 +1,5 @@
 BasedOnStyle: LLVM
 InsertBraces: true
+InsertNewlineAtEOF: true
 LineEnding: LF
 RemoveBracesLLVM: true
Index: clang/lib/Format/.clang-format
===
--- clang/lib/Format/.clang-format
+++ clang/lib/Format/.clang-format
@@ -1,4 +1,5 @@
 BasedOnStyle: LLVM
 InsertBraces: true
+InsertNewlineAtEOF: true
 LineEnding: LF
 RemoveBracesLLVM: true
Index: clang/include/clang/Format/.clang-format
===
--- clang/include/clang/Format/.clang-format
+++ clang/include/clang/Format/.clang-format
@@ -1,4 +1,5 @@
 BasedOnStyle: LLVM
 InsertBraces: true
+InsertNewlineAtEOF: true
 LineEnding: LF
 RemoveBracesLLVM: true
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] bca11ba - [clang-format] Add InsertNewlineAtEOF to .clang-format files

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

Author: Owen Pan
Date: 2023-06-20T08:30:09-07:00
New Revision: bca11bafba9788dd80135b76a187c5f00e64f735

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

LOG: [clang-format] Add InsertNewlineAtEOF to .clang-format files

Also, reformat all clang-format related files.

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

Added: 


Modified: 
clang/include/clang/Format/.clang-format
clang/lib/Format/.clang-format
clang/tools/clang-format/.clang-format
clang/unittests/Format/.clang-format
clang/unittests/Format/FormatTestMacroExpansion.cpp

Removed: 




diff  --git a/clang/include/clang/Format/.clang-format 
b/clang/include/clang/Format/.clang-format
index 60f4950c01a59..63d45e0307a3d 100644
--- a/clang/include/clang/Format/.clang-format
+++ b/clang/include/clang/Format/.clang-format
@@ -1,4 +1,5 @@
 BasedOnStyle: LLVM
 InsertBraces: true
+InsertNewlineAtEOF: true
 LineEnding: LF
 RemoveBracesLLVM: true

diff  --git a/clang/lib/Format/.clang-format b/clang/lib/Format/.clang-format
index 60f4950c01a59..63d45e0307a3d 100644
--- a/clang/lib/Format/.clang-format
+++ b/clang/lib/Format/.clang-format
@@ -1,4 +1,5 @@
 BasedOnStyle: LLVM
 InsertBraces: true
+InsertNewlineAtEOF: true
 LineEnding: LF
 RemoveBracesLLVM: true

diff  --git a/clang/tools/clang-format/.clang-format 
b/clang/tools/clang-format/.clang-format
index 60f4950c01a59..63d45e0307a3d 100644
--- a/clang/tools/clang-format/.clang-format
+++ b/clang/tools/clang-format/.clang-format
@@ -1,4 +1,5 @@
 BasedOnStyle: LLVM
 InsertBraces: true
+InsertNewlineAtEOF: true
 LineEnding: LF
 RemoveBracesLLVM: true

diff  --git a/clang/unittests/Format/.clang-format 
b/clang/unittests/Format/.clang-format
index 60f4950c01a59..63d45e0307a3d 100644
--- a/clang/unittests/Format/.clang-format
+++ b/clang/unittests/Format/.clang-format
@@ -1,4 +1,5 @@
 BasedOnStyle: LLVM
 InsertBraces: true
+InsertNewlineAtEOF: true
 LineEnding: LF
 RemoveBracesLLVM: true

diff  --git a/clang/unittests/Format/FormatTestMacroExpansion.cpp 
b/clang/unittests/Format/FormatTestMacroExpansion.cpp
index feafadb1593e2..1ac5ac0d84f12 100644
--- a/clang/unittests/Format/FormatTestMacroExpansion.cpp
+++ b/clang/unittests/Format/FormatTestMacroExpansion.cpp
@@ -259,4 +259,4 @@ TEST_F(FormatTestMacroExpansion,
 } // namespace
 } // namespace test
 } // namespace format
-} // namespace clang
\ No newline at end of file
+} // namespace clang



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


[PATCH] D153359: [clang][Diagnostics] Fix distant source ranges in bad-conversion notes

2023-06-20 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet created this revision.
hazohelet added reviewers: aaron.ballman, tbaeder, cjdb, shafik.
Herald added a project: All.
hazohelet requested review of this revision.
Herald added a project: clang.

Now that clang supports printing of multiple lines of code snippet in 
diagnostics, source ranges in diagnostics that are located in different lines 
from the diagnosed source location get to be printed if the gap happened to be 
less than the maximum number of lines clang is allowed to print in.
Many of the bad-conversion notes in overload resolution failures have their 
source location in the function declaration and source range in the argument of 
function call. This can cause an unnecessarily many lines of snippet printing.
e.g.

  void func(int num);
  
  
  void test() { func("hello"); }

Live demo: https://godbolt.org/z/fdj6WWsef

This patch fixes it by changing the source range from function callsite to the 
problematic parameter in function declaration.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153359

Files:
  clang/lib/Sema/SemaOverload.cpp
  clang/test/Misc/diag-overload-cand-ranges.cpp
  clang/test/Misc/diag-overload-cand-ranges.mm

Index: clang/test/Misc/diag-overload-cand-ranges.mm
===
--- /dev/null
+++ clang/test/Misc/diag-overload-cand-ranges.mm
@@ -0,0 +1,26 @@
+// RUN: not %clang_cc1 -fobjc-runtime-has-weak -fobjc-arc -fsyntax-only -fdiagnostics-print-source-range-info %s 2>&1 | FileCheck %s --strict-whitespace -check-prefixes=CHECK,ARC
+// RUN: not %clang_cc1 -fobjc-runtime-has-weak -fobjc-gc -fsyntax-only -fdiagnostics-print-source-range-info %s 2>&1 | FileCheck %s --strict-whitespace -check-prefixes=CHECK,GC
+
+// CHECK:  error: no matching function
+// CHECK:  :{[[@LINE+1]]:15-[[@LINE+1]]:28}: note: {{.*}}: 1st argument
+void powerful(__strong id &);
+void lifetime_gcattr_mismatch() {
+  static __weak id weak_id;
+  powerful(weak_id);
+}
+
+// CHECK:  error: no matching function
+// ARC::{[[@LINE+2]]:11-[[@LINE+2]]:21}: note: {{.*}}: cannot implicitly convert
+// GC: :{[[@LINE+1]]:11-[[@LINE+1]]:21}: note: {{.*}}: no known conversion
+void func(char *uiui);
+
+__attribute__((objc_root_class))
+@interface Interface
+- (void)something;
+@end
+
+@implementation Interface
+- (void)something{
+func(self);
+}
+@end
Index: clang/test/Misc/diag-overload-cand-ranges.cpp
===
--- /dev/null
+++ clang/test/Misc/diag-overload-cand-ranges.cpp
@@ -0,0 +1,72 @@
+// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-print-source-range-info %s 2>&1 | FileCheck %s --strict-whitespace
+// CHECK:  error: no matching function
+template  struct mcdata {
+  typedef int result_type;
+};
+template  typename mcdata::result_type wrap_mean(mcdata const &);
+// CHECK:  :{[[@LINE+1]]:19-[[@LINE+1]]:53}: note: {{.*}}: no overload of 'wrap_mean'
+void add_property(double (*)(mcdata const &));
+void f() { add_property(_mean); }
+
+// CHECK:  error: no matching function
+// CHECK:  :{[[@LINE+1]]:10-[[@LINE+1]]:51}: note: {{.*}}: cannot pass pointer to generic address space
+void baz(__attribute__((opencl_private)) int *Data) {}
+void fizz() {
+  int *Nop;
+  baz(Nop);
+  // CHECK:error: no matching function
+  // CHECK::[[@LINE+1]]:53: note: {{.*}}: 'this' object is in address space '__private'
+  __attribute__((opencl_private)) static auto err = [&]() {};
+  err();
+}
+
+// CHECK:  error: no matching function
+struct Bar {
+// CHECK:  :{[[@LINE+1]]:26-[[@LINE+1]]:32}: note: {{.*}} would lose const qualifier
+static void foo(int num, int *X) {}
+// CHECK:  :{[[@LINE+1]]:17-[[@LINE+1]]:25}: note: {{.*}} no known conversion
+static void foo(int *err, int *x) {}
+};
+void bar(const int *Y) {
+  Bar::foo(5, Y);
+}
+
+struct InComp;
+
+struct A {};
+struct B : public A{};
+// CHECK:  error: no matching function
+// CHECK:  :{[[@LINE+5]]:36-[[@LINE+5]]:50}: note: {{.*}}: cannot convert initializer
+// CHECK:  error: no matching function
+// CHECK:  :{[[@LINE+3]]:36-[[@LINE+3]]:50}: note: {{.*}}: cannot convert argument
+// CHECK:  error: no matching function
+// CHECK:  :{[[@LINE+1]]:11-[[@LINE+1]]:18}: note: {{.*}}: no known conversion
+void hoge(char aa, const char *bb, const A& third);
+
+// CHECK:  error: no matching function
+// CHECK:  :{[[@LINE+1]]:14-[[@LINE+1]]:16}: note: {{.*}}: cannot convert from base class
+void derived(B*);
+
+void func(const A ) {
+  hoge(1, "pass", {{{arg}}});
+  InComp *a;
+  hoge(1, "pass", a);
+  hoge("first", 5, 6);
+  A *b;
+  derived(b);
+}
+
+struct Q {
+  // CHECK:error: invalid operands
+  // CHECK::[[@LINE+1]]:6: note: {{.*}}: 'this' argument has type 'const Q'
+  Q +(void*);
+};
+
+void fuga(const Q q) { q + 3; }
+
+template  class Type1 {};
+// CHECK:  error: no matching function
+// CHECK:  

[PATCH] D153331: [clangd][c++20]Consider rewritten binary operators in TargetFinder

2023-06-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/unittests/FindTargetTests.cpp:648
+   {"bool operator==(const Foo &) const noexcept = default",
+Rel::TemplateInstantiation});
+}

this template pattern vs instantiation is really surprising, but it's a 
reasonable analogy, I don't see any particular problems.  (Also, `operator<=>` 
looks like a template over whatever `=` is!)

Do you know whether this means go-to-definition gives you two options to 
navigate to?
(No need to write a test, just curious)



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:4051
 
+TEST(Hover, RewrittenBinaryOperatorSpaceshipMassberg) {
+  Annotations T(R"cpp(

massberg wrote:
> massberg wrote:
> > sammccall wrote:
> > > sammccall wrote:
> > > > no need to sign your work :-)
> > > can you add this to HoverTest__All instead? That way we test all details 
> > > of the hover card
> > Upps, sorry.
> > can you add this to HoverTest__All instead? That way we test all details of 
> > the hover card
> 
> The (Hover, All) test tests with `std=c++17` while this test tests c++20 
> features.
> We could add an additional field with the version to the struct in the 
> (Hover, All) test.
> Or add a (Hover, All_Cpp20) test for testing C++20 (what is probably not 
> worth at the moment with just one test requiring C++20).
Does anything break if you switch everything to C++20?
The intention of "std=c++17" there was certainly "not 14", rather than "not 20" 
:-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153331

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


[PATCH] D153331: [clangd][c++20]Consider rewritten binary operators in TargetFinder

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

Thanks for the comments, I have added an additional test to FindTargetTest. See 
also my other comments.




Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:4051
 
+TEST(Hover, RewrittenBinaryOperatorSpaceshipMassberg) {
+  Annotations T(R"cpp(

sammccall wrote:
> sammccall wrote:
> > no need to sign your work :-)
> can you add this to HoverTest__All instead? That way we test all details of 
> the hover card
Upps, sorry.



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:4051
 
+TEST(Hover, RewrittenBinaryOperatorSpaceshipMassberg) {
+  Annotations T(R"cpp(

massberg wrote:
> sammccall wrote:
> > sammccall wrote:
> > > no need to sign your work :-)
> > can you add this to HoverTest__All instead? That way we test all details of 
> > the hover card
> Upps, sorry.
> can you add this to HoverTest__All instead? That way we test all details of 
> the hover card

The (Hover, All) test tests with `std=c++17` while this test tests c++20 
features.
We could add an additional field with the version to the struct in the (Hover, 
All) test.
Or add a (Hover, All_Cpp20) test for testing C++20 (what is probably not worth 
at the moment with just one test requiring C++20).



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:4079
+  EXPECT_EQ(HI->Type,
+HoverInfo::PrintedType("bool (const Foo &) const noexcept"));
+  EXPECT_EQ(HI->Documentation, "Foo spaceship");

sammccall wrote:
> if we're describing this as the spaceship operator, then the type looks wrong
I have added a test checking the whole definition.
Actually the following is happening here:
The `!=` operator isn't explicitly defined, so the binary operator is rewritten 
to `!(Foo(1) == Foo(2)`,
i.e. we are now using the `==` operator.
However, the `==`  operator is also not explicitly defined, but there is a 
defaulted spaceship operator.
Thus the `==` operator is implicitly defined through the `<=>` operator.
So the type and definition here are from the implicitly defined `==` operator, 
while the original source of it is the `<=>` operator.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153331

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


[PATCH] D153331: [clangd][c++20]Consider rewritten binary operators in TargetFinder

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

Add test to FindTargetTests and extend test in HoverTests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153331

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -4048,6 +4048,41 @@
   EXPECT_TRUE(H->Type);
 }
 
+TEST(Hover, RewrittenBinaryOperatorSpaceship) {
+  Annotations T(R"cpp(
+  namespace std {
+  struct strong_ordering {
+int n;
+constexpr operator int() const { return n; }
+static const strong_ordering equal, greater, less;
+  };
+  constexpr strong_ordering strong_ordering::equal = {0};
+  constexpr strong_ordering strong_ordering::greater = {1};
+  constexpr strong_ordering strong_ordering::less = {-1};
+  }
+
+  struct Foo
+  {
+int x;
+// Foo spaceship
+auto operator<=>(const Foo&) const = default;
+  };
+
+  static_assert(Foo(1) !^= Foo(2));
+  )cpp");
+
+  TestTU TU = TestTU::withCode(T.code());
+  TU.ExtraArgs.push_back("-std=c++20");
+  auto AST = TU.build();
+  auto HI = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
+  EXPECT_EQ(HI->Type,
+HoverInfo::PrintedType("bool (const Foo &) const noexcept"));
+  EXPECT_EQ(HI->Name, "operator==");
+  EXPECT_EQ(HI->Definition,
+"bool operator==(const Foo &) const noexcept = default");
+  EXPECT_EQ(HI->Documentation, "Foo spaceship");
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -618,6 +618,36 @@
   EXPECT_DECLS("RecordTypeLoc", "struct executor");
 }
 
+TEST_F(TargetDeclTest, RewrittenBinaryOperator) {
+  Flags.push_back("-std=c++20");
+
+  Code = R"cpp(
+  namespace std {
+struct strong_ordering {
+  int n;
+  constexpr operator int() const { return n; }
+  static const strong_ordering equal, greater, less;
+};
+constexpr strong_ordering strong_ordering::equal = {0};
+constexpr strong_ordering strong_ordering::greater = {1};
+constexpr strong_ordering strong_ordering::less = {-1};
+}
+
+struct Foo
+{
+  int x;
+  auto operator<=>(const Foo&) const = default;
+};
+
+bool x = (Foo(1) [[!=]] Foo(2));
+  )cpp";
+  EXPECT_DECLS("CXXRewrittenBinaryOperator",
+   {"std::strong_ordering operator<=>(const Foo &) const = default",
+Rel::TemplatePattern},
+   {"bool operator==(const Foo &) const noexcept = default",
+Rel::TemplateInstantiation});
+}
+
 TEST_F(TargetDeclTest, FunctionTemplate) {
   Code = R"cpp(
 // Implicit specialization.
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -347,6 +347,10 @@
   void VisitCXXDeleteExpr(const CXXDeleteExpr *CDE) {
 Outer.add(CDE->getOperatorDelete(), Flags);
   }
+  void
+  VisitCXXRewrittenBinaryOperator(const CXXRewrittenBinaryOperator *RBO) {
+Outer.add(RBO->getDecomposedForm().InnerBinOp, Flags);
+  }
 };
 Visitor(*this, Flags).Visit(S);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147732: [AMDGPU] Add type mangling for {read, write, readfirst, perm}lane intrinsics

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



Comment at: llvm/test/CodeGen/AMDGPU/llvm.amdgcn.readlane.ll:5
+declare i16 @llvm.amdgcn.readlane.i16(i16, i32) #0
+declare half @llvm.amdgcn.readlane.f16(half, i32) #0
+declare float @llvm.amdgcn.readlane.f32(float, i32) #0

arsenm wrote:
> Add bfloat and <2 x i16>, <2 x half>, <2 x bfloat> tests
Also p2, p3, p5, p6


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147732

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


[PATCH] D147732: [AMDGPU] Add type mangling for {read, write, readfirst, perm}lane intrinsics

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



Comment at: llvm/lib/Target/AMDGPU/AMDGPULateCodeGenPrepare.cpp:209
+bool is16Bit =
+(EltType->isIntegerTy() && EltType->getIntegerBitWidth() == 16) ||
+(EltType->isHalfTy());

isIntegerTy(16). Also, just check the bitsize is 16. Might as well also handle 
bfloat



Comment at: llvm/lib/Target/AMDGPU/AMDGPULateCodeGenPrepare.cpp:301-310
+  if (Ty->isPointerTy()) {
+unsigned BitWidth = DL->getTypeSizeInBits(Ty);
+auto ResTy = Result->getType();
+if (ResTy->isVectorTy()) {
+  auto Scalarized = B.CreateBitCast(
+  Result, IntegerType::get(Mod->getContext(), BitWidth));
+  return B.CreateIntToPtr(Scalarized, Ty);

Just let pointer types pass through to codegen, we try really hard to never 
introduce ptrtoint/inttoptr



Comment at: llvm/test/CodeGen/AMDGPU/llvm.amdgcn.readlane.ll:5
+declare i16 @llvm.amdgcn.readlane.i16(i16, i32) #0
+declare half @llvm.amdgcn.readlane.f16(half, i32) #0
+declare float @llvm.amdgcn.readlane.f32(float, i32) #0

Add bfloat and <2 x i16>, <2 x half>, <2 x bfloat> tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147732

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


[PATCH] D147732: [AMDGPU] Add type mangling for {read, write, readfirst, perm}lane intrinsics

2023-06-20 Thread Nuno Lopes via Phabricator via cfe-commits
nlopes added inline comments.



Comment at: llvm/lib/Target/AMDGPU/AMDGPULateCodeGenPrepare.cpp:213
+
+Value *Result = UndefValue::get(Ty);
+for (int i = 0; i < EC; i += 1 + is16Bit) {

Please use poison wherever possible. In this case it seems it's just a 
placeholder, so it can be poison.
We're trying to get rid of poison. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147732

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


[PATCH] D152720: [clangd][ObjC] Support ObjC class rename from implementation decls

2023-06-20 Thread David Goldman via Phabricator via cfe-commits
dgoldman added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:131
 return HighlightingKind::Interface;
-  if (isa(D))
+  if (isa(D))
 return HighlightingKind::Namespace;

kadircet wrote:
> let's do this in a separate change, with some tests
Given the other changes, this is needed otherwise the semantic highlighting 
test fails.



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:171-177
+if (const auto *C = dyn_cast(D)) {
+  if (C->getLocation() == TokenStartLoc)
+D = C->getClassInterface();
+  else if (const auto *I = C->getImplementation())
+if (I->getLocation() == TokenStartLoc)
+  D = C->getClassInterface();
+}

kadircet wrote:
> sorry i don't follow what's the logic doing here and we're likely doing these 
> in the wrong layer.
> 
> we should either:
> - Fix selection tree to pick the correct ASTNode, if it's picking the wrong 
> one due to not having special cases for these locations here
> - Fix the `targetDecl` logic to make sure it emits all the declarations that 
> might be referenced by this ast node, if it's missing ClassInterface.
> - Fix the canonicalRenameDecl, if we should always prefer `ClassInterface` in 
> these cases.
Replied to you in chat, LMK what you think.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152720

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


  1   2   >