[PATCH] D147612: [RISCV][MC] Add support for experimental Zvfbfwma extension

2023-05-19 Thread Alex Bradbury 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 rGa1455de74d95: [RISCV][MC] Add support for experimental 
Zvfbfwma extension (authored by asb).

Changed prior to commit:
  https://reviews.llvm.org/D147612?vs=523018&id=523771#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147612

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/docs/RISCVUsage.rst
  llvm/docs/ReleaseNotes.rst
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/RISCVFeatures.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZvfbf.td
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/rv64zhinx-invalid.s
  llvm/test/MC/RISCV/rv64zhinxmin-invalid.s
  llvm/test/MC/RISCV/rvv/zvfbfwma-invalid.s
  llvm/test/MC/RISCV/rvv/zvfbfwma.s

Index: llvm/test/MC/RISCV/rvv/zvfbfwma.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvv/zvfbfwma.s
@@ -0,0 +1,68 @@
+# RUN: llvm-mc -triple=riscv32 -show-encoding -mattr=+f,+experimental-zvfbfwma %s \
+# RUN:   | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+# RUN: not llvm-mc -triple=riscv32 -show-encoding -mattr=+v,+f %s 2>&1 \
+# RUN:   | FileCheck %s --check-prefix=CHECK-ERROR
+# RUN: llvm-mc -triple=riscv32 -filetype=obj -mattr=+f,+experimental-zvfbfwma %s \
+# RUN:| llvm-objdump -d --mattr=+f,+experimental-zvfbfwma - \
+# RUN:| FileCheck %s --check-prefix=CHECK-INST
+# RUN: llvm-mc -triple=riscv32 -filetype=obj -mattr=+f,+experimental-zvfbfwma %s \
+# RUN:| llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN
+# RUN: llvm-mc -triple=riscv64 -show-encoding -mattr=+f,+experimental-zvfbfwma %s \
+# RUN:   | FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+# RUN: not llvm-mc -triple=riscv64 -show-encoding -mattr=+v,+f %s 2>&1 \
+# RUN:   | FileCheck %s --check-prefix=CHECK-ERROR
+# RUN: llvm-mc -triple=riscv64 -filetype=obj -mattr=+f,+experimental-zvfbfwma %s \
+# RUN:| llvm-objdump -d --mattr=+f,+experimental-zvfbfwma - \
+# RUN:| FileCheck %s --check-prefix=CHECK-INST
+# RUN: llvm-mc -triple=riscv64 -filetype=obj -mattr=+f,+experimental-zvfbfwma %s \
+# RUN:| llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN
+
+# CHECK-INST: vfwmaccbf16.vv v8, v20, v4, v0.t
+# CHECK-ENCODING: [0x57,0x14,0x4a,0x8c]
+# CHECK-ERROR: instruction requires the following: 'Zvfbfwma' (Vector BF16 widening mul-add){{$}}
+# CHECK-UNKNOWN: 57 14 4a 8c 
+vfwmaccbf16.vv v8, v20, v4, v0.t
+
+# CHECK-INST: vfwmaccbf16.vv v8, v20, v4
+# CHECK-ENCODING: [0x57,0x14,0x4a,0x8e]
+# CHECK-ERROR: instruction requires the following: 'Zvfbfwma' (Vector BF16 widening mul-add){{$}}
+# CHECK-UNKNOWN: 57 14 4a 8e 
+vfwmaccbf16.vv v8, v20, v4
+
+# CHECK-INST: vfwmaccbf16.vf v8, fa0, v4, v0.t
+# CHECK-ENCODING: [0x57,0x54,0x45,0x8c]
+# CHECK-ERROR: instruction requires the following: 'Zvfbfwma' (Vector BF16 widening mul-add){{$}}
+# CHECK-UNKNOWN: 57 54 45 8c 
+vfwmaccbf16.vf v8, fa0, v4, v0.t
+
+# CHECK-INST: vfwmaccbf16.vf v8, fa0, v4
+# CHECK-ENCODING: [0x57,0x54,0x45,0x8e]
+# CHECK-ERROR: instruction requires the following: 'Zvfbfwma' (Vector BF16 widening mul-add){{$}}
+# CHECK-UNKNOWN: 57 54 45 8e 
+vfwmaccbf16.vf v8, fa0, v4
+
+# Check scalar half FP load/store/move included in this extension.
+
+# CHECK-INST: flh ft0, 12(a0)
+# CHECK-ENCODING: [0x07,0x10,0xc5,0x00]
+# CHECK-ERROR: instruction requires the following: 'Zfh' (Half-Precision Floating-Point) or 'Zfhmin' (Half-Precision Floating-Point Minimal) or 'Zfbfmin' (Scalar BF16 Converts) or 'Zvfbfwma' (Vector BF16 widening mul-add){{$}}
+# CHECK-UNKNOWN: 07 10 c5 00 
+flh f0, 12(a0)
+
+# CHECK-INST: fsh ft6, 2047(s4)
+# CHECK-ENCODING: [0xa7,0x1f,0x6a,0x7e]
+# CHECK-ERROR: instruction requires the following: 'Zfh' (Half-Precision Floating-Point) or 'Zfhmin' (Half-Precision Floating-Point Minimal) or 'Zfbfmin' (Scalar BF16 Converts) or 'Zvfbfwma' (Vector BF16 widening mul-add){{$}}
+# CHECK-UNKNOWN: a7 1f 6a 7e 
+fsh f6, 2047(s4)
+
+# CHECK-INST: fmv.x.h a2, fs7
+# CHECK-ENCODING: [0x53,0x86,0x0b,0xe4]
+# CHECK-ERROR: instruction requires the following: 'Zfh' (Half-Precision Floating-Point) or 'Zfhmin' (Half-Precision Floating-Point Minimal) or 'Zfbfmin' (Scalar BF16 Converts) or 'Zvfbfwma' (Vector BF16 widening mul-add){{$}}
+# CHECK-UNKNOWN: 53 86 0b e4 
+fmv.x.h a2, fs7
+
+# CHECK-INST: fmv.h.x ft1, a6
+# CHECK-ENCODING: [0xd3,0x00,0x08,0xf4]
+# CHECK-ERROR: instruction requires the following: 'Zfh' (Half-Precision Floating-Point) or 'Zfhmin' (Half-Precision Floating-Point Minimal) or 'Zfbfmin' (Scalar BF16 Converts) or 'Zvfbfwma' (Vector BF16 widening mul-add){{$}}
+# CHECK-UNKNOWN: d3 00 08 f4 
+fmv.h.x ft1, a6
Index: llvm/test/MC/RISCV/rvv/zvfbfwma-invalid.s
===

[PATCH] D150966: [clang] Don't define predefined macros multiple times

2023-05-19 Thread John Brawn via Phabricator via cfe-commits
john.brawn created this revision.
john.brawn added reviewers: aaron.ballman, thakis, arichardson, pratlucas.
Herald added subscribers: luke, abrachet, frasercrmck, phosek, luismarques, 
apazos, sameer.abuasal, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, 
MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, 
simoncook, johnrusso, rbar, asb, fedor.sergeev, kristof.beyls, krytarowski, 
dylanmckay, dschuff.
Herald added a project: All.
john.brawn requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, MaskRay, aheejin.
Herald added a project: clang.

Fix several instances of macros being defined multiple times in several 
targets. Most of these are just simple duplication in a TargetInfo or 
OSTargetInfo of things already defined in InitializePredefinedMacros or 
InitializeStandardPredefinedMacros, but there are a few that aren't:

- AArch64 defines a couple of feature macros for armv8.1a that are handled 
generically by getTargetDefines.
- CSKY needs to take care when CPUName and ArchName are the same.
- Many os/target combinations result in __ELF__ being defined twice. Instead 
define __ELF__ just once in InitPreprocessor based on the Triple, which already 
knows what the object format is based on os and target.

These changes shouldn't change the final result of which macros are defined, 
with the exception of the changes to __ELF__ where if you explicitly specify 
the object type in the triple then this affects if __ELF__ is defined, e.g. 
--target=i686-windows-elf results in it being defined where it wasn't before, 
but this is more accurate as an ELF file is in fact generated.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150966

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Basic/Targets/AVR.cpp
  clang/lib/Basic/Targets/CSKY.cpp
  clang/lib/Basic/Targets/Hexagon.cpp
  clang/lib/Basic/Targets/Le64.cpp
  clang/lib/Basic/Targets/MSP430.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/VE.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/Preprocessor/predefined-macros-no-warnings.c

Index: clang/test/Preprocessor/predefined-macros-no-warnings.c
===
--- /dev/null
+++ clang/test/Preprocessor/predefined-macros-no-warnings.c
@@ -0,0 +1,196 @@
+// Check that the predefined macros don't contain anything that causes a warning with -Wsystem-headers
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple arc
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple xcore
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple hexagon
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple hexagon-linux
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple lanai
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple aarch64_32-darwin
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple aarch64
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple aarch64-darwin
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple aarch64-cloudabi
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple aarch64-freebsd
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple aarch64-fuchsia
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple aarch64-linux
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple aarch64-linux-openhos
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple aarch64-netbsd
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple aarch64-openbsd
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple aarch64-win32-gnu
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple aarch64-win32-msvc
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple aarch64_be
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple aarch64_be-freebsd
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple aarch64_be-fuchsia
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple aarch64_be-linux
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple aarch64_be-netbsd
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple arm
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple arm-darwin
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple arm-cloudabi
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple arm-freebsd
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple arm-fuchsia
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple arm-linux
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple arm-linux-openhos
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple arm-liteos
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple arm-netbsd
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple a

[PATCH] D148665: Change -fsanitize=function to place two words before the function entry

2023-05-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay marked an inline comment as done.
MaskRay added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.h:205
   getUBSanFunctionSignature(CodeGen::CodeGenModule &CGM) const {
-return nullptr;
+return llvm::ConstantInt::get(CGM.Int32Ty, 0xc105cafe);
   }

peter.smith wrote:
> Is it worth making this target specific? Defaulting to 0xc105cafe for all 
> targets, if that gets allocated in the future on any one target we can change 
> it without having to test against all other targets.
> 
> For example on AArch64 this is is in the decoding space of SME instructions 
> op0 = 0b1 op1 = 0b. This may get allocated in the future. Although 
> admittedly it is likely to be very rare to find a use of a SME instruction at 
> the end of a function to cause it to get misidentified.
> 
> I suspect most targets have an explicit undefined instruction, such as UDF in 
> AArch64 which is 0x where ? can be any value. On Arm there two 
> separate 4-byte encodings for Arm, Thumb of UDF.
> 
Thanks for the review! This is a virtual function, so a target can override as 
appropriate.

Thanks for informing that this is an encoding that AArch64 may allocate in the 
future. Since the signature is placed before the function label and is used to 
protect uninstrumented object files, the signature doesn't need to be out of 
all encoding space. As long as it is unlikely to be the last 2 instructions of 
a previous function, this is going to have a good defensive effect. So I expect 
that A32/A64 may not want to change this as well.

I assume that T32 unlikely uses 0xca 0xca (ldm r2, {r1-r7}) as one of the last 
two instructions of the previous function, so this seems fine as well, but no 
objection if T32 wants to change to a different signature :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148665

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


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

2023-05-19 Thread Alex Bradbury via Phabricator via cfe-commits
asb added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:2347
 
-Only ``*m1_t`` (LMUL=1) types are supported at this time.
+For types where LMUL!=1, ``__riscv_v_fixed_vlen`` needs to be scaled by the 
LMULo
+of the type before passing to the attribute.

LMULo -> LMUL


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150926

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


[PATCH] D150966: [clang] Don't define predefined macros multiple times

2023-05-19 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added a comment.

Is it possible/worth to add an assertion to Builder.defineMacro to enforce this 
one definition rule?




Comment at: clang/lib/Frontend/InitPreprocessor.cpp:1305
+Builder.defineMacro("__ELF__");
+  }
+

Redundant braces.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150966

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


[PATCH] D150968: [NFC][CLANG] Fix issue with dereference null return value found by Coverity static analyzer tool

2023-05-19 Thread Soumi Manna via Phabricator via cfe-commits
Manna created this revision.
Herald added subscribers: manas, ASDenysPetrov, dkrupp, donat.nagy, Szelethus, 
a.sidorin, baloghadamsoftware.
Herald added a project: All.
Manna requested review of this revision.
Herald added a project: clang.

Reported by Coverity:

  In 
clang::​FunctionDecl::​isReplaceableGlobalAllocationFunction(std::​optional *, bool *): Return value of function which returns null is dereferenced 
without checking 
  
  if (!IsSizedDelete && !Ty.isNull() && Ty->isEnumeralType()) {
   QualType T = Ty;
   //Condition TD, taking false branch.
  while (const auto *TD = T->getAs())
T = TD->getDecl()->getUnderlyingType();
//returned_null: getAs returns nullptr (checked 95 out of 97 times). 

  //Dereference null return value (NULL_RETURNS)
  // dereference: Dereferencing a pointer that might be nullptr T->getAs() 
when calling getDecl. 
  IdentifierInfo *II = T->getAs()->getDecl()->getIdentifier();
  if (II && II->isStr("__hot_cold_t"))
Consume();
}

This patch uses castAs instead of getAs which will assert if the type doesn't 
match.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150968

Files:
  clang/lib/AST/Decl.cpp


Index: clang/lib/AST/Decl.cpp
===
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -3301,7 +3301,7 @@
 QualType T = Ty;
 while (const auto *TD = T->getAs())
   T = TD->getDecl()->getUnderlyingType();
-IdentifierInfo *II = T->getAs()->getDecl()->getIdentifier();
+IdentifierInfo *II = T->castAs()->getDecl()->getIdentifier();
 if (II && II->isStr("__hot_cold_t"))
   Consume();
   }


Index: clang/lib/AST/Decl.cpp
===
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -3301,7 +3301,7 @@
 QualType T = Ty;
 while (const auto *TD = T->getAs())
   T = TD->getDecl()->getUnderlyingType();
-IdentifierInfo *II = T->getAs()->getDecl()->getIdentifier();
+IdentifierInfo *II = T->castAs()->getDecl()->getIdentifier();
 if (II && II->isStr("__hot_cold_t"))
   Consume();
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] ad31a2d - Change -fsanitize=function to place two words before the function entry

2023-05-19 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-05-19T07:50:29-07:00
New Revision: ad31a2dcadfcd57a99bbd6d0050d2690fd84a883

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

LOG: Change -fsanitize=function to place two words before the function entry

The current implementation of -fsanitize=function places two words (the prolog
signature and the RTTI proxy) at the function entry, which makes the feature
incompatible with Intel Indirect Branch Tracking (IBT) that needs an ENDBR 
instruction
at the function entry. To allow the combination, move the two words before the
function entry, similar to -fsanitize=kcfi.

Armv8.5 Branch Target Identification (BTI) has a similar requirement.

Note: for IBT and BTI, whether a function gets a marker instruction at the entry
generally cannot be assumed (it can be disabled by a function attribute or
stronger LTO optimizations).

It is extremely unlikely for two words preceding a function entry to be
inaccessible. One way to achieve this is by ensuring that a function is
aligned at a page boundary and making the preceding page unmapped or
unreadable. This is not reasonable for application or library code.
(Think: the first text section has crt* code not instrumented by
-fsanitize=function.)

We use 0xc105cafe for all targets. .long 0xc105cafe disassembles to invalid
instructions on all architectures I have tested, except Power where it is
`lfs 8, -13570(5)` (Load Floating-Point with a weird offset, unlikely to be 
used in real code).

---

For the removed function in AsmPrinter.cpp, remove an assert: `mdconst::extract`
already asserts non-nullness.

For compiler-rt/test/ubsan/TestCases/TypeCheck/Function/function.cpp,
when the function doesn't have prolog/epilog (-O1 and above), after moving the 
two words,
the address of the function equals the address of ret instruction,
so symbolizing the function will additionally get a non-zero column number.
Adjust the test to allow an optional column number.
```
  .long   3238382334
  .long   .L__llvm_rtti_proxy-_Z1fv
_Z1fv:   // symbolizing here retrieves the line table entry from the second .loc
  .file   0 ...
  .loc0 1 0
  .cfi_startproc
  .loc0 2 1 prologue_end
  retq
```

Reviewed By: peter.smith

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

Added: 


Modified: 
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/TargetInfo.cpp
clang/lib/CodeGen/TargetInfo.h
clang/test/CodeGen/ubsan-function.cpp
clang/test/CodeGenCXX/catch-undef-behavior.cpp
clang/test/CodeGenCXX/ubsan-function-noexcept.cpp
compiler-rt/test/ubsan/TestCases/TypeCheck/Function/function.cpp
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/test/CodeGen/X86/func-sanitizer.ll
llvm/test/CodeGen/X86/patchable-function-entry-ibt.ll

Removed: 




diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 44b97d272634e..834c2fda5855b 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -5368,7 +5368,7 @@ RValue CodeGenFunction::EmitCall(QualType CalleeType, 
const CGCallee &OrigCallee
   llvm::Value *CalleePrefixStruct = Builder.CreateBitCast(
   CalleePtr, llvm::PointerType::getUnqual(PrefixStructTy));
   llvm::Value *CalleeSigPtr =
-  Builder.CreateConstGEP2_32(PrefixStructTy, CalleePrefixStruct, 0, 0);
+  Builder.CreateConstGEP2_32(PrefixStructTy, CalleePrefixStruct, -1, 
0);
   llvm::Value *CalleeSig =
   Builder.CreateAlignedLoad(PrefixSigType, CalleeSigPtr, 
getIntAlign());
   llvm::Value *CalleeSigMatch = Builder.CreateICmpEQ(CalleeSig, PrefixSig);
@@ -5379,7 +5379,7 @@ RValue CodeGenFunction::EmitCall(QualType CalleeType, 
const CGCallee &OrigCallee
 
   EmitBlock(TypeCheck);
   llvm::Value *CalleeRTTIPtr =
-  Builder.CreateConstGEP2_32(PrefixStructTy, CalleePrefixStruct, 0, 1);
+  Builder.CreateConstGEP2_32(PrefixStructTy, CalleePrefixStruct, -1, 
1);
   llvm::Value *CalleeRTTIEncoded =
   Builder.CreateAlignedLoad(Int32Ty, CalleeRTTIPtr, getPointerAlign());
   llvm::Value *CalleeRTTI =

diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index e4d75eff08423..13c2a6b65f76e 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -1293,15 +1293,6 @@ class X86_32TargetCodeGenInfo : public TargetCodeGenInfo 
{
 std::string &AsmString,
 unsigned NumOutputs) const override;
 
-  llvm::Constant *
-  getUBSanFunctionSignature(CodeGen::CodeGenModule &CGM) const override {
-unsigned Sig = (0xeb << 0) |  // jmp rel8
-   (0x06 << 8) |  //   .+0x08
-   ('v' << 16) |
-   ('2' << 24);
-return

[PATCH] D148665: Change -fsanitize=function to place two words before the function entry

2023-05-19 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.
MaskRay marked an inline comment as done.
Closed by commit rGad31a2dcadfc: Change -fsanitize=function to place two words 
before the function entry (authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148665

Files:
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h
  clang/test/CodeGen/ubsan-function.cpp
  clang/test/CodeGenCXX/catch-undef-behavior.cpp
  clang/test/CodeGenCXX/ubsan-function-noexcept.cpp
  compiler-rt/test/ubsan/TestCases/TypeCheck/Function/function.cpp
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/test/CodeGen/X86/func-sanitizer.ll
  llvm/test/CodeGen/X86/patchable-function-entry-ibt.ll

Index: llvm/test/CodeGen/X86/patchable-function-entry-ibt.ll
===
--- llvm/test/CodeGen/X86/patchable-function-entry-ibt.ll
+++ llvm/test/CodeGen/X86/patchable-function-entry-ibt.ll
@@ -1,6 +1,9 @@
 ; RUN: llc -mtriple=i686 %s -o - | FileCheck --check-prefixes=CHECK,32 %s
 ; RUN: llc -mtriple=x86_64 %s -o - | FileCheck --check-prefixes=CHECK,64 %s
 
+@_ZTIFvvE = linkonce_odr constant i32 1
+@__llvm_rtti_proxy = private unnamed_addr constant ptr @_ZTIFvvE
+
 ;; -fpatchable-function-entry=0 -fcf-protection=branch
 define void @f0() "patchable-function-entry"="0" {
 ; CHECK-LABEL: f0:
@@ -83,6 +86,25 @@
   ret void
 }
 
+;; Test the interaction with -fsanitize=function.
+; CHECK:  .type sanitize_function,@function
+; CHECK-NEXT: .Ltmp{{.*}}:
+; CHECK-NEXT:   nop
+; CHECK-NEXT:   .long   3238382334
+; CHECK-NEXT:   .long   .L__llvm_rtti_proxy-sanitize_function
+; CHECK-NEXT: sanitize_function:
+; CHECK-NEXT: .Lfunc_begin{{.*}}:
+; CHECK-NEXT:   .cfi_startproc
+; CHECK-NEXT:   # %bb.0:
+; 32-NEXT:  endbr32
+; 64-NEXT:  endbr64
+; CHECK-NEXT:   nop
+; CHECK-NEXT:   ret
+define void @sanitize_function(ptr noundef %x) "patchable-function-prefix"="1" "patchable-function-entry"="1" !func_sanitize !1 {
+  ret void
+}
+
 !llvm.module.flags = !{!0}
 
 !0 = !{i32 8, !"cf-protection-branch", i32 1}
+!1 = !{i32 3238382334, ptr @__llvm_rtti_proxy}
Index: llvm/test/CodeGen/X86/func-sanitizer.ll
===
--- llvm/test/CodeGen/X86/func-sanitizer.ll
+++ llvm/test/CodeGen/X86/func-sanitizer.ll
@@ -1,12 +1,12 @@
 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s
 
-; CHECK: _Z3funv:
-; CHECK: .cfi_startproc
-; CHECK: .long   846595819
-; CHECK: .long   .L__llvm_rtti_proxy-_Z3funv
-; CHECK: .L__llvm_rtti_proxy:
-; CHECK: .quad   i
-; CHECK: .size   .L__llvm_rtti_proxy, 8
+; CHECK:  .type _Z3funv,@function
+; CHECK-NEXT:   .long   3238382334  # 0xc105cafe
+; CHECK-NEXT:   .long   .L__llvm_rtti_proxy-_Z3funv
+; CHECK-NEXT: _Z3funv:
+; CHECK-NEXT:   .cfi_startproc
+; CHECK-NEXT:   # %bb.0:
+; CHECK-NEXT:   retq
 
 @i = linkonce_odr constant i32 1
 @__llvm_rtti_proxy = private unnamed_addr constant ptr @i
@@ -15,4 +15,4 @@
   ret void
 }
 
-!0 = !{i32 846595819, ptr @__llvm_rtti_proxy}
+!0 = !{i32 3238382334, ptr @__llvm_rtti_proxy}
Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -971,6 +971,21 @@
 CurrentPatchableFunctionEntrySym = CurrentFnBegin;
   }
 
+  // Emit the function prologue data for the indirect call sanitizer.
+  if (const MDNode *MD = F.getMetadata(LLVMContext::MD_func_sanitize)) {
+assert(MD->getNumOperands() == 2);
+
+auto *PrologueSig = mdconst::extract(MD->getOperand(0));
+auto *FTRTTIProxy = mdconst::extract(MD->getOperand(1));
+emitGlobalConstant(F.getParent()->getDataLayout(), PrologueSig);
+
+const MCExpr *Proxy = lowerConstant(FTRTTIProxy);
+const MCExpr *FnExp = MCSymbolRefExpr::create(CurrentFnSym, OutContext);
+const MCExpr *PCRel = MCBinaryExpr::createSub(Proxy, FnExp, OutContext);
+// Use 32 bit since only small code model is supported.
+OutStreamer->emitValue(PCRel, 4u);
+  }
+
   if (isVerbose()) {
 F.printAsOperand(OutStreamer->getCommentOS(),
  /*PrintType=*/false, F.getParent());
@@ -1025,24 +1040,6 @@
   // Emit the prologue data.
   if (F.hasPrologueData())
 emitGlobalConstant(F.getParent()->getDataLayout(), F.getPrologueData());
-
-  // Emit the function prologue data for the indirect call sanitizer.
-  if (const MDNode *MD = F.getMetadata(LLVMContext::MD_func_sanitize)) {
-assert(TM.getTargetTriple().getArch() == Triple::x86 ||
-   TM.getTargetTriple().getArch() == Triple::x86_64);
-assert(MD->getNumOperands() == 2);
-
-auto *PrologueSig = mdconst::extract(MD->getOperand(0)

[PATCH] D150913: [Clang][Bfloat16] Upgrade __bf16 to arithmetic type, change mangling, and extend excess precision support.

2023-05-19 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a comment.

Great work! Thanks for the patch!




Comment at: clang/include/clang/AST/ASTContext.h:1102
   CanQualType HalfTy; // [OpenCL 6.1.1.1], ARM NEON
-  CanQualType BFloat16Ty;
+  CanQualType BFloat16Ty; // ISO/IEC/IEEE 60559.
   CanQualType Float16Ty; // C11 extension ISO/IEC TS 18661-3

Don't have a look at ISO/IEC/IEEE 60559, but I doubt BF16 is still not a IEEE 
type for now.



Comment at: clang/lib/Basic/Targets/AMDGPU.h:121
   bool hasBFloat16Type() const override { return isAMDGCN(getTriple()); }
-  const char *getBFloat16Mangling() const override { return "u6__bf16"; };
+  const char *getBFloat16Mangling() const override { return "DF16b"; };
 

I think it's time to bring D139608 back with this patch :)



Comment at: clang/lib/Basic/Targets/X86.cpp:362-363
   HasX87 = true;
+} else if (Feature == "+fullbf16") {
+  HasFullBFloat16 = true;
 }

Maybe not need it.



Comment at: clang/lib/Basic/Targets/X86.cpp:381
 
 HasBFloat16 = SSELevel >= SSE2;
 

I'm not sure if I understand the meaning of `HasFullBFloat16`. If it is used 
for target that supports arithmetic `__bf16`, we should not use `+fullbf16` but 
always enable it for SSE2, i.e., `HasFullBFloat16 = SSELevel >= SSE2`. Because 
X86 GCC already supports arithmetic for `__bf16`.

If this is used in the way like `HasLegalHalfType`, we should enable it once we 
have a full BF16 ISA on X86. `fullbf16` doesn't make much sense to me.



Comment at: clang/lib/Basic/Targets/X86.cpp:1122
   .Case("xsaveopt", HasXSAVEOPT)
+  .Case("fullbf16", HasFullBFloat16)
   .Default(false);

ditto.



Comment at: clang/test/CodeGen/X86/bfloat16.cpp:2-3
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 2
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -target-feature +fullbf16 
-S -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | 
FileCheck -check-prefix=CHECK-NBF16 %s
+

The backend has already support lowering of `bfloat`, I don't think it's 
necessary to do extra work in FE unless for excess-precision.



Comment at: clang/test/CodeGen/X86/fexcess-precision-bfloat16.c:7
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
+// RUN: -fbfloat16-excess-precision=fast -target-feature +fullbf16 \
+// RUN: -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK-NO-EXT %s

The tests here make me guess you want to use `fullbf16` the same as 
`HasLegalHalfType`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150913

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


[PATCH] D150966: [clang] Don't define predefined macros multiple times

2023-05-19 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added a comment.

Q: What is it the -Wsystem-header can warn about? I mean, no system header is 
included by the test, what can go wrong?




Comment at: clang/test/Preprocessor/predefined-macros-no-warnings.c:2
+// Check that the predefined macros don't contain anything that causes a 
warning with -Wsystem-headers
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple arc
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple xcore




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150966

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


[PATCH] D148573: Allow -fsanitize=function on all targets

2023-05-19 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 rG67cbe1b85972: Allow -fsanitize=function on all targets 
(authored by MaskRay).
Herald added subscribers: pcwang-thead, s.egerton, mstorsjo, simoncook, asb.

Changed prior to commit:
  https://reviews.llvm.org/D148573?vs=515161&id=523782#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148573

Files:
  clang/docs/UndefinedBehaviorSanitizer.rst
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/lib/Driver/ToolChains/NetBSD.cpp
  clang/lib/Driver/ToolChains/Solaris.cpp
  clang/test/CodeGen/ubsan-function.cpp
  clang/test/Driver/fsanitize.c
  compiler-rt/test/ubsan/TestCases/TypeCheck/Function/function.cpp
  compiler-rt/test/ubsan/TestCases/TypeCheck/Function/lit.local.cfg.py
  llvm/test/CodeGen/AArch64/func-sanitizer.ll
  llvm/test/CodeGen/AArch64/patchable-function-entry-bti.ll

Index: llvm/test/CodeGen/AArch64/patchable-function-entry-bti.ll
===
--- llvm/test/CodeGen/AArch64/patchable-function-entry-bti.ll
+++ llvm/test/CodeGen/AArch64/patchable-function-entry-bti.ll
@@ -1,5 +1,8 @@
 ; RUN: llc -mtriple=aarch64 %s -o - | FileCheck %s
 
+@_ZTIFvvE = linkonce_odr constant i32 2
+@__llvm_rtti_proxy = private unnamed_addr constant ptr @_ZTIFvvE
+
 define void @f0() "patchable-function-entry"="0" "branch-target-enforcement"="true" {
 ; CHECK-LABEL: f0:
 ; CHECK-NEXT: .Lfunc_begin0:
@@ -85,3 +88,22 @@
   call void asm sideeffect "", ""()
   ret void
 }
+
+;; Test the interaction with -fsanitize=function.
+; CHECK:  .type sanitize_function,@function
+; CHECK-NEXT: .Ltmp{{.*}}:
+; CHECK-NEXT:   nop
+; CHECK-NEXT:   .word   3238382334  // 0xc105cafe
+; CHECK-NEXT:   .word   .L__llvm_rtti_proxy-sanitize_function
+; CHECK-NEXT: sanitize_function:
+; CHECK-NEXT: .Lfunc_begin{{.*}}:
+; CHECK-NEXT:   .cfi_startproc
+; CHECK-NEXT:   // %bb.0:
+; CHECK-NEXT:   hint #34
+; CHECK-NEXT:   nop
+; CHECK-NEXT:   ret
+define void @sanitize_function(ptr noundef %x) "patchable-function-prefix"="1" "patchable-function-entry"="1" "branch-target-enforcement"="true" !func_sanitize !0 {
+  ret void
+}
+
+!0 = !{i32 3238382334, ptr @__llvm_rtti_proxy}
Index: llvm/test/CodeGen/AArch64/func-sanitizer.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/func-sanitizer.ll
@@ -0,0 +1,22 @@
+; RUN: llc -mtriple=aarch64-unknown-linux-gnu < %s | FileCheck %s
+
+; CHECK-LABEL: .type _Z3funv,@function
+; CHECK-NEXT:.word   3238382334  // 0xc105cafe
+; CHECK-NEXT:.word   .L__llvm_rtti_proxy-_Z3funv
+; CHECK-NEXT:  _Z3funv:
+; CHECK-NEXT:  // %bb.0:
+; CHECK-NEXT:ret
+
+; CHECK:   .section .rodata,"a",@progbits
+; CHECK-LABEL: .L__llvm_rtti_proxy:
+; CHECK-NEXT:.xword  _ZTIFvvE
+; CHECK-NEXT:.size   .L__llvm_rtti_proxy, 8
+
+@_ZTIFvvE = linkonce_odr constant i32 1
+@__llvm_rtti_proxy = private unnamed_addr constant ptr @_ZTIFvvE
+
+define dso_local void @_Z3funv() nounwind !func_sanitize !0 {
+  ret void
+}
+
+!0 = !{i32 3238382334, ptr @__llvm_rtti_proxy}
Index: compiler-rt/test/ubsan/TestCases/TypeCheck/Function/lit.local.cfg.py
===
--- compiler-rt/test/ubsan/TestCases/TypeCheck/Function/lit.local.cfg.py
+++ compiler-rt/test/ubsan/TestCases/TypeCheck/Function/lit.local.cfg.py
@@ -1,3 +1,2 @@
-# The function type checker is only supported on x86 and x86_64 for now.
-if config.target_arch not in ['x86', 'x86_64']:
+if config.host_os not in ['Darwin', 'FreeBSD', 'Linux', 'NetBSD']:
   config.unsupported = True
Index: compiler-rt/test/ubsan/TestCases/TypeCheck/Function/function.cpp
===
--- compiler-rt/test/ubsan/TestCases/TypeCheck/Function/function.cpp
+++ compiler-rt/test/ubsan/TestCases/TypeCheck/Function/function.cpp
@@ -4,9 +4,6 @@
 // RUN: %run %t 2>&1 | FileCheck %s --check-prefix=CHECK $(%run %t-unique UNIQUE)
 // Verify that we can disable symbolization if needed:
 // RUN: %env_ubsan_opts=symbolize=0 %run %t 2>&1 | FileCheck %s --check-prefix=NOSYM $(%run %t-unique NOSYM-UNIQUE)
-// XFAIL: target={{.*windows.*}}
-// Unsupported function flag
-// UNSUPPORTED: target={{.*openbsd.*}}
 
 #ifdef DETERMINE_UNIQUE
 
Index: clang/test/Driver/fsanitize.c
===
--- clang/test/Driver/fsanitize.c
+++ clang/test/Driver/fsanitize.c
@@ -24,8 +24,8 @@
 // CHECK-UNDEFINED-WIN64: "--dependent-lib={{[^"]*}}ubsan_standalone{{(-x86_64)?}}.lib"
 // CHECK-UNDEFINED-WIN64-MINGW: "--dependent-lib={{[^"]*}}libclang_rt.ubsan_standalone{{(-x86_64)?}}.a"
 // CHECK-UNDEFINED-WIN-CXX: "--depe

[PATCH] D124244: [analyzer] add StoreToImmutable and ModelConstQualifiedReturn checkers

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

Overall this seems to be a promising checker; I added a few minor remarks as 
inline comments. Unfortunately @steakhal's comment that

> The `check::PostCall` handler wants to mark some memory region immutable. 
> Currently, the checker creates a new //symbolic// memregion, spawned into the 
> //immutable// memory space. After this it simply re-binds the return value.
> However, only `eval::Call` handler is supposed (**must**) to bind the return 
> value, so the current implementation cannot land.

highlights question that is as far as I see a blocking obstacle. I hope that 
you can find a solution for that technical difficulty.

Moreover, I agree with @martong's comment that you should probably create two 
commits for these two checkers. (One-way dependency between the checkers is not 
an obstacle: simply pay attention to merging the commits in the right order.)




Comment at: clang/lib/StaticAnalyzer/Checkers/StoreToImmutableChecker.cpp:68-72
+  if (const auto *BP = dyn_cast(S))
+if (const auto *UP = dyn_cast(BP->getLHS())) {
+  bugreporter::trackExpressionValue(
+  Report->getErrorNode(), UP->getSubExpr()->IgnoreImpCasts(), *Report);
+}

This code is a bit hard to understand, perhaps add a comment like
`// If the binding statement looks like "*ptr = ...", then track the pointer 
"ptr"`



Comment at: 
clang/lib/StaticAnalyzer/Checkers/cert/ModelConstQualifiedReturnChecker.cpp:39
+  // SEI CERT ENV30-C
+  const CallDescriptionMap ConstQualifiedReturnFunctions = {
+  {{"getenv", 1},

If you don't have concrete plans for extending this checker to cases where you 
need a different HandlerFn, then I strongly suggest replacing this map with a 
set (or a CallDescriptionMap where the bool is just a dummy placeholder). 
There is no reason to juggle member function pointers when they are always 
pointing to the same function.


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

https://reviews.llvm.org/D124244

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


[PATCH] D150968: [NFC][CLANG] Fix issue with dereference null return value found by Coverity static analyzer tool

2023-05-19 Thread Soumi Manna via Phabricator via cfe-commits
Manna added a comment.

Thank you @erichkeane for review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150968

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


[PATCH] D148088: [RFC][clangd] Move preamble index out of document open critical path

2023-05-19 Thread Kugan Vivekanandarajah via Phabricator via cfe-commits
kuganv updated this revision to Diff 523784.
kuganv added a comment.

Revised Except for:

1. Explicitly destructing in AfterExecute
2. setStatCache to take refence

Removing Both of which is causing crash.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148088

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/tool/Check.cpp
  clang-tools-extra/clangd/unittests/FileIndexTests.cpp
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
  clang-tools-extra/clangd/unittests/TestWorkspace.cpp
  clang/include/clang/Frontend/CompilerInstance.h

Index: clang/include/clang/Frontend/CompilerInstance.h
===
--- clang/include/clang/Frontend/CompilerInstance.h
+++ clang/include/clang/Frontend/CompilerInstance.h
@@ -12,6 +12,7 @@
 #include "clang/AST/ASTConsumer.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Basic/TargetInfo.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Frontend/PCHContainerOperations.h"
 #include "clang/Frontend/Utils.h"
@@ -233,6 +234,8 @@
 return *Invocation;
   }
 
+  std::shared_ptr getInvocationPtr() { return Invocation; }
+
   /// setInvocation - Replace the current invocation.
   void setInvocation(std::shared_ptr Value);
 
@@ -338,6 +341,11 @@
 return *Diagnostics;
   }
 
+  IntrusiveRefCntPtr getDiagnosticsPtr() const {
+assert(Diagnostics && "Compiler instance has no diagnostics!");
+return Diagnostics;
+  }
+
   /// setDiagnostics - Replace the current diagnostics engine.
   void setDiagnostics(DiagnosticsEngine *Value);
 
@@ -373,6 +381,11 @@
 return *Target;
   }
 
+  IntrusiveRefCntPtr getTargetPtr() const {
+assert(Target && "Compiler instance has no target!");
+return Target;
+  }
+
   /// Replace the current Target.
   void setTarget(TargetInfo *Value);
 
@@ -406,6 +419,11 @@
 return *FileMgr;
   }
 
+  IntrusiveRefCntPtr getFileManagerPtr() const {
+assert(FileMgr && "Compiler instance has no file manager!");
+return FileMgr;
+  }
+
   void resetAndLeakFileManager() {
 llvm::BuryPointer(FileMgr.get());
 FileMgr.resetWithoutRelease();
@@ -426,6 +444,11 @@
 return *SourceMgr;
   }
 
+  IntrusiveRefCntPtr getSourceManagerPtr() const {
+assert(SourceMgr && "Compiler instance has no source manager!");
+return SourceMgr;
+  }
+
   void resetAndLeakSourceManager() {
 llvm::BuryPointer(SourceMgr.get());
 SourceMgr.resetWithoutRelease();
@@ -466,6 +489,11 @@
 return *Context;
   }
 
+  IntrusiveRefCntPtr getASTContextPtr() const {
+assert(Context && "Compiler instance has no AST context!");
+return Context;
+  }
+
   void resetAndLeakASTContext() {
 llvm::BuryPointer(Context.get());
 Context.resetWithoutRelease();
Index: clang-tools-extra/clangd/unittests/TestWorkspace.cpp
===
--- clang-tools-extra/clangd/unittests/TestWorkspace.cpp
+++ clang-tools-extra/clangd/unittests/TestWorkspace.cpp
@@ -21,11 +21,14 @@
   continue;
 TU.Code = Input.second.Code;
 TU.Filename = Input.first().str();
-TU.preamble([&](ASTContext &Ctx, Preprocessor &PP,
-const CanonicalIncludes &CanonIncludes) {
-  Index->updatePreamble(testPath(Input.first()), "null", Ctx, PP,
-CanonIncludes);
-});
+TU.preamble(
+[&](CapturedASTCtx ASTCtx,
+const std::shared_ptr CanonIncludes) {
+  auto &Ctx = ASTCtx.getASTContext();
+  auto &PP = ASTCtx.getPreprocessor();
+  Index->updatePreamble(testPath(Input.first()), "null", Ctx, PP,
+*CanonIncludes);
+});
 ParsedAST MainAST = TU.build();
 Index->updateMain(testPath(Input.first()), MainAST);
   }
Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -1129,9 +1129,9 @@
   public:
 BlockPreambleThread(llvm::StringRef BlockVersion, Notification &N)
 : BlockVersion(BlockVersion), N(N) {}
-void onPreambleAST(PathRef Path, llvm::StringRef Version,
-   const CompilerInvocation &, ASTContext &Ctx,
-   Preprocessor &, const CanonicalIncludes &) override {
+void
+onPreambleAST(PathRef Path, llvm::StringRef Version, CapturedASTCtx,
+  const std::shared_ptr) override {
   if (Version == BlockVersion)
 N.wait();
 }
@@ -1208,9 +1208,9 @@
 BlockPr

[PATCH] D150966: [clang] Don't define predefined macros multiple times

2023-05-19 Thread John Brawn via Phabricator via cfe-commits
john.brawn updated this revision to Diff 523785.
john.brawn added a comment.

Remove redundant braces, explain more in test comment.


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

https://reviews.llvm.org/D150966

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Basic/Targets/AVR.cpp
  clang/lib/Basic/Targets/CSKY.cpp
  clang/lib/Basic/Targets/Hexagon.cpp
  clang/lib/Basic/Targets/Le64.cpp
  clang/lib/Basic/Targets/MSP430.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/VE.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/Preprocessor/predefined-macros-no-warnings.c

Index: clang/test/Preprocessor/predefined-macros-no-warnings.c
===
--- /dev/null
+++ clang/test/Preprocessor/predefined-macros-no-warnings.c
@@ -0,0 +1,199 @@
+// Check that the predefined macros don't contain anything that causes a
+// warning, which needs -Wsystem-headers to detect as the predefined macros
+// are in the  file which is treated as a system header and so has
+// warnings suppressed by default.
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple arc
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple xcore
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple hexagon
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple hexagon-linux
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple lanai
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple aarch64_32-darwin
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple aarch64
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple aarch64-darwin
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple aarch64-cloudabi
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple aarch64-freebsd
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple aarch64-fuchsia
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple aarch64-linux
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple aarch64-linux-openhos
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple aarch64-netbsd
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple aarch64-openbsd
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple aarch64-win32-gnu
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple aarch64-win32-msvc
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple aarch64_be
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple aarch64_be-freebsd
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple aarch64_be-fuchsia
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple aarch64_be-linux
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple aarch64_be-netbsd
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple arm
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple arm-darwin
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple arm-cloudabi
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple arm-freebsd
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple arm-fuchsia
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple arm-linux
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple arm-linux-openhos
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple arm-liteos
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple arm-netbsd
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple arm-openbsd
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple arm-rtems
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple arm-nacl
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple arm-win32-cygnus
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple arm-win32-gnu
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple arm-win32-itanium
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple arm-win32-msvc
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple armeb
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple armeb-linux
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple armeb-freebsd
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple armeb-netbsd
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple armeb-openbsd
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple armeb-rtems
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple avr
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple bpfeb
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple bpfel
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple msp430
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple mips
+// RUN: %clang_cc1 %s -E -o - -Wsystem-headers -Werror -triple mips-li

[PATCH] D150948: [clang][RecoveryExpr] Fix a crash where a dependent type crahes on c-only code path.

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

LGTM, but this should have a release note for the fix. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150948

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


[PATCH] D150955: [clang][AST] Propagate the value-dependent bit for VAArgExpr.

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

LGTM assuming CI is okay with it -- the patch did not apply so precommit CI 
never ran. I'm surprised no tests break as a result of this because it changes 
both C and C++ behavior. The changes should have a release note, too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150955

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


[PATCH] D127910: [Clang][AArch64][SME] Add vector load/store (ld1/st1) intrinsics

2023-05-19 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen accepted this revision.
sdesmalen added a comment.

Thanks @bryanpkc this patch looks good to me now. I'll make some time to review 
the other patches in the series as well after you update them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127910

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


[clang] ba1f31f - [CLANG][AArch64][SVE2.1] Add UCLAMP/SCLAMP/FCLAMP function prototypes

2023-05-19 Thread Caroline Concatto via cfe-commits

Author: Caroline Concatto
Date: 2023-05-19T15:36:22Z
New Revision: ba1f31fb066af2769634ebb2e23d683d8d409f37

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

LOG: [CLANG][AArch64][SVE2.1] Add UCLAMP/SCLAMP/FCLAMP function prototypes

Submitting this patch in the name of: David Sherwood 

Reviewed By: sdesmalen

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

Added: 
clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_fclamp.c
clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_sclamp.c
clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_uclamp.c

Modified: 
clang/include/clang/Basic/arm_sve.td
llvm/include/llvm/TargetParser/AArch64TargetParser.h

Removed: 




diff  --git a/clang/include/clang/Basic/arm_sve.td 
b/clang/include/clang/Basic/arm_sve.td
index 8584e1741dac2..bd2db7ef17be8 100644
--- a/clang/include/clang/Basic/arm_sve.td
+++ b/clang/include/clang/Basic/arm_sve.td
@@ -2104,3 +2104,12 @@ def SVBEXT_N : SInst<"svbext[_n_{d}]", "dda", 
"UcUsUiUl", MergeNone, "aarch64_sv
 def SVBGRP   : SInst<"svbgrp[_{d}]",   "ddd", "UcUsUiUl", MergeNone, 
"aarch64_sve_bgrp_x">;
 def SVBGRP_N : SInst<"svbgrp[_n_{d}]", "dda", "UcUsUiUl", MergeNone, 
"aarch64_sve_bgrp_x">;
 }
+
+let TargetGuard = "sve2p1" in {
+def SVFCLAMP   : SInst<"svclamp[_{d}]", "", "hfd", MergeNone, 
"aarch64_sve_fclamp", [], []>;
+}
+
+let TargetGuard = "sve2p1" in {
+def SVSCLAMP : SInst<"svclamp[_{d}]", "", "csil", MergeNone, 
"aarch64_sve_sclamp", [], []>;
+def SVUCLAMP : SInst<"svclamp[_{d}]", "", "UcUsUiUl", MergeNone, 
"aarch64_sve_uclamp", [], []>;
+}

diff  --git a/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_fclamp.c 
b/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_fclamp.c
new file mode 100644
index 0..e7085c94b255c
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_fclamp.c
@@ -0,0 +1,64 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve2p1 \
+// RUN:   -S -Werror -emit-llvm -disable-O0-optnone -o - %s | opt -S -p 
mem2reg,instcombine,tailcallelim | FileCheck %s
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu 
-target-feature +sve2p1 \
+// RUN:   -S -Werror -emit-llvm -disable-O0-optnone -o - %s | opt -S -p 
mem2reg,instcombine,tailcallelim | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve2p1 \
+// RUN:   -S -Werror -emit-llvm -disable-O0-optnone -o - -x c++ %s | opt -S -p 
mem2reg,instcombine,tailcallelim | FileCheck %s -check-prefix=CPP-CHECK
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu 
-target-feature +sve2p1 \
+// RUN:   -S -Werror -emit-llvm -disable-O0-optnone -o - -x c++ %s | opt -S -p 
mem2reg,instcombine,tailcallelim | FileCheck %s -check-prefix=CPP-CHECK
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve2p1 \
+// RUN:   -S -disable-O0-optnone -Werror -Wall -o /dev/null %s
+
+#include 
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1, A2_UNUSED, A3, A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1, A2, A3, A4) A1##A2##A3##A4
+#endif
+
+// CHECK-LABEL: @test_svclamp_f16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  
@llvm.aarch64.sve.fclamp.nxv8f16( [[OP1:%.*]],  [[OP2:%.*]],  [[OP3:%.*]])
+// CHECK-NEXT:ret  [[TMP0]]
+//
+// CPP-CHECK-LABEL: 
@_Z16test_svclamp_f16u13__SVFloat16_tu13__SVFloat16_tu13__SVFloat16_t(
+// CPP-CHECK-NEXT:  entry:
+// CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call  
@llvm.aarch64.sve.fclamp.nxv8f16( [[OP1:%.*]],  [[OP2:%.*]],  [[OP3:%.*]])
+// CPP-CHECK-NEXT:ret  [[TMP0]]
+//
+svfloat16_t test_svclamp_f16(svfloat16_t op1, svfloat16_t op2, svfloat16_t 
op3) {
+  return SVE_ACLE_FUNC(svclamp, _f16, , )(op1, op2, op3);
+}
+
+// CHECK-LABEL: @test_svclamp_f32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  
@llvm.aarch64.sve.fclamp.nxv4f32( [[OP1:%.*]],  [[OP2:%.*]],  [[OP3:%.*]])
+// CHECK-NEXT:ret  [[TMP0]]
+//
+// CPP-CHECK-LABEL: 
@_Z16test_svclamp_f32u13__SVFloat32_tu13__SVFloat32_tu13__SVFloat32_t(
+// CPP-CHECK-NEXT:  entry:
+// CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call  
@llvm.aarch64.sve.fclamp.nxv4f32( [[OP1:%.*]],  [[OP2:%.*]],  [[OP3:%.*]])
+// CPP-CHECK-NEXT:ret  [[TMP0]]
+//
+svfloat32_t test_svclamp_f32(svfloat32_t op1, svfloat32_t op2, svfloat32_t 
op3) {
+  return SVE_ACLE_FUNC(svclamp, _f32, , )(op1, op2, op3);
+}
+
+// CHECK-LABEL: @test_svclamp_f64(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  
@llvm.aarch64.sve.fclamp.nxv

[PATCH] D150863: [CLANG][AArch64][SVE2.1] Add UCLAMP/SCLAMP/FCLAMP function prototypes

2023-05-19 Thread Caroline via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGba1f31fb066a: [CLANG][AArch64][SVE2.1] Add 
UCLAMP/SCLAMP/FCLAMP function prototypes (authored by CarolineConcatto).

Changed prior to commit:
  https://reviews.llvm.org/D150863?vs=523343&id=523793#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150863

Files:
  clang/include/clang/Basic/arm_sve.td
  clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_fclamp.c
  clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_sclamp.c
  clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_uclamp.c
  llvm/include/llvm/TargetParser/AArch64TargetParser.h

Index: llvm/include/llvm/TargetParser/AArch64TargetParser.h
===
--- llvm/include/llvm/TargetParser/AArch64TargetParser.h
+++ llvm/include/llvm/TargetParser/AArch64TargetParser.h
@@ -253,7 +253,7 @@
 {"sve2-sha3", AArch64::AEK_SVE2SHA3, "+sve2-sha3", "-sve2-sha3", FEAT_SVE_SHA3, "+sve2,+sve,+sve2-sha3,+fullfp16,+fp-armv8,+neon", 410},
 {"sve2-sm4", AArch64::AEK_SVE2SM4, "+sve2-sm4", "-sve2-sm4", FEAT_SVE_SM4, "+sve2,+sve,+sve2-sm4,+fullfp16,+fp-armv8,+neon", 420},
 {"sve2", AArch64::AEK_SVE2, "+sve2", "-sve2", FEAT_SVE2, "+sve2,+sve,+fullfp16,+fp-armv8,+neon", 370},
-{"sve2p1", AArch64::AEK_SVE2p1, "+sve2p1", "-sve2p1", FEAT_MAX, "", 0},
+{"sve2p1", AArch64::AEK_SVE2p1, "+sve2p1", "-sve2p1", FEAT_MAX, "+sve2p1,+sve2,+sve,+fullfp16,+fp-armv8,+neon", 0},
 {"the", AArch64::AEK_THE, "+the", "-the", FEAT_MAX, "", 0},
 {"tme", AArch64::AEK_TME, "+tme", "-tme", FEAT_MAX, "", 0},
 {"wfxt", AArch64::AEK_NONE, {}, {}, FEAT_WFXT, "+wfxt", 550},
Index: clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_uclamp.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_uclamp.c
@@ -0,0 +1,78 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve2p1 \
+// RUN:   -S -Werror -emit-llvm -disable-O0-optnone -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve2p1 \
+// RUN:   -S -Werror -emit-llvm -disable-O0-optnone -o - %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve2p1 \
+// RUN:   -S -Werror -emit-llvm -disable-O0-optnone -o - -x c++ %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s -check-prefix=CPP-CHECK
+// RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve2p1 \
+// RUN:   -S -Werror -emit-llvm -disable-O0-optnone -o - -x c++ %s | opt -S -p mem2reg,instcombine,tailcallelim | FileCheck %s -check-prefix=CPP-CHECK
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve2p1 \
+// RUN:   -S -disable-O0-optnone -Werror -Wall -o /dev/null %s
+
+#include 
+
+#ifdef SVE_OVERLOADED_FORMS
+// A simple used,unused... macro, long enough to represent any SVE builtin.
+#define SVE_ACLE_FUNC(A1, A2_UNUSED, A3, A4_UNUSED) A1##A3
+#else
+#define SVE_ACLE_FUNC(A1, A2, A3, A4) A1##A2##A3##A4
+#endif
+
+// CHECK-LABEL: @test_svclamp_u8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.uclamp.nxv16i8( [[OP1:%.*]],  [[OP2:%.*]],  [[OP3:%.*]])
+// CHECK-NEXT:ret  [[TMP0]]
+//
+// CPP-CHECK-LABEL: @_Z15test_svclamp_u8u11__SVUint8_tu11__SVUint8_tu11__SVUint8_t(
+// CPP-CHECK-NEXT:  entry:
+// CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.uclamp.nxv16i8( [[OP1:%.*]],  [[OP2:%.*]],  [[OP3:%.*]])
+// CPP-CHECK-NEXT:ret  [[TMP0]]
+//
+svuint8_t test_svclamp_u8(svuint8_t op1, svuint8_t op2, svuint8_t op3) {
+  return SVE_ACLE_FUNC(svclamp, _u8, , )(op1, op2, op3);
+}
+
+// CHECK-LABEL: @test_svclamp_u16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.uclamp.nxv8i16( [[OP1:%.*]],  [[OP2:%.*]],  [[OP3:%.*]])
+// CHECK-NEXT:ret  [[TMP0]]
+//
+// CPP-CHECK-LABEL: @_Z16test_svclamp_u16u12__SVUint16_tu12__SVUint16_tu12__SVUint16_t(
+// CPP-CHECK-NEXT:  entry:
+// CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.uclamp.nxv8i16( [[OP1:%.*]],  [[OP2:%.*]],  [[OP3:%.*]])
+// CPP-CHECK-NEXT:ret  [[TMP0]]
+//
+svuint16_t test_svclamp_u16(svuint16_t op1, svuint16_t op2, svuint16_t op3) {
+  return SVE_ACLE_FUNC(svclamp, _u16, , )(op1, op2, op3);
+}
+
+// CHECK-LABEL: @test_svclamp_u32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  @llvm.aarch64.sve.uclamp.nxv4i32( [[OP1:%.*]],  [[OP2:%.*]],  [[OP3:%.*]])
+// CHECK-NEXT:ret  [[TMP0]]
+//
+// CPP-CHECK-LABEL: @_Z16test_svclamp_u32u12__SVUint32_tu12__SVUint32

[PATCH] D148088: [RFC][clangd] Move preamble index out of document open critical path

2023-05-19 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/ClangdServer.cpp:90
+if (Tasks) {
+  std::unique_lock Lock(*Barrier, std::try_to_lock);
+  Tasks->runAsync("task:" + Path + Version, std::move(Task));

DmitryPolukhin wrote:
> kadircet wrote:
> > what's the point of this semaphore, if we're only going to `try_to_lock`? 
> > this should be done in the `Task` that we're passing to the `Tasks`.
> > 
> > but more importantly, this is going to be a change in behavior, before this 
> > patch we had one preamble thread per open file and they'll run indexing (in 
> > addition to preamble builds) without any throttling.
> > 
> > if we limit number of indexig tasks to 1, we'll need a queue to ensure 
> > progress for every file. semaphore won't be fair especially in the face of 
> > contention, we'll also likely handle requests out-of-order (which is 
> > redundant but OK correctness-wise as our file-index already accounts for 
> > that).
> > 
> > hence I don't think there's any reason to change behaviour here until we 
> > see some issues with contention (which I believe is unlikely as we can 
> > still only issue preamble indexing requests as quick as we can build 
> > preambles, and the latter is slower than the former).
> > we can still only issue preamble indexing requests as quick as we can build 
> > preambles, and the latter is slower than the former
> 
> Preamble compliation is not always slower than indexing. For example, if 
> modules are actively used, compilation itself can be very fast but indexing 
> is slow. Said that, I think we can eliminate the semaphore if there is no 
> good reason to keep it.
> For example, if modules are actively used, compilation itself can be very 
> fast but indexing is slow. 

You're right, but that's a mode of operation that incidentally works in clangd 
as we discussed before.

> I think we can eliminate the semaphore if there is no good reason to keep it.

As mentioned above I don't think we have good enough reasons to have some 
throttling here, and even if we did, I don't think we can achieve it with a 
semaphore cheaply, we probably need a queue and multiple consumers to at least 
ensure forward progress on every file.



Comment at: clang-tools-extra/clangd/Preamble.cpp:698-700
+  // While extending the life of FileMgr and VFS, StatCache should also be
+  // extended.
+  Ctx.setStatCache(Result->StatCache);

kuganv wrote:
> kadircet wrote:
> > we use a "producingfs" when building the preamble, hence there shouldn't be 
> > any references to statcache inside the FM&VFS stored in the compiler 
> > instance here. have you noticed something to the contrary ?
> > we use a "producingfs" when building the preamble, hence there shouldn't be 
> > any references to statcache inside the FM&VFS stored in the compiler 
> > instance here. have you noticed something to the contrary ?
> 
> 
> In PrecompiledPreamble::Build, we use StatCacheFS for FileMgr creation. 
> Shouldn’t we keep this Alive? Without this, I am seeing:
> 
> ```
> ==1509807==ERROR: AddressSanitizer: heap-use-after-free on address 
> 0x606000464c00 at pc 0x55f558fd7de2 bp 0x7f18a73ff010 sp 0x7f18a73ff008
> READ of size 8 at 0x606000464c00 thread T48 (NodeServer.cpp1)
> V[23:14:41.667] Ignored diagnostic. 
> /data/users/kugan/fbsource/fbcode/synapse_dev/prod/NodeServer.cpp:2:2:Mandatory
>  header  not found in standard library!
> I[23:14:41.669] Indexed c++20 standard library (incomplete due to errors): 0 
> symbols, 0 filtered
> #0 0x55f558fd7de1 in std::__cxx11::basic_string std::char_traits, std::allocator>::_M_data() const 
> /opt/rh/gcc-toolset-12/root/usr/lib/gcc/x86_64-redhat-linux/12/../../../../include/c++/12/bits/basic_string.h:234:28
> #1 0x55f558fd7de1 in std::__cxx11::basic_string std::char_traits, std::allocator>::data() const 
> /opt/rh/gcc-toolset-12/root/usr/lib/gcc/x86_64-redhat-linux/12/../../../../include/c++/12/bits/basic_string.h:2567:16
> #2 0x55f558fd7de1 in 
> llvm::StringRef::StringRef(std::__cxx11::basic_string std::char_traits, std::allocator> const&) 
> /home/kugan/local/llvm-project/llvm/include/llvm/ADT/StringRef.h:101:18
> #3 0x55f558fd7de1 in 
> clang::clangd::PreambleFileStatusCache::update(llvm::vfs::FileSystem const&, 
> llvm::vfs::Status) 
> /home/kugan/local/llvm-project/clang-tools-extra/clangd/FS.cpp:33:20
> #4 0x55f558fd925f in 
> clang::clangd::PreambleFileStatusCache::getProducingFS(llvm::IntrusiveRefCntPtr)::CollectFS::status(llvm::Twine
>  const&) /home/kugan/local/llvm-project/clang-tools-extra/clangd/FS.cpp:82:19
> #5 0x55f55917ddee in clang::clangd::(anonymous 
> namespace)::TimerFS::status(llvm::Twine const&) 
> /home/kugan/local/llvm-project/clang-tools-extra/clangd/Preamble.cpp:492:30
> #6 0x55f55670dcff in clang::FileSystemStatCache::get(llvm::StringRef, 
> llvm::vfs::Status&, bool, std::unique_ptr std::default_delete>*, clang::F

[PATCH] D150966: [clang] Don't define predefined macros multiple times

2023-05-19 Thread John Brawn via Phabricator via cfe-commits
john.brawn updated this revision to Diff 523803.
john.brawn marked 2 inline comments as done.
john.brawn added a comment.

Send test output to /dev/null


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

https://reviews.llvm.org/D150966

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/ARM.cpp
  clang/lib/Basic/Targets/AVR.cpp
  clang/lib/Basic/Targets/CSKY.cpp
  clang/lib/Basic/Targets/Hexagon.cpp
  clang/lib/Basic/Targets/Le64.cpp
  clang/lib/Basic/Targets/MSP430.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/VE.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/Preprocessor/predefined-macros-no-warnings.c

Index: clang/test/Preprocessor/predefined-macros-no-warnings.c
===
--- /dev/null
+++ clang/test/Preprocessor/predefined-macros-no-warnings.c
@@ -0,0 +1,199 @@
+// Check that the predefined macros don't contain anything that causes a
+// warning, which needs -Wsystem-headers to detect as the predefined macros
+// are in the  file which is treated as a system header and so has
+// warnings suppressed by default.
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple arc
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple xcore
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple hexagon
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple hexagon-linux
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple lanai
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple aarch64_32-darwin
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple aarch64
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple aarch64-darwin
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple aarch64-cloudabi
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple aarch64-freebsd
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple aarch64-fuchsia
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple aarch64-linux
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple aarch64-linux-openhos
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple aarch64-netbsd
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple aarch64-openbsd
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple aarch64-win32-gnu
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple aarch64-win32-msvc
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple aarch64_be
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple aarch64_be-freebsd
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple aarch64_be-fuchsia
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple aarch64_be-linux
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple aarch64_be-netbsd
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple arm
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple arm-darwin
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple arm-cloudabi
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple arm-freebsd
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple arm-fuchsia
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple arm-linux
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple arm-linux-openhos
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple arm-liteos
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple arm-netbsd
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple arm-openbsd
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple arm-rtems
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple arm-nacl
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple arm-win32-cygnus
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple arm-win32-gnu
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple arm-win32-itanium
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple arm-win32-msvc
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple armeb
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple armeb-linux
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple armeb-freebsd
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple armeb-netbsd
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple armeb-openbsd
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem-headers -Werror -triple armeb-rtems
+// RUN: %clang_cc1 %s -E -o /dev/null -Wsystem

[PATCH] D150966: [clang] Don't define predefined macros multiple times

2023-05-19 Thread John Brawn via Phabricator via cfe-commits
john.brawn added a comment.

In D150966#4356403 , @barannikov88 
wrote:

> Is it possible/worth to add an assertion to Builder.defineMacro to enforce 
> this one definition rule?

It just appends a string to a raw_ostream, so it's not possible to check what's 
previously been written.

In D150966#4356470 , @barannikov88 
wrote:

> Q: What is it the -Wsystem-header can warn about? I mean, no system header is 
> included by the test, what can go wrong?

The  buffer is treated as a system header. I've expanded on the 
comment to explain this more.


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

https://reviews.llvm.org/D150966

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


[PATCH] D150887: [clang] Convert a few tests to opaque pointers

2023-05-19 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added inline comments.



Comment at: clang/test/CodeGenCXX/const-init-cxx11.cpp:353
   };
-  // CHECK: @_ZN14VirtualMembersL13sGlobalMemoryE = internal global { i8** } { 
i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* 
@_ZTVN14VirtualMembers12nsMemoryImplE, i32 0, inrange i32 0, i32 2) }
+  // CHECK: @_ZN14VirtualMembersL13sGlobalMemoryE = internal global 
%"struct.VirtualMembers::nsMemoryImpl" { ptr getelementptr inbounds ({ [3 x 
ptr] }, ptr @_ZTVN14VirtualMembers12nsMemoryImplE, i32 0, inrange i32 0, i32 2) 
}
   __attribute__((used))

nikic wrote:
> barannikov88 wrote:
> > This was one suspicious change. An anonymous struct became named.
> > 
> Not sure why exactly this happened, but should be harmless. I believe we 
> sometimes generate anon structs for initializaton because the types used for 
> initialization are not always compatible with the nominal LLVM memory type -- 
> I guess there previously was a mismatch in pointer types here or something.
This is where the behavior diverges:
```
llvm::Constant *ConstantAggregateBuilder::buildFrom(
CodeGenModule &CGM, ArrayRef Elems,
ArrayRef Offsets, CharUnits StartOffset, CharUnits Size,
bool NaturalLayout, llvm::Type *DesiredTy, bool AllowOversized) {
...
  // Pick the type to use.  If the type is layout identical to the desired
  // type then use it, otherwise use whatever the builder produced for us.
  if (llvm::StructType *DesiredSTy = dyn_cast(DesiredTy)) {
if (DesiredSTy->isLayoutIdentical(STy))
  STy = DesiredSTy;
  }
...
```
With typed pointers, STy and DesiredSTy respectively are:
```
{ i8** }
%struct.nsMemoryImpl = type { i32 (...)** }
```
`isLayoutIdentical`, despite its name, actually checks for full equivalence of 
structs, not just the layout. That is, it is no different from `operator==`.

The code snippet above is the only use of `isLayoutIdentical`.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150887

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


[PATCH] D124349: [analyzer] Get direct binding for specific punned case

2023-05-19 Thread Domján Dániel via Phabricator via cfe-commits
isuckatcs added inline comments.



Comment at: clang/test/Analysis/array-punned-region.c:23
+  BITFIELD_CAST *pff = &ff;
+  int a = *((int *)pff + 2); // expected-warning{{Assigned value is garbage or 
undefined [core.uninitialized.Assign]}}
+  return a;

@steakhal @martong @NoQ 

Isn't this actually a false positive here?

`(int *)pff + 2` points to `ff.b[1]`, which is initialized to `0`. 

https://godbolt.org/z/Gh8a4aMe8







Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124349

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


[PATCH] D150930: [Driver] Accept and ignore -fno-lifetime-dse argument

2023-05-19 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D150930#4355240 , @MaskRay wrote:

> Note: for options controlling individual optimization behaviors, there is a 
> large probability that they may not make sense for Clang since the two 
> compilers' internals are so different. 
> Users and projects should learn to not add GCC optimization options for Clang 
> uses.

If this is the case, can we at least add a CMake option to disable LLVM from 
enabling this option against the user's will? As it stands 
https://reviews.llvm.org/rG47f5c54f997a59bb2c65abe6b8b811f6e7553456 represents 
a significant regression in usability. As I understand, the previous patch only 
had an issue with LTO builds, so it should be perfectly reasonable for users to 
at least disable this at the LLVM level if they do not with the LLVM build to 
insert an incompatible flag into their compilation database.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150930

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


[clang] 78d8312 - [Clang][clang-cl] Implement `__builtin_FUNCSIG`

2023-05-19 Thread Aaron Ballman via cfe-commits

Author: Jakub Mazurkiewicz
Date: 2023-05-19T12:02:44-04:00
New Revision: 78d8312acea96f58f13a876f98d241590c16d530

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

LOG: [Clang][clang-cl] Implement `__builtin_FUNCSIG`

This patch implements __builtin_FUNCSIG intrinsic which returns the same string 
as __FUNCSIG__.

Fixes https://github.com/llvm/llvm-project/issues/58951
Differential Revision: https://reviews.llvm.org/D150183

Added: 


Modified: 
clang/docs/LanguageExtensions.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/Expr.h
clang/include/clang/Basic/TokenKinds.def
clang/include/clang/Sema/Sema.h
clang/lib/AST/Expr.cpp
clang/lib/Parse/ParseExpr.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/Preprocessor/feature_tests.c
clang/test/Preprocessor/feature_tests.cpp
clang/test/Sema/source_location.c
clang/test/SemaCXX/source_location.cpp

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 632a5cf1a7d02..5b186c4f81774 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -3711,7 +3711,7 @@ Source location builtins
 
 Clang provides builtins to support C++ standard library implementation
 of ``std::source_location`` as specified in C++20.  With the exception
-of ``__builtin_COLUMN`` and ``__builtin_FILE_NAME``,
+of ``__builtin_COLUMN``, ``__builtin_FILE_NAME`` and ``__builtin_FUNCSIG``,
 these builtins are also implemented by GCC.
 
 **Syntax**:
@@ -3721,6 +3721,7 @@ these builtins are also implemented by GCC.
   const char *__builtin_FILE();
   const char *__builtin_FILE_NAME(); // Clang only
   const char *__builtin_FUNCTION();
+  const char *__builtin_FUNCSIG(); // Microsoft
   unsigned__builtin_LINE();
   unsigned__builtin_COLUMN(); // Clang only
   const std::source_location::__impl *__builtin_source_location();
@@ -3750,11 +3751,12 @@ these builtins are also implemented by GCC.
 
 **Description**:
 
-The builtins ``__builtin_LINE``, ``__builtin_FUNCTION``, ``__builtin_FILE`` and
-``__builtin_FILE_NAME`` return the values, at the "invocation point", for
-``__LINE__``, ``__FUNCTION__``, ``__FILE__`` and ``__FILE_NAME__`` 
respectively.
-``__builtin_COLUMN`` similarly returns the column,
-though there is no corresponding macro. These builtins are constant 
expressions.
+The builtins ``__builtin_LINE``, ``__builtin_FUNCTION``, ``__builtin_FUNCSIG``,
+``__builtin_FILE`` and ``__builtin_FILE_NAME`` return the values, at the
+"invocation point", for ``__LINE__``, ``__FUNCTION__``, ``__FUNCSIG__``,
+``__FILE__`` and ``__FILE_NAME__`` respectively. ``__builtin_COLUMN`` similarly
+returns the column, though there is no corresponding macro. These builtins are
+constant expressions.
 
 When the builtins appear as part of a default function argument the invocation
 point is the location of the caller. When the builtins appear as part of a

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 1dd3d8a0ed80c..9bcc17b0c5ff8 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -198,6 +198,9 @@ Non-comprehensive list of changes in this release
   ``memcmp(&lhs, &rhs, sizeof(T)) == 0``.
 - Clang now ignores null directives outside of the include guard when deciding
   whether a file can be enabled for the multiple-include optimization.
+- Clang now support ``__builtin_FUNCSIG()`` which retruns the same information
+  as the ``__FUNCSIG__`` macro (available only with ``-fms-extensions`` flag).
+  This fixes (`#58951 `_).
 
 New Compiler Flags
 --

diff  --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index db4316d8faf1f..22cbf23ac2a4c 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -4691,14 +4691,22 @@ class VAArgExpr : public Expr {
 };
 
 /// Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(),
-/// __builtin_FUNCTION(), __builtin_FILE(), __builtin_FILE_NAME(),
-/// or __builtin_source_location().
+/// __builtin_FUNCTION(), __builtin_FUNCSIG(), __builtin_FILE(),
+/// __builtin_FILE_NAME() or __builtin_source_location().
 class SourceLocExpr final : public Expr {
   SourceLocation BuiltinLoc, RParenLoc;
   DeclContext *ParentContext;
 
 public:
-  enum IdentKind { Function, File, FileName, Line, Column, SourceLocStruct };
+  enum IdentKind {
+Function,
+FuncSig,
+File,
+FileName,
+Line,
+Column,
+SourceLocStruct
+  };
 
   SourceLocExpr(const ASTContext &Ctx, IdentKind Type, QualType ResultTy,
 SourceLocation BLoc, SourceLocation RParenLoc,
@@ -4724,6 +4732,7 @@ class SourceLocExpr final : public Expr {
 case 

[PATCH] D150183: [Clang][clang-cl] Implement `__builtin_FUNCSIG`

2023-05-19 Thread Aaron Ballman 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 rG78d8312acea9: [Clang][clang-cl] Implement 
`__builtin_FUNCSIG` (authored by JMazurkiewicz, committed by aaron.ballman).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150183

Files:
  clang/docs/LanguageExtensions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/Expr.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Expr.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Preprocessor/feature_tests.c
  clang/test/Preprocessor/feature_tests.cpp
  clang/test/Sema/source_location.c
  clang/test/SemaCXX/source_location.cpp

Index: clang/test/SemaCXX/source_location.cpp
===
--- clang/test/SemaCXX/source_location.cpp
+++ clang/test/SemaCXX/source_location.cpp
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fexceptions -verify %s
 // RUN: %clang_cc1 -std=c++2a -fcxx-exceptions -DUSE_CONSTEVAL -fexceptions -verify %s
+// RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fms-extensions -DMS -fexceptions -verify %s
+// RUN: %clang_cc1 -std=c++2a -fcxx-exceptions -fms-extensions -DMS -DUSE_CONSTEVAL -fexceptions -verify %s
 // expected-no-diagnostics
 
 #define assert(...) ((__VA_ARGS__) ? ((void)0) : throw 42)
@@ -86,6 +88,9 @@
 static_assert(is_same);
 static_assert(is_same);
 static_assert(is_same);
+#ifdef MS
+static_assert(is_same);
+#endif
 static_assert(is_same);
 
 // test noexcept
@@ -94,6 +99,9 @@
 static_assert(noexcept(__builtin_FILE()));
 static_assert(noexcept(__builtin_FILE_NAME()));
 static_assert(noexcept(__builtin_FUNCTION()));
+#ifdef MS
+static_assert(noexcept(__builtin_FUNCSIG()));
+#endif
 static_assert(noexcept(__builtin_source_location()));
 
 //===--===//
@@ -450,6 +458,57 @@
 
 } // namespace test_func
 
+//===--===//
+//__builtin_FUNCSIG()
+//===--===//
+
+#ifdef MS
+namespace test_funcsig {
+
+constexpr const char *test_funcsig_simple(const char *f = __builtin_FUNCSIG()) {
+  return f;
+}
+constexpr const char *get_funcsig() {
+  return __FUNCSIG__;
+}
+constexpr bool test_funcsig() {
+  return is_equal(__FUNCSIG__, test_funcsig_simple()) &&
+ !is_equal(get_funcsig(), test_funcsig_simple());
+}
+static_assert(test_funcsig());
+
+template 
+constexpr Pair test_funcsig_template(T, const char* f = __builtin_FUNCSIG()) {
+  return {f, __builtin_FUNCSIG()};
+}
+template 
+void func_template_tests() {
+  constexpr auto P = test_funcsig_template(42);
+  static_assert(is_equal(P.first, __FUNCSIG__), "");
+  static_assert(!is_equal(P.second, __FUNCSIG__), "");
+}
+template void func_template_tests();
+
+template 
+struct TestCtor {
+  T funcsig = __builtin_FUNCSIG();
+  T ctor_funcsig;
+  TestCtor() = default;
+  template 
+  constexpr TestCtor(int, F f = __builtin_FUNCSIG()) : ctor_funcsig(f) {}
+};
+void ctor_tests() {
+  constexpr TestCtor<> Template{42};
+  static_assert(is_equal(Template.funcsig, "__cdecl test_funcsig::TestCtor<>::TestCtor(int, F) [T = const char *, F = const char *]"));
+  static_assert(is_equal(Template.ctor_funcsig, __FUNCSIG__));
+}
+
+constexpr const char* global_funcsig = __builtin_FUNCSIG();
+static_assert(is_equal(global_funcsig, ""));
+
+} // namespace test_funcsig
+#endif
+
 //===--===//
 //__builtin_COLUMN()
 //===--===//
Index: clang/test/Sema/source_location.c
===
--- clang/test/Sema/source_location.c
+++ clang/test/Sema/source_location.c
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -std=c90 -fconst-strings -DCONST_STRINGS -verify %s
 // RUN: %clang_cc1 -std=c90 -verify %s
+// RUN: %clang_cc1 -std=c90 -fms-extensions -DMS -fconst-strings -DCONST_STRINGS -verify %s
+// RUN: %clang_cc1 -std=c90 -fms-extensions -DMS -verify %s
 
 // expected-no-diagnostics
 
@@ -13,6 +15,9 @@
 #ifndef CONST_STRINGS
 char *const NCFILE = __builtin_FILE();
 char *const NCFUNC = __builtin_FUNCTION();
+#ifdef MS
+char *const NCFNSG = __builtin_FUNCSIG();
+#endif
 #endif
 
 #ifdef CONST_STRINGS
@@ -20,6 +25,9 @@
 _Static_assert(IsEqual(__builtin_FILE_NAME(), __FILE_NAME__), "");
 _Static_assert(__builtin_LINE() == __LINE__, "");
 _Static_assert(IsEqual("", __builtin_FUNCTION()), "");
+#ifdef MS
+_Static_assert(IsEqual("", __builtin_FUNCSIG()), "");
+#endif
 
 #line 42 "my_file.c"
 _Static_assert(__builtin_LINE() == 42, "");
@@ -30,5 +38,8 @@
 
 void fo

[PATCH] D150978: [clang][Sema] Add CodeCompletionContext::CCC_ObjCClassForwardDecl

2023-05-19 Thread David Goldman via Phabricator via cfe-commits
dgoldman created this revision.
dgoldman added a reviewer: kadircet.
Herald added a subscriber: arphaman.
Herald added a project: All.
dgoldman requested review of this revision.
Herald added subscribers: cfe-commits, ilya-biryukov.
Herald added projects: clang, clang-tools-extra.

- Use this new context in Sema to limit completions to seen ObjC class names

- Use this new context in clangd to disable include insertions when completing 
ObjC forward decls


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150978

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang/include/clang/Sema/CodeCompleteConsumer.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Parse/ParseObjc.cpp
  clang/lib/Sema/CodeCompleteConsumer.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/tools/libclang/CIndexCodeCompletion.cpp

Index: clang/tools/libclang/CIndexCodeCompletion.cpp
===
--- clang/tools/libclang/CIndexCodeCompletion.cpp
+++ clang/tools/libclang/CIndexCodeCompletion.cpp
@@ -537,6 +537,7 @@
 case CodeCompletionContext::CCC_Other:
 case CodeCompletionContext::CCC_ObjCInterface:
 case CodeCompletionContext::CCC_ObjCImplementation:
+case CodeCompletionContext::CCC_ObjCClassForwardDecl:
 case CodeCompletionContext::CCC_NewName:
 case CodeCompletionContext::CCC_MacroName:
 case CodeCompletionContext::CCC_PreprocessorExpression:
Index: clang/lib/Sema/SemaCodeComplete.cpp
===
--- clang/lib/Sema/SemaCodeComplete.cpp
+++ clang/lib/Sema/SemaCodeComplete.cpp
@@ -8460,6 +8460,24 @@
 Results.data(), Results.size());
 }
 
+void Sema::CodeCompleteObjCClassForwardDecl(Scope *S) {
+  ResultBuilder Results(*this, CodeCompleter->getAllocator(),
+CodeCompleter->getCodeCompletionTUInfo(),
+CodeCompletionContext::CCC_ObjCClassForwardDecl);
+  Results.EnterNewScope();
+
+  if (CodeCompleter->includeGlobals()) {
+// Add all classes.
+AddInterfaceResults(Context.getTranslationUnitDecl(), CurContext, false,
+false, Results);
+  }
+
+  Results.ExitScope();
+
+  HandleCodeCompleteResults(this, CodeCompleter, Results.getCompletionContext(),
+Results.data(), Results.size());
+}
+
 void Sema::CodeCompleteObjCSuperclass(Scope *S, IdentifierInfo *ClassName,
   SourceLocation ClassNameLoc) {
   ResultBuilder Results(*this, CodeCompleter->getAllocator(),
Index: clang/lib/Sema/CodeCompleteConsumer.cpp
===
--- clang/lib/Sema/CodeCompleteConsumer.cpp
+++ clang/lib/Sema/CodeCompleteConsumer.cpp
@@ -83,6 +83,7 @@
   case CCC_ObjCCategoryName:
   case CCC_IncludedFile:
   case CCC_Attribute:
+  case CCC_ObjCClassForwardDecl:
 return false;
   }
 
@@ -166,6 +167,8 @@
 return "Attribute";
   case CCKind::CCC_Recovery:
 return "Recovery";
+  case CCKind::CCC_ObjCClassForwardDecl:
+return "ObjCClassForwardDecl";
   }
   llvm_unreachable("Invalid CodeCompletionContext::Kind!");
 }
Index: clang/lib/Parse/ParseObjc.cpp
===
--- clang/lib/Parse/ParseObjc.cpp
+++ clang/lib/Parse/ParseObjc.cpp
@@ -153,6 +153,11 @@
 
   while (true) {
 MaybeSkipAttributes(tok::objc_class);
+if (Tok.is(tok::code_completion)) {
+  cutOffParsing();
+  Actions.CodeCompleteObjCClassForwardDecl(getCurScope());
+  return Actions.ConvertDeclToDeclGroup(nullptr);
+}
 if (expectIdentifier()) {
   SkipUntil(tok::semi);
   return Actions.ConvertDeclToDeclGroup(nullptr);
Index: clang/lib/Frontend/ASTUnit.cpp
===
--- clang/lib/Frontend/ASTUnit.cpp
+++ clang/lib/Frontend/ASTUnit.cpp
@@ -322,6 +322,7 @@
   if (ID->getDefinition())
 Contexts |= (1LL << CodeCompletionContext::CCC_Expression);
   Contexts |= (1LL << CodeCompletionContext::CCC_ObjCInterfaceName);
+  Contexts |= (1LL << CodeCompletionContext::CCC_ObjCClassForwardDecl);
 }
 
 // Deal with tag names.
@@ -2027,6 +2028,7 @@
   case CodeCompletionContext::CCC_IncludedFile:
   case CodeCompletionContext::CCC_Attribute:
   case CodeCompletionContext::CCC_NewName:
+  case CodeCompletionContext::CCC_ObjCClassForwardDecl:
 // We're looking for nothing, or we're looking for names that cannot
 // be hidden.
 return;
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -13417,6 +13417,7 @@
  ArrayRef Protocols);
   void CodeCompleteObjCProtocolDecl(Scope *S);
   void CodeCompleteObjC

[PATCH] D150966: [clang] Don't define predefined macros multiple times

2023-05-19 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added a comment.

In D150966#4356695 , @john.brawn 
wrote:

>> Q: What is it the -Wsystem-header can warn about? I mean, no system header 
>> is included by the test, what can go wrong?
>
> The  buffer is treated as a system header. I've expanded on the 
> comment to explain this more.

Thanks, I didn't know that  is treated as a system header, but I was 
mostly interested in this part

  Check that the predefined macros don't contain anything that causes a warning

What is 'anything', exactly? Does it include duplicate predefined macros, or it 
tests something else?
Sorry for the silly question.


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

https://reviews.llvm.org/D150966

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


[PATCH] D144509: [CMake] Bumps minimum version to 3.20.0.

2023-05-19 Thread Mark de Wever via Phabricator via cfe-commits
Mordante added a comment.

In D144509#4356160 , @hans wrote:

> In D144509#4350052 , @Mordante 
> wrote:
>
>> In D144509#4349921 , @thakis wrote:
>>
>>> Reverted this and follow-ups in d763c6e5e2d0a6b34097aa7dabca31e9aff9b0b6 
>>>  for 
>>> now.
>>>
>>> Sorry this is such a pain to land :(
>>>
>>> (See also discussion over in D150688 )
>>
>> I'm not happy that the patch needs to be reverted again.
>>
>> It has taken me a lot of time to contact all buildbots maintainers to get 
>> all buildbots updated to the minimal CMake requirement.
>
> I sympathize with this, but I still believe reverting in these situations is 
> the right thing to do. It reduces disruption for everyone who needs their 
> builds to keep working, while allowing the failures to be investigated 
> without the pressure of knowing that head is currently broken. That this 
> patch has been hard to land is in the nature of the change itself.

I'm caught quite off-guard that it seems the LLVM buildbots don't cover our 
Windows support that well. It would also be great to know how we can improve 
the process to update dependency versions. The current way does not really 
encourage me to propose LLVM wide updates again.

>> Now that they are updated it turned out that one of the two last updated 
>> bots has an issue with this patch and that has been fixed. But now it seems 
>> to break Chromium. I don't have access to Windows so I don't know how I can 
>> test patches.
>
> I'm happy to test patches on my Windows machine.

Thanks!

>> Do you have a suggestion how we can move this patch forward?
>
> IIRC, D150688  + the diff in 
> https://github.com/llvm/llvm-project/issues/62719#issuecomment-1552903385 + 
> upgrading the pre-merge linux bot should take care of all known issues.

Would it make sense to put all these patches in one new review and then test 
that on Chromium and ask @glandium to test that too. Then we know whether it 
solves the issues. Do you want me to make a patch or do you want to do it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144509

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


[PATCH] D150887: [clang] Convert a few tests to opaque pointers

2023-05-19 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added inline comments.



Comment at: clang/test/CodeGenCXX/const-init-cxx11.cpp:353
   };
-  // CHECK: @_ZN14VirtualMembersL13sGlobalMemoryE = internal global { i8** } { 
i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* 
@_ZTVN14VirtualMembers12nsMemoryImplE, i32 0, inrange i32 0, i32 2) }
+  // CHECK: @_ZN14VirtualMembersL13sGlobalMemoryE = internal global 
%"struct.VirtualMembers::nsMemoryImpl" { ptr getelementptr inbounds ({ [3 x 
ptr] }, ptr @_ZTVN14VirtualMembers12nsMemoryImplE, i32 0, inrange i32 0, i32 2) 
}
   __attribute__((used))

barannikov88 wrote:
> nikic wrote:
> > barannikov88 wrote:
> > > This was one suspicious change. An anonymous struct became named.
> > > 
> > Not sure why exactly this happened, but should be harmless. I believe we 
> > sometimes generate anon structs for initializaton because the types used 
> > for initialization are not always compatible with the nominal LLVM memory 
> > type -- I guess there previously was a mismatch in pointer types here or 
> > something.
> This is where the behavior diverges:
> ```
> llvm::Constant *ConstantAggregateBuilder::buildFrom(
> CodeGenModule &CGM, ArrayRef Elems,
> ArrayRef Offsets, CharUnits StartOffset, CharUnits Size,
> bool NaturalLayout, llvm::Type *DesiredTy, bool AllowOversized) {
> ...
>   // Pick the type to use.  If the type is layout identical to the desired
>   // type then use it, otherwise use whatever the builder produced for us.
>   if (llvm::StructType *DesiredSTy = dyn_cast(DesiredTy)) {
> if (DesiredSTy->isLayoutIdentical(STy))
>   STy = DesiredSTy;
>   }
> ...
> ```
> With typed pointers, STy and DesiredSTy respectively are:
> ```
> { i8** }
> %struct.nsMemoryImpl = type { i32 (...)** }
> ```
> `isLayoutIdentical`, despite its name, actually checks for full equivalence 
> of structs, not just the layout. That is, it is no different from 
> `operator==`.
> 
> The code snippet above is the only use of `isLayoutIdentical`.
> 
>  That is, it is no different from operator==.

Quick test shows this is not true...



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150887

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


[PATCH] D150946: [clang][Interp] PointerToIntegral casts

2023-05-19 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik accepted this revision.
shafik 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/D150946/new/

https://reviews.llvm.org/D150946

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


[PATCH] D149677: [clang][TypePrinter] Add option to skip over elaborated types

2023-05-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added reviewers: dblaikie, sammccall.
aaron.ballman added subscribers: sammccall, dblaikie.
aaron.ballman added a comment.

In D149677#4350337 , @li.zhe.hua 
wrote:

> In D149677#4349523 , @aaron.ballman 
> wrote:
>
>> In D149677#4320178 , @li.zhe.hua 
>> wrote:
>>
>>> Some additional context: I'm working on a refactoring tool to, in part, 
>>> deprecate an alias by replacing it with its definition. That functionality 
>>> by itself could be provided through something like a clang-tidy, so I say 
>>> "initially".
>>
>> We typically don't add new printing policies in tree without some need for 
>> them in the project itself (otherwise this becomes a maintenance problem), 
>> and I'm not certain I see a strong need for this to live in Clang. I think 
>> it might be best to wait until you're closer to having a clang-tidy check 
>> that would use this functionality before we continue with this patch. WDYT?
>
> I believe there is value for having this option, as without it, the 
> `PrintingCallbacks::isScopeVisible` callback is effectively useless in 
> practice. It won't be triggered in non-canonical types because the 
> `ElaboratedType` represents a fixed qualification on the name.
>
> Note: there may be an argument for folding this functionality directly into 
> `FullyQualifiedName` (which currently affects template-ids despite the 
> comment on it suggesting it only is for function names). If the template name 
> was elaborated, `FullyQualifiedName` does nothing, which seems 
> inconsistent/incorrect.

Adding @dblaikie as he might have some opinions here.

I'm not seeing how the changes you've got here interact with 
`isScopeVisible()`; However, I also note that the only use of 
`isScopeVisible()` in tree is in clangd, so also adding @sammccall to see if 
they're hitting issues there or not.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149677

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


[clang] dae1754 - Reword diagnostic for style; NFC

2023-05-19 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2023-05-19T12:38:33-04:00
New Revision: dae175423a07fbc63cf9d996751609361493f925

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

LOG: Reword diagnostic for style; NFC

Clang diagnostics do not start with a capital letter.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/test/Driver/openmp-offload-jit.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 8a5a3ad3b7fc..d56708e3ee4f 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -135,7 +135,7 @@ def err_drv_invalid_unwindlib_name : Error<
 def err_drv_incompatible_unwindlib : Error<
   "--rtlib=libgcc requires --unwindlib=libgcc">;
 def err_drv_incompatible_options : Error<
-  "The combination of '%0' and '%1' is incompatible">;
+  "the combination of '%0' and '%1' is incompatible">;
 def err_drv_invalid_stdlib_name : Error<
   "invalid library name in argument '%0'">;
 def err_drv_invalid_output_with_multiple_archs : Error<

diff  --git a/clang/test/Driver/openmp-offload-jit.c 
b/clang/test/Driver/openmp-offload-jit.c
index d887e697268c..392a8439a02f 100644
--- a/clang/test/Driver/openmp-offload-jit.c
+++ b/clang/test/Driver/openmp-offload-jit.c
@@ -46,9 +46,9 @@
 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp 
-fno-offload-lto \
 // RUN:   -fopenmp-targets=nvptx64-nvidia-cuda -fopenmp-target-jit %s 2>&1 \
 // RUN: | FileCheck -check-prefix=NO-LTO %s
-// NO-LTO: error: The combination of '-fno-offload-lto' and 
'-fopenmp-target-jit' is incompatible
+// NO-LTO: error: the combination of '-fno-offload-lto' and 
'-fopenmp-target-jit' is incompatible
 
 // RUN: %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp 
-foffload-lto=thin \
 // RUN:   -fopenmp-targets=nvptx64-nvidia-cuda -fopenmp-target-jit %s 2>&1 \
 // RUN: | FileCheck -check-prefix=THIN-LTO %s
-// THIN-LTO: error: The combination of '-foffload-lto=' and 
'-fopenmp-target-jit' is incompatible
+// THIN-LTO: error: the combination of '-foffload-lto=' and 
'-fopenmp-target-jit' is incompatible



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


[PATCH] D150948: [clang][RecoveryExpr] Fix a crash where a dependent type crahes on c-only code path.

2023-05-19 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik accepted this revision.
shafik added a comment.

Thank you for the fix, LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150948

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


[PATCH] D150913: [Clang][Bfloat16] Upgrade __bf16 to arithmetic type, change mangling, and extend excess precision support.

2023-05-19 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Basic/Targets/X86.cpp:381
 
 HasBFloat16 = SSELevel >= SSE2;
 

pengfei wrote:
> I'm not sure if I understand the meaning of `HasFullBFloat16`. If it is used 
> for target that supports arithmetic `__bf16`, we should not use `+fullbf16` 
> but always enable it for SSE2, i.e., `HasFullBFloat16 = SSELevel >= SSE2`. 
> Because X86 GCC already supports arithmetic for `__bf16`.
> 
> If this is used in the way like `HasLegalHalfType`, we should enable it once 
> we have a full BF16 ISA on X86. `fullbf16` doesn't make much sense to me.
At the moment, we haven't done the work to emulate BFloat16 arithmetic in any 
of the three ways we can do that: Clang doesn't promote it in IRGen, LLVM 
doesn't promote it in legalization, and we don't have compiler-rt functions for 
it.  If we emit these instructions, they'll just sail through LLVM and fail in 
the backend.  So in the short term, we have to restrict this to targets that 
directly support BFloat16 arithmetic in hardware, which doesn't include x86.

Once we have that emulation support, I agree that the x86 targets should enable 
this whenever they would enable `__bf16`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150913

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


[PATCH] D148505: Allow `__attribute__((warn_unused))` on individual constructors

2023-05-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D148505#4331647 , @sberg wrote:

> In D148505#4302702 , @aaron.ballman 
> wrote:
>
>> Thank you for poking on this! FWIW, I don't know that there's a way to 
>> cross-post to Discourse (but if I'm wrong and there is, I'd love to know 
>> how!).
>
> Ping, any further input from anybody?
>
> (The cross-posting didn't work, but there was also almost no response on the 
> GCC side, https://gcc.gnu.org/pipermail/gcc/2023-April/241220.html "Re: 
> GCC/Clang attributes guiding warnings about unused entities".)

I've thought about it a bit since the last time around, and I'm still kind of 
uncomfortable with the changes especially given that GCC folks don't seem to 
have an appetite to change the behavior. However, I'm also not firmly opposed 
to the idea either as there is some nice symmetry. Most of my concerns really 
boil down to the ergonomics of how all the various attributes in this space are 
slightly different from one another; unless GCC goes the same direction, this 
is one more difference between the attributes that you need to worry about. 
However, at least GCC warns that they're ignoring the attribute when written on 
a constructor: https://godbolt.org/z/bzTojhs1f so perhaps this difference is 
reasonable so long as we have some amazing documentation.

I'm not certain if @erichkeane has new thoughts or not.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148505

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


[PATCH] D147808: [clangd] Support non-trivial defaulted special member functions in Define Outline tweak

2023-05-19 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks a lot, and sorry for the delay!




Comment at: clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp:333
+[](const syntax::Token &Tok) { return Tok.kind() == tok::equal; });
+assert(Toks.size() == 2);
+return {Toks.front().location(), Toks.back().endLocation()};

can you add a comment here saying `// We should have just ```= default``` in 
this case`



Comment at: clang-tools-extra/clangd/refactor/tweaks/DefineOutline.cpp:409
+(!Source->doesThisDeclarationHaveABody() &&
+ (!Source->isExplicitlyDefaulted() || Source->isTrivial())) ||
 Source->isOutOfLine())

i know i asked for triviality check in the first version, but thinking a little 
bit more about it, users might be more confused about code action's 
availability. as this is very subtle at a glance for anyone but the compiler. 
so i think it's better to just emit it always.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147808

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


[PATCH] D148505: Allow `__attribute__((warn_unused))` on individual constructors

2023-05-19 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

I'm still on the fence.  I think properly documenting all of this entire 
attribute would make me more comfortable here, particularly since it will allow 
GCC to follow us easily some day.  I think that would move the needle for me.




Comment at: clang/include/clang/Basic/Attr.td:2997
+  let Subjects = SubjectList<[Record, CXXConstructor]>;
   let Documentation = [Undocumented];
   let SimpleHandler = 1;

For this to go through, I think we'd want this properly documented.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148505

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


[PATCH] D146873: [2/11][POC][Clang][RISCV] Define RVV tuple types

2023-05-19 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 523834.
eopXD added a comment.

Rebase to latest main before landing this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146873

Files:
  clang/include/clang/Basic/RISCVVTypes.def
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/rvv-tuple-type.c
  clang/test/Sema/riscv-types.c

Index: clang/test/Sema/riscv-types.c
===
--- clang/test/Sema/riscv-types.c
+++ clang/test/Sema/riscv-types.c
@@ -133,6 +133,9 @@
 
   // CHECK: __rvv_int8mf2_t x43;
   __rvv_int8mf2_t x43;
+
+  // CHECK: __rvv_int32m1x2_t x44;
+  __rvv_int32m1x2_t x44;
 }
 
 typedef __rvv_bool4_t vbool4_t;
Index: clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/rvv-tuple-type.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/rvv-tuple-type.c
@@ -0,0 +1,90 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// RUN: %clang_cc1 -triple riscv64 -target-feature +zve32x -O0 \
+// RUN:   -emit-llvm %s -o - | FileCheck %s --check-prefix=O0
+// RUN: %clang_cc1 -triple riscv64 -target-feature +zve32x -disable-O0-optnone \
+// RUN:   -emit-llvm %s -o - | opt -S -passes=mem2reg | FileCheck %s --check-prefix=AFTER_MEM2REG
+
+
+#include 
+
+// Declare local variable
+// O0-LABEL: define dso_local void @foo
+// O0-SAME: () #[[ATTR0:[0-9]+]] {
+// O0-NEXT:  entry:
+// O0-NEXT:[[V_TUPLE:%.*]] = alloca { ,  }, align 4
+// O0-NEXT:ret void
+//
+// AFTER_MEM2REG-LABEL: define dso_local void @foo
+// AFTER_MEM2REG-SAME: () #[[ATTR0:[0-9]+]] {
+// AFTER_MEM2REG-NEXT:  entry:
+// AFTER_MEM2REG-NEXT:ret void
+//
+void foo() {
+  __rvv_int32m1x2_t v_tuple;
+}
+
+// Declare local variable and return
+// O0-LABEL: define dso_local { ,  } @bar
+// O0-SAME: () #[[ATTR0]] {
+// O0-NEXT:  entry:
+// O0-NEXT:[[V_TUPLE:%.*]] = alloca { ,  }, align 4
+// O0-NEXT:[[TMP0:%.*]] = load { ,  }, ptr [[V_TUPLE]], align 4
+// O0-NEXT:ret { ,  } [[TMP0]]
+//
+// AFTER_MEM2REG-LABEL: define dso_local { ,  } @bar
+// AFTER_MEM2REG-SAME: () #[[ATTR0]] {
+// AFTER_MEM2REG-NEXT:  entry:
+// AFTER_MEM2REG-NEXT:ret { ,  } undef
+//
+__rvv_int32m1x2_t bar() {
+  __rvv_int32m1x2_t v_tuple;
+  return v_tuple;
+}
+
+// Pass as function parameter
+// O0-LABEL: define dso_local void @baz
+// O0-SAME: ( [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]]) #[[ATTR0]] {
+// O0-NEXT:  entry:
+// O0-NEXT:[[V_TUPLE:%.*]] = alloca { ,  }, align 4
+// O0-NEXT:[[V_TUPLE_ADDR:%.*]] = alloca { ,  }, align 4
+// O0-NEXT:[[TMP0:%.*]] = insertvalue { ,  } poison,  [[V_TUPLE_COERCE0]], 0
+// O0-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// O0-NEXT:store { ,  } [[TMP1]], ptr [[V_TUPLE]], align 4
+// O0-NEXT:[[V_TUPLE1:%.*]] = load { ,  }, ptr [[V_TUPLE]], align 4
+// O0-NEXT:store { ,  } [[V_TUPLE1]], ptr [[V_TUPLE_ADDR]], align 4
+// O0-NEXT:ret void
+//
+// AFTER_MEM2REG-LABEL: define dso_local void @baz
+// AFTER_MEM2REG-SAME: ( [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]]) #[[ATTR0]] {
+// AFTER_MEM2REG-NEXT:  entry:
+// AFTER_MEM2REG-NEXT:[[TMP0:%.*]] = insertvalue { ,  } poison,  [[V_TUPLE_COERCE0]], 0
+// AFTER_MEM2REG-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// AFTER_MEM2REG-NEXT:ret void
+//
+void baz(__rvv_int32m1x2_t v_tuple) {
+}
+
+// Pass as function parameter and return
+// O0-LABEL: define dso_local { ,  } @qux
+// O0-SAME: ( [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]]) #[[ATTR0]] {
+// O0-NEXT:  entry:
+// O0-NEXT:[[V_TUPLE:%.*]] = alloca { ,  }, align 4
+// O0-NEXT:[[V_TUPLE_ADDR:%.*]] = alloca { ,  }, align 4
+// O0-NEXT:[[TMP0:%.*]] = insertvalue { ,  } poison,  [[V_TUPLE_COERCE0]], 0
+// O0-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// O0-NEXT:store { ,  } [[TMP1]], ptr [[V_TUPLE]], align 4
+// O0-NEXT:[[V_TUPLE1:%.*]] = load { ,  }, ptr [[V_TUPLE]], align 4
+// O0-NEXT:store { ,  } [[V_TUPLE1]], ptr [[V_TUPLE_ADDR]], align 4
+// O0-NEXT:[[TMP2:%.*]] = load { ,  }, ptr [[V_TUPLE_ADDR]], align 4
+// O0-NEXT:ret { ,  } [[TMP2]]
+//
+// AFTER_MEM2REG-LABEL: define dso_local { ,  } @qux
+// AFTER_MEM2REG-SAME: ( [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]]) #[[ATTR0]] {
+// AFTER_MEM2REG-NEXT:  entry:
+// AFTER_MEM2REG-NEXT:[[TMP0:%.*]] = insertvalue { ,  } poison,  [[V_TUPLE_COERCE0]], 0
+// AFTER_MEM2REG-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// AFTER_MEM2REG-NEXT:ret { ,  } [[TMP1]]
+//
+__rvv_int32m1x2_t qux(__rvv_int32m1x2_t v_tuple) {
+  return v_tuple;
+}
Index: clang/lib/CodeGen/CodeGenTypes.cpp
==

[PATCH] D150752: [bolt] Use correct output paths and passthrough necessary options

2023-05-19 Thread Amir Ayupov via Phabricator via cfe-commits
Amir added a comment.

Please retitle as "[BOLT][CMake] ..."


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150752

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


[clang] be37e3e - [NFC][CLANG] Fix dereference issue before null check found by Coverity static analyzer tool

2023-05-19 Thread via cfe-commits

Author: Manna, Soumi
Date: 2023-05-19T10:16:14-07:00
New Revision: be37e3e25982c9346df883fcc61e7b60311594a4

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

LOG: [NFC][CLANG] Fix dereference issue before null check found by Coverity 
static analyzer tool

Reported by Coverity static analyzer tool:

Inside "ParsePragma.cpp" file, in 
::PragmaRISCVHandler::HandlePragma(clang::Preprocessor &, 
clang::PragmaIntroducer, clang::Token &): All paths that lead to this null 
pointer comparison already dereference the pointer earlier

  PP.Lex(Tok);
  II = Tok.getIdentifierInfo();
  //deref_ptr_in_call: Dereferencing pointer II.
  StringRef IntrinsicClass = II->getName();

//Dereference before null check (REVERSE_INULL)
//check_after_deref: Null-checking II suggests that it may be null, but it 
has already been dereferenced on all paths leading to the check.
if (!II || !(II->isStr("vector") || II->isStr("sifive_vector"))) {
  PP.Diag(Tok.getLocation(), diag::warn_pragma_invalid_argument)
  << PP.getSpelling(Tok) << "riscv" << /*Expected=*/true
  << "'vector' or 'sifive_vector'";
  return;
  }

This patch removes redundant StringRef type 'IntrinsicClass' and checks
II->isStr("vector") || II->isStr("sifive_vector") instead to set 
Actions.DeclareRISCVVBuiltins or
Actions.DeclareRISCVVectorBuiltins.

Reviewed By: erichkeane

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

Added: 


Modified: 
clang/lib/Parse/ParsePragma.cpp

Removed: 




diff  --git a/clang/lib/Parse/ParsePragma.cpp b/clang/lib/Parse/ParsePragma.cpp
index aad8c09729774..8c3da9a7438e8 100644
--- a/clang/lib/Parse/ParsePragma.cpp
+++ b/clang/lib/Parse/ParsePragma.cpp
@@ -4041,7 +4041,6 @@ void PragmaRISCVHandler::HandlePragma(Preprocessor &PP,
 
   PP.Lex(Tok);
   II = Tok.getIdentifierInfo();
-  StringRef IntrinsicClass = II->getName();
   if (!II || !(II->isStr("vector") || II->isStr("sifive_vector"))) {
 PP.Diag(Tok.getLocation(), diag::warn_pragma_invalid_argument)
 << PP.getSpelling(Tok) << "riscv" << /*Expected=*/true
@@ -4056,8 +4055,8 @@ void PragmaRISCVHandler::HandlePragma(Preprocessor &PP,
 return;
   }
 
-  if (IntrinsicClass == "vector")
+  if (II->isStr("vector"))
 Actions.DeclareRISCVVBuiltins = true;
-  else if (IntrinsicClass == "sifive_vector")
+  else if (II->isStr("sifive_vector"))
 Actions.DeclareRISCVVectorBuiltins = true;
 }



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


[PATCH] D150895: [NFC][CLANG] Fix dereference issue before null check found by Coverity static analyzer tool

2023-05-19 Thread Soumi Manna via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Manna marked an inline comment as done.
Closed by commit rGbe37e3e25982: [NFC][CLANG] Fix dereference issue before null 
check found by Coverity static… (authored by Manna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150895

Files:
  clang/lib/Parse/ParsePragma.cpp


Index: clang/lib/Parse/ParsePragma.cpp
===
--- clang/lib/Parse/ParsePragma.cpp
+++ clang/lib/Parse/ParsePragma.cpp
@@ -4041,7 +4041,6 @@
 
   PP.Lex(Tok);
   II = Tok.getIdentifierInfo();
-  StringRef IntrinsicClass = II->getName();
   if (!II || !(II->isStr("vector") || II->isStr("sifive_vector"))) {
 PP.Diag(Tok.getLocation(), diag::warn_pragma_invalid_argument)
 << PP.getSpelling(Tok) << "riscv" << /*Expected=*/true
@@ -4056,8 +4055,8 @@
 return;
   }
 
-  if (IntrinsicClass == "vector")
+  if (II->isStr("vector"))
 Actions.DeclareRISCVVBuiltins = true;
-  else if (IntrinsicClass == "sifive_vector")
+  else if (II->isStr("sifive_vector"))
 Actions.DeclareRISCVVectorBuiltins = true;
 }


Index: clang/lib/Parse/ParsePragma.cpp
===
--- clang/lib/Parse/ParsePragma.cpp
+++ clang/lib/Parse/ParsePragma.cpp
@@ -4041,7 +4041,6 @@
 
   PP.Lex(Tok);
   II = Tok.getIdentifierInfo();
-  StringRef IntrinsicClass = II->getName();
   if (!II || !(II->isStr("vector") || II->isStr("sifive_vector"))) {
 PP.Diag(Tok.getLocation(), diag::warn_pragma_invalid_argument)
 << PP.getSpelling(Tok) << "riscv" << /*Expected=*/true
@@ -4056,8 +4055,8 @@
 return;
   }
 
-  if (IntrinsicClass == "vector")
+  if (II->isStr("vector"))
 Actions.DeclareRISCVVBuiltins = true;
-  else if (IntrinsicClass == "sifive_vector")
+  else if (II->isStr("sifive_vector"))
 Actions.DeclareRISCVVectorBuiltins = true;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150965: [HIP] Allow std::malloc in device function

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

LGTM.




Comment at: clang/test/Headers/Inputs/include/math.h:108-109
 long lroundf(float __a);
-int max(int __a, int __b);
-int min(int __a, int __b);
 double modf(double __a, double *__b);

Why were these functions removed? It does not seem related to the changes in 
the patch?


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

https://reviews.llvm.org/D150965

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


[PATCH] D148089: [clang][CodeGen] Break up TargetInfo.cpp [1/8]

2023-05-19 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 updated this revision to Diff 523839.
barannikov88 added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148089

Files:
  clang/lib/CodeGen/TargetInfo.cpp


Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -9056,13 +9056,17 @@
 
 namespace {
 class LanaiABIInfo : public DefaultABIInfo {
+  struct CCState {
+unsigned FreeRegs;
+  };
+
 public:
   LanaiABIInfo(CodeGen::CodeGenTypes &CGT) : DefaultABIInfo(CGT) {}
 
   bool shouldUseInReg(QualType Ty, CCState &State) const;
 
   void computeInfo(CGFunctionInfo &FI) const override {
-CCState State(FI);
+CCState State;
 // Lanai uses 4 registers to pass arguments unless the function has the
 // regparm attribute set.
 if (FI.getHasRegParm()) {
@@ -10074,6 +10078,10 @@
 namespace {
 
 class ARCABIInfo : public DefaultABIInfo {
+  struct CCState {
+unsigned FreeRegs;
+  };
+
 public:
   using DefaultABIInfo::DefaultABIInfo;
 
@@ -10096,7 +10104,7 @@
   }
 
   void computeInfo(CGFunctionInfo &FI) const override {
-CCState State(FI);
+CCState State;
 // ARC uses 8 registers to pass arguments.
 State.FreeRegs = 8;
 


Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -9056,13 +9056,17 @@
 
 namespace {
 class LanaiABIInfo : public DefaultABIInfo {
+  struct CCState {
+unsigned FreeRegs;
+  };
+
 public:
   LanaiABIInfo(CodeGen::CodeGenTypes &CGT) : DefaultABIInfo(CGT) {}
 
   bool shouldUseInReg(QualType Ty, CCState &State) const;
 
   void computeInfo(CGFunctionInfo &FI) const override {
-CCState State(FI);
+CCState State;
 // Lanai uses 4 registers to pass arguments unless the function has the
 // regparm attribute set.
 if (FI.getHasRegParm()) {
@@ -10074,6 +10078,10 @@
 namespace {
 
 class ARCABIInfo : public DefaultABIInfo {
+  struct CCState {
+unsigned FreeRegs;
+  };
+
 public:
   using DefaultABIInfo::DefaultABIInfo;
 
@@ -10096,7 +10104,7 @@
   }
 
   void computeInfo(CGFunctionInfo &FI) const override {
-CCState State(FI);
+CCState State;
 // ARC uses 8 registers to pass arguments.
 State.FreeRegs = 8;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D148090: [clang][CodeGen] Break up TargetInfo.cpp [2/8]

2023-05-19 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 updated this revision to Diff 523840.
barannikov88 added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148090

Files:
  clang/lib/CodeGen/TargetInfo.cpp

Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -830,19 +830,18 @@
 // This is a very simple ABI that relies a lot on DefaultABIInfo.
 //===--===//
 
-class WebAssemblyABIInfo final : public ABIInfo {
-public:
-  enum ABIKind {
-MVP = 0,
-ExperimentalMV = 1,
-  };
+enum class WebAssemblyABIKind {
+  MVP = 0,
+  ExperimentalMV = 1,
+};
 
-private:
+class WebAssemblyABIInfo final : public ABIInfo {
   DefaultABIInfo defaultInfo;
-  ABIKind Kind;
+  WebAssemblyABIKind Kind;
 
 public:
-  explicit WebAssemblyABIInfo(CodeGen::CodeGenTypes &CGT, ABIKind Kind)
+  explicit WebAssemblyABIInfo(CodeGen::CodeGenTypes &CGT,
+  WebAssemblyABIKind Kind)
   : ABIInfo(CGT), defaultInfo(CGT), Kind(Kind) {}
 
 private:
@@ -866,7 +865,7 @@
 class WebAssemblyTargetCodeGenInfo final : public TargetCodeGenInfo {
 public:
   explicit WebAssemblyTargetCodeGenInfo(CodeGen::CodeGenTypes &CGT,
-WebAssemblyABIInfo::ABIKind K)
+WebAssemblyABIKind K)
   : TargetCodeGenInfo(std::make_unique(CGT, K)) {
 SwiftInfo =
 std::make_unique(CGT, /*SwiftErrorInRegister=*/false);
@@ -931,7 +930,7 @@
 if (const Type *SeltTy = isSingleElementStruct(Ty, getContext()))
   return ABIArgInfo::getDirect(CGT.ConvertType(QualType(SeltTy, 0)));
 // For the experimental multivalue ABI, fully expand all other aggregates
-if (Kind == ABIKind::ExperimentalMV) {
+if (Kind == WebAssemblyABIKind::ExperimentalMV) {
   const RecordType *RT = Ty->getAs();
   assert(RT);
   bool HasBitField = false;
@@ -964,7 +963,7 @@
   if (const Type *SeltTy = isSingleElementStruct(RetTy, getContext()))
 return ABIArgInfo::getDirect(CGT.ConvertType(QualType(SeltTy, 0)));
   // For the experimental multivalue ABI, return all other aggregates
-  if (Kind == ABIKind::ExperimentalMV)
+  if (Kind == WebAssemblyABIKind::ExperimentalMV)
 return ABIArgInfo::getDirect();
 }
   }
@@ -4973,21 +4972,19 @@
 // PowerPC-64
 
 namespace {
+enum class PPC64_SVR4_ABIKind {
+  ELFv1 = 0,
+  ELFv2,
+};
+
 /// PPC64_SVR4_ABIInfo - The 64-bit PowerPC ELF (SVR4) ABI information.
 class PPC64_SVR4_ABIInfo : public ABIInfo {
-public:
-  enum ABIKind {
-ELFv1 = 0,
-ELFv2
-  };
-
-private:
   static const unsigned GPRBits = 64;
-  ABIKind Kind;
+  PPC64_SVR4_ABIKind Kind;
   bool IsSoftFloatABI;
 
 public:
-  PPC64_SVR4_ABIInfo(CodeGen::CodeGenTypes &CGT, ABIKind Kind,
+  PPC64_SVR4_ABIInfo(CodeGen::CodeGenTypes &CGT, PPC64_SVR4_ABIKind Kind,
  bool SoftFloatABI)
   : ABIInfo(CGT), Kind(Kind), IsSoftFloatABI(SoftFloatABI) {}
 
@@ -5035,8 +5032,7 @@
 class PPC64_SVR4_TargetCodeGenInfo : public TargetCodeGenInfo {
 
 public:
-  PPC64_SVR4_TargetCodeGenInfo(CodeGenTypes &CGT,
-   PPC64_SVR4_ABIInfo::ABIKind Kind,
+  PPC64_SVR4_TargetCodeGenInfo(CodeGenTypes &CGT, PPC64_SVR4_ABIKind Kind,
bool SoftFloatABI)
   : TargetCodeGenInfo(
 std::make_unique(CGT, Kind, SoftFloatABI)) {
@@ -5135,7 +5131,7 @@
   // Likewise for ELFv2 homogeneous aggregates.
   const Type *Base = nullptr;
   uint64_t Members = 0;
-  if (!AlignAsType && Kind == ELFv2 &&
+  if (!AlignAsType && Kind == PPC64_SVR4_ABIKind::ELFv2 &&
   isAggregateTypeForABI(Ty) && isHomogeneousAggregate(Ty, Base, Members))
 AlignAsType = Base;
 
@@ -5329,7 +5325,7 @@
 // ELFv2 homogeneous aggregates are passed as array types.
 const Type *Base = nullptr;
 uint64_t Members = 0;
-if (Kind == ELFv2 &&
+if (Kind == PPC64_SVR4_ABIKind::ELFv2 &&
 isHomogeneousAggregate(Ty, Base, Members)) {
   llvm::Type *BaseTy = CGT.ConvertType(QualType(Base, 0));
   llvm::Type *CoerceTy = llvm::ArrayType::get(BaseTy, Members);
@@ -5399,7 +5395,7 @@
 // ELFv2 homogeneous aggregates are returned as array types.
 const Type *Base = nullptr;
 uint64_t Members = 0;
-if (Kind == ELFv2 &&
+if (Kind == PPC64_SVR4_ABIKind::ELFv2 &&
 isHomogeneousAggregate(RetTy, Base, Members)) {
   llvm::Type *BaseTy = CGT.ConvertType(QualType(Base, 0));
   llvm::Type *CoerceTy = llvm::ArrayType::get(BaseTy, Members);
@@ -5408,7 +5404,7 @@
 
 // ELFv2 small aggregates are returned in up to two registers.
 uint64_t Bits = getContext().getTypeSize(RetTy);
-if (Kind == ELFv2 && Bits <= 2 * GPRBits) {
+if (Kind == PPC64_SVR4_ABIKind::ELFv2 &&

[PATCH] D148091: [clang][CodeGen] Break up TargetInfo.cpp [3/8]

2023-05-19 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 updated this revision to Diff 523841.
barannikov88 added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148091

Files:
  clang/lib/CodeGen/TargetInfo.cpp


Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -5049,9 +5049,10 @@
llvm::Value *Address) const override;
 };
 
-class PPC64TargetCodeGenInfo : public DefaultTargetCodeGenInfo {
+class PPC64TargetCodeGenInfo : public TargetCodeGenInfo {
 public:
-  PPC64TargetCodeGenInfo(CodeGenTypes &CGT) : DefaultTargetCodeGenInfo(CGT) {}
+  PPC64TargetCodeGenInfo(CodeGenTypes &CGT)
+  : TargetCodeGenInfo(std::make_unique(CGT)) {}
 
   int getDwarfEHStackPointer(CodeGen::CodeGenModule &M) const override {
 // This is recovered from gcc output.
@@ -5061,7 +5062,6 @@
   bool initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF,
llvm::Value *Address) const override;
 };
-
 }
 
 // Return true if the ABI requires Ty to be passed sign- or zero-
@@ -8584,10 +8584,10 @@
 
 namespace {
 
-class TCETargetCodeGenInfo : public DefaultTargetCodeGenInfo {
+class TCETargetCodeGenInfo : public TargetCodeGenInfo {
 public:
   TCETargetCodeGenInfo(CodeGenTypes &CGT)
-: DefaultTargetCodeGenInfo(CGT) {}
+  : TargetCodeGenInfo(std::make_unique(CGT)) {}
 
   void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
CodeGen::CodeGenModule &M) const override;


Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -5049,9 +5049,10 @@
llvm::Value *Address) const override;
 };
 
-class PPC64TargetCodeGenInfo : public DefaultTargetCodeGenInfo {
+class PPC64TargetCodeGenInfo : public TargetCodeGenInfo {
 public:
-  PPC64TargetCodeGenInfo(CodeGenTypes &CGT) : DefaultTargetCodeGenInfo(CGT) {}
+  PPC64TargetCodeGenInfo(CodeGenTypes &CGT)
+  : TargetCodeGenInfo(std::make_unique(CGT)) {}
 
   int getDwarfEHStackPointer(CodeGen::CodeGenModule &M) const override {
 // This is recovered from gcc output.
@@ -5061,7 +5062,6 @@
   bool initDwarfEHRegSizeTable(CodeGen::CodeGenFunction &CGF,
llvm::Value *Address) const override;
 };
-
 }
 
 // Return true if the ABI requires Ty to be passed sign- or zero-
@@ -8584,10 +8584,10 @@
 
 namespace {
 
-class TCETargetCodeGenInfo : public DefaultTargetCodeGenInfo {
+class TCETargetCodeGenInfo : public TargetCodeGenInfo {
 public:
   TCETargetCodeGenInfo(CodeGenTypes &CGT)
-: DefaultTargetCodeGenInfo(CGT) {}
+  : TargetCodeGenInfo(std::make_unique(CGT)) {}
 
   void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
CodeGen::CodeGenModule &M) const override;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D148092: [clang][CodeGen] Break up TargetInfo.cpp [4/8]

2023-05-19 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 updated this revision to Diff 523842.
barannikov88 added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148092

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h

Index: clang/lib/CodeGen/TargetInfo.h
===
--- clang/lib/CodeGen/TargetInfo.h
+++ clang/lib/CodeGen/TargetInfo.h
@@ -52,6 +52,11 @@
   // by returning true from TargetInfo::checkCallingConvention for them.
   std::unique_ptr SwiftInfo;
 
+  // Returns ABI info helper for the target. This is for use by derived classes.
+  template  const T &getABIInfo() const {
+return static_cast(*Info);
+  }
+
 public:
   TargetCodeGenInfo(std::unique_ptr Info);
   virtual ~TargetCodeGenInfo();
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -2476,10 +2476,6 @@
 std::make_unique(CGT, /*SwiftErrorInRegister=*/true);
   }
 
-  const X86_64ABIInfo &getABIInfo() const {
-return static_cast(TargetCodeGenInfo::getABIInfo());
-  }
-
   /// Disable tail call on x86-64. The epilogue code before the tail jump blocks
   /// autoreleaseRV/retainRV and autoreleaseRV/unsafeClaimRV optimizations.
   bool markARCOptimizedReturnCallsAsNoTail() const override { return true; }
@@ -2516,7 +2512,7 @@
   bool HasAVXType = false;
   for (CallArgList::const_iterator
  it = args.begin(), ie = args.end(); it != ie; ++it) {
-if (getABIInfo().isPassedUsingAVXType(it->Ty)) {
+if (getABIInfo().isPassedUsingAVXType(it->Ty)) {
   HasAVXType = true;
   break;
 }
@@ -6388,10 +6384,6 @@
 SwiftInfo = std::make_unique(CGT);
   }
 
-  const ARMABIInfo &getABIInfo() const {
-return static_cast(TargetCodeGenInfo::getABIInfo());
-  }
-
   int getDwarfEHStackPointer(CodeGen::CodeGenModule &M) const override {
 return 13;
   }
@@ -6410,7 +6402,8 @@
   }
 
   unsigned getSizeOfUnwindException() const override {
-if (getABIInfo().isEABI()) return 88;
+if (getABIInfo().isEABI())
+  return 88;
 return TargetCodeGenInfo::getSizeOfUnwindException();
   }
 
@@ -6477,7 +6470,7 @@
 
 Fn->addFnAttr("interrupt", Kind);
 
-ARMABIKind ABI = cast(getABIInfo()).getABIKind();
+ARMABIKind ABI = getABIInfo().getABIKind();
 if (ABI == ARMABIKind::APCS)
   return;
 
@@ -7415,10 +7408,6 @@
 class SystemZTargetCodeGenInfo : public TargetCodeGenInfo {
   ASTContext &Ctx;
 
-  const SystemZABIInfo &getABIInfo() const {
-return static_cast(TargetCodeGenInfo::getABIInfo());
-  }
-
   // These are used for speeding up the search for a visible vector ABI.
   mutable bool HasVisibleVecABIFlag = false;
   mutable std::set SeenTypes;
@@ -7867,8 +7856,9 @@
 // it will be passed in a vector register. A wide (>16 bytes) vector will
 // be passed via "hidden" pointer where any extra alignment is not
 // required (per GCC).
-const Type *SingleEltTy =
-  getABIInfo().GetSingleElementType(QualType(Ty, 0)).getTypePtr();
+const Type *SingleEltTy = getABIInfo()
+  .GetSingleElementType(QualType(Ty, 0))
+  .getTypePtr();
 bool SingleVecEltStruct = SingleEltTy != Ty && SingleEltTy->isVectorType() &&
   Ctx.getTypeSize(SingleEltTy) == Ctx.getTypeSize(Ty);
 if (Ty->isVectorType() || SingleVecEltStruct)
@@ -11841,10 +11831,6 @@
 public:
   BPFTargetCodeGenInfo(CodeGenTypes &CGT)
   : TargetCodeGenInfo(std::make_unique(CGT)) {}
-
-  const BPFABIInfo &getABIInfo() const {
-return static_cast(TargetCodeGenInfo::getABIInfo());
-  }
 };
 
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D148093: [clang][CodeGen] Break up TargetInfo.cpp [5/8]

2023-05-19 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 updated this revision to Diff 523843.
barannikov88 added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148093

Files:
  clang/lib/CodeGen/ABIInfo.h
  clang/lib/CodeGen/TargetInfo.cpp


Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -125,7 +125,7 @@
 /// registers when expanded?
 ///
 /// This is intended to be the basis of a reasonable basic implementation
-/// of should{Pass,Return}IndirectlyForSwift.
+/// of should{Pass,Return}Indirectly.
 ///
 /// For most targets, a limit of four total registers is reasonable; this
 /// limits the amount of code required in order to move around the value
@@ -134,15 +134,14 @@
 /// immediately within the callee.  But some targets may need to further
 /// limit the register count due to an inability to support that many
 /// return registers.
-static bool occupiesMoreThan(CodeGenTypes &cgt,
- ArrayRef scalarTypes,
- unsigned maxAllRegisters) {
+bool SwiftABIInfo::occupiesMoreThan(ArrayRef scalarTypes,
+unsigned maxAllRegisters) const {
   unsigned intCount = 0, fpCount = 0;
   for (llvm::Type *type : scalarTypes) {
 if (type->isPointerTy()) {
   intCount++;
 } else if (auto intTy = dyn_cast(type)) {
-  auto ptrWidth = cgt.getTarget().getPointerWidth(LangAS::Default);
+  auto ptrWidth = CGT.getTarget().getPointerWidth(LangAS::Default);
   intCount += (intTy->getBitWidth() + ptrWidth - 1) / ptrWidth;
 } else {
   assert(type->isVectorTy() || type->isFloatingPointTy());
@@ -155,7 +154,7 @@
 
 bool SwiftABIInfo::shouldPassIndirectly(ArrayRef ComponentTys,
 bool AsReturnValue) const {
-  return occupiesMoreThan(CGT, ComponentTys, /*total=*/4);
+  return occupiesMoreThan(ComponentTys, /*total=*/4);
 }
 
 bool SwiftABIInfo::isLegalVectorType(CharUnits VectorSize, llvm::Type *EltTy,
@@ -1248,7 +1247,7 @@
 // integer registers and three fp registers.  Oddly, it'll use up to
 // four vector registers for vectors, but those can overlap with the
 // scalar registers.
-return occupiesMoreThan(CGT, ComponentTys, /*total=*/3);
+return occupiesMoreThan(ComponentTys, /*total=*/3);
   }
 };
 
Index: clang/lib/CodeGen/ABIInfo.h
===
--- clang/lib/CodeGen/ABIInfo.h
+++ clang/lib/CodeGen/ABIInfo.h
@@ -117,6 +117,9 @@
   CodeGenTypes &CGT;
   bool SwiftErrorInRegister;
 
+  bool occupiesMoreThan(ArrayRef scalarTypes,
+unsigned maxAllRegisters) const;
+
 public:
   SwiftABIInfo(CodeGen::CodeGenTypes &CGT, bool SwiftErrorInRegister)
   : CGT(CGT), SwiftErrorInRegister(SwiftErrorInRegister) {}


Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -125,7 +125,7 @@
 /// registers when expanded?
 ///
 /// This is intended to be the basis of a reasonable basic implementation
-/// of should{Pass,Return}IndirectlyForSwift.
+/// of should{Pass,Return}Indirectly.
 ///
 /// For most targets, a limit of four total registers is reasonable; this
 /// limits the amount of code required in order to move around the value
@@ -134,15 +134,14 @@
 /// immediately within the callee.  But some targets may need to further
 /// limit the register count due to an inability to support that many
 /// return registers.
-static bool occupiesMoreThan(CodeGenTypes &cgt,
- ArrayRef scalarTypes,
- unsigned maxAllRegisters) {
+bool SwiftABIInfo::occupiesMoreThan(ArrayRef scalarTypes,
+unsigned maxAllRegisters) const {
   unsigned intCount = 0, fpCount = 0;
   for (llvm::Type *type : scalarTypes) {
 if (type->isPointerTy()) {
   intCount++;
 } else if (auto intTy = dyn_cast(type)) {
-  auto ptrWidth = cgt.getTarget().getPointerWidth(LangAS::Default);
+  auto ptrWidth = CGT.getTarget().getPointerWidth(LangAS::Default);
   intCount += (intTy->getBitWidth() + ptrWidth - 1) / ptrWidth;
 } else {
   assert(type->isVectorTy() || type->isFloatingPointTy());
@@ -155,7 +154,7 @@
 
 bool SwiftABIInfo::shouldPassIndirectly(ArrayRef ComponentTys,
 bool AsReturnValue) const {
-  return occupiesMoreThan(CGT, ComponentTys, /*total=*/4);
+  return occupiesMoreThan(ComponentTys, /*total=*/4);
 }
 
 bool SwiftABIInfo::isLegalVectorType(CharUnits VectorSize, llvm::Type *EltTy,
@@ -1248,7 +1247,7 @@
 // integer registers and three fp registers.  Oddly, it'll use up to
 // four vector registers for vectors, but those can overla

[PATCH] D150178: [clang][CodeGen] Break up TargetInfo.cpp [6/8]

2023-05-19 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 updated this revision to Diff 523844.
barannikov88 added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150178

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h


Index: clang/lib/CodeGen/TargetInfo.h
===
--- clang/lib/CodeGen/TargetInfo.h
+++ clang/lib/CodeGen/TargetInfo.h
@@ -398,6 +398,12 @@
   virtual llvm::Type *getOpenCLType(CodeGenModule &CGM, const Type *T) const {
 return nullptr;
   }
+
+protected:
+  static std::string qualifyWindowsLibrary(StringRef Lib);
+
+  void addStackProbeTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
+ CodeGen::CodeGenModule &CGM) const;
 };
 
 } // namespace CodeGen
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -2543,6 +2543,7 @@
 const FunctionDecl *Callee,
 const CallArgList &Args) const override;
 };
+} // namespace
 
 static void initFeatureMaps(const ASTContext &Ctx,
 llvm::StringMap &CallerMap,
@@ -2641,7 +2642,7 @@
   }
 }
 
-static std::string qualifyWindowsLibrary(llvm::StringRef Lib) {
+std::string TargetCodeGenInfo::qualifyWindowsLibrary(StringRef Lib) {
   // If the argument does not end in .lib, automatically add the suffix.
   // If the argument contains a space, enclose it in quotes.
   // This matches the behavior of MSVC.
@@ -2654,6 +2655,7 @@
   return ArgStr;
 }
 
+namespace {
 class WinX86_32TargetCodeGenInfo : public X86_32TargetCodeGenInfo {
 public:
   WinX86_32TargetCodeGenInfo(CodeGen::CodeGenTypes &CGT,
@@ -2677,11 +2679,11 @@
 Opt = "/FAILIFMISMATCH:\"" + Name.str() + "=" + Value.str() + "\"";
   }
 };
+} // namespace
 
-static void addStackProbeTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
-  CodeGen::CodeGenModule &CGM) {
+void TargetCodeGenInfo::addStackProbeTargetAttributes(
+const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &CGM) const {
   if (llvm::Function *Fn = dyn_cast_or_null(GV)) {
-
 if (CGM.getCodeGenOpts().StackProbeSize != 4096)
   Fn->addFnAttr("stack-probe-size",
 llvm::utostr(CGM.getCodeGenOpts().StackProbeSize));
@@ -2698,6 +2700,7 @@
   addStackProbeTargetAttributes(D, GV, CGM);
 }
 
+namespace {
 class WinX86_64TargetCodeGenInfo : public TargetCodeGenInfo {
 public:
   WinX86_64TargetCodeGenInfo(CodeGen::CodeGenTypes &CGT,
@@ -2736,6 +2739,7 @@
 Opt = "/FAILIFMISMATCH:\"" + Name.str() + "=" + Value.str() + "\"";
   }
 };
+} // namespace
 
 void WinX86_64TargetCodeGenInfo::setTargetAttributes(
 const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &CGM) const {
@@ -2753,7 +2757,6 @@
 
   addStackProbeTargetAttributes(D, GV, CGM);
 }
-}
 
 void X86_64ABIInfo::postMerge(unsigned AggregateSize, Class &Lo,
   Class &Hi) const {


Index: clang/lib/CodeGen/TargetInfo.h
===
--- clang/lib/CodeGen/TargetInfo.h
+++ clang/lib/CodeGen/TargetInfo.h
@@ -398,6 +398,12 @@
   virtual llvm::Type *getOpenCLType(CodeGenModule &CGM, const Type *T) const {
 return nullptr;
   }
+
+protected:
+  static std::string qualifyWindowsLibrary(StringRef Lib);
+
+  void addStackProbeTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
+ CodeGen::CodeGenModule &CGM) const;
 };
 
 } // namespace CodeGen
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -2543,6 +2543,7 @@
 const FunctionDecl *Callee,
 const CallArgList &Args) const override;
 };
+} // namespace
 
 static void initFeatureMaps(const ASTContext &Ctx,
 llvm::StringMap &CallerMap,
@@ -2641,7 +2642,7 @@
   }
 }
 
-static std::string qualifyWindowsLibrary(llvm::StringRef Lib) {
+std::string TargetCodeGenInfo::qualifyWindowsLibrary(StringRef Lib) {
   // If the argument does not end in .lib, automatically add the suffix.
   // If the argument contains a space, enclose it in quotes.
   // This matches the behavior of MSVC.
@@ -2654,6 +2655,7 @@
   return ArgStr;
 }
 
+namespace {
 class WinX86_32TargetCodeGenInfo : public X86_32TargetCodeGenInfo {
 public:
   WinX86_32TargetCodeGenInfo(CodeGen::CodeGenTypes &CGT,
@@ -2677,11 +2679,11 @@
 Opt = "/FAILIFMISMATCH:\"" + Name.str() + "=" + Value.str() + "\"";
   }
 };
+} // namespace
 
-static void addStackProbeTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
-  CodeGen::CodeGenM

[PATCH] D150215: [clang][CodeGen] Break up TargetInfo.cpp [7/8]

2023-05-19 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 updated this revision to Diff 523845.
barannikov88 added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150215

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h

Index: clang/lib/CodeGen/TargetInfo.h
===
--- clang/lib/CodeGen/TargetInfo.h
+++ clang/lib/CodeGen/TargetInfo.h
@@ -406,6 +406,150 @@
  CodeGen::CodeGenModule &CGM) const;
 };
 
+std::unique_ptr
+createDefaultTargetCodeGenInfo(CodeGenModule &CGM);
+
+enum class AArch64ABIKind {
+  AAPCS = 0,
+  DarwinPCS,
+  Win64,
+};
+
+std::unique_ptr
+createAArch64TargetCodeGenInfo(CodeGenModule &CGM, AArch64ABIKind Kind);
+
+std::unique_ptr
+createWindowsAArch64TargetCodeGenInfo(CodeGenModule &CGM, AArch64ABIKind K);
+
+std::unique_ptr
+createAMDGPUTargetCodeGenInfo(CodeGenModule &CGM);
+
+std::unique_ptr
+createARCTargetCodeGenInfo(CodeGenModule &CGM);
+
+enum class ARMABIKind {
+  APCS = 0,
+  AAPCS = 1,
+  AAPCS_VFP = 2,
+  AAPCS16_VFP = 3,
+};
+
+std::unique_ptr
+createARMTargetCodeGenInfo(CodeGenModule &CGM, ARMABIKind Kind);
+
+std::unique_ptr
+createWindowsARMTargetCodeGenInfo(CodeGenModule &CGM, ARMABIKind K);
+
+std::unique_ptr
+createAVRTargetCodeGenInfo(CodeGenModule &CGM, unsigned NPR, unsigned NRR);
+
+std::unique_ptr
+createBPFTargetCodeGenInfo(CodeGenModule &CGM);
+
+std::unique_ptr
+createCSKYTargetCodeGenInfo(CodeGenModule &CGM, unsigned FLen);
+
+std::unique_ptr
+createHexagonTargetCodeGenInfo(CodeGenModule &CGM);
+
+std::unique_ptr
+createLanaiTargetCodeGenInfo(CodeGenModule &CGM);
+
+std::unique_ptr
+createLoongArchTargetCodeGenInfo(CodeGenModule &CGM, unsigned GRLen,
+ unsigned FLen);
+
+std::unique_ptr
+createM68kTargetCodeGenInfo(CodeGenModule &CGM);
+
+std::unique_ptr
+createMIPSTargetCodeGenInfo(CodeGenModule &CGM, bool IsOS32);
+
+std::unique_ptr
+createMSP430TargetCodeGenInfo(CodeGenModule &CGM);
+
+std::unique_ptr
+createNVPTXTargetCodeGenInfo(CodeGenModule &CGM);
+
+std::unique_ptr
+createPNaClTargetCodeGenInfo(CodeGenModule &CGM);
+
+enum class PPC64_SVR4_ABIKind {
+  ELFv1 = 0,
+  ELFv2,
+};
+
+std::unique_ptr
+createAIXTargetCodeGenInfo(CodeGenModule &CGM, bool Is64Bit);
+
+std::unique_ptr
+createPPC32TargetCodeGenInfo(CodeGenModule &CGM, bool SoftFloatABI);
+
+std::unique_ptr
+createPPC64TargetCodeGenInfo(CodeGenModule &CGM);
+
+std::unique_ptr
+createPPC64_SVR4_TargetCodeGenInfo(CodeGenModule &CGM, PPC64_SVR4_ABIKind Kind,
+   bool SoftFloatABI);
+
+std::unique_ptr
+createRISCVTargetCodeGenInfo(CodeGenModule &CGM, unsigned XLen, unsigned FLen);
+
+std::unique_ptr
+createCommonSPIRTargetCodeGenInfo(CodeGenModule &CGM);
+
+std::unique_ptr
+createSPIRVTargetCodeGenInfo(CodeGenModule &CGM);
+
+std::unique_ptr
+createSparcV8TargetCodeGenInfo(CodeGenModule &CGM);
+
+std::unique_ptr
+createSparcV9TargetCodeGenInfo(CodeGenModule &CGM);
+
+std::unique_ptr
+createSystemZTargetCodeGenInfo(CodeGenModule &CGM, bool HasVector,
+   bool SoftFloatABI);
+
+std::unique_ptr
+createTCETargetCodeGenInfo(CodeGenModule &CGM);
+
+std::unique_ptr
+createVETargetCodeGenInfo(CodeGenModule &CGM);
+
+enum class WebAssemblyABIKind {
+  MVP = 0,
+  ExperimentalMV = 1,
+};
+
+std::unique_ptr
+createWebAssemblyTargetCodeGenInfo(CodeGenModule &CGM, WebAssemblyABIKind K);
+
+/// The AVX ABI level for X86 targets.
+enum class X86AVXABILevel {
+  None,
+  AVX,
+  AVX512,
+};
+
+std::unique_ptr createX86_32TargetCodeGenInfo(
+CodeGenModule &CGM, bool DarwinVectorABI, bool Win32StructABI,
+unsigned NumRegisterParameters, bool SoftFloatABI);
+
+std::unique_ptr
+createWinX86_32TargetCodeGenInfo(CodeGenModule &CGM, bool DarwinVectorABI,
+ bool Win32StructABI,
+ unsigned NumRegisterParameters);
+
+std::unique_ptr
+createX86_64TargetCodeGenInfo(CodeGenModule &CGM, X86AVXABILevel AVXLevel);
+
+std::unique_ptr
+createWinX86_64TargetCodeGenInfo(CodeGenModule &CGM, X86AVXABILevel AVXLevel);
+
+std::unique_ptr
+createXCoreTargetCodeGenInfo(CodeGenModule &CGM);
+
 } // namespace CodeGen
 } // namespace clang
 
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -829,11 +829,6 @@
 // This is a very simple ABI that relies a lot on DefaultABIInfo.
 //===--===//
 
-enum class WebAssemblyABIKind {
-  MVP = 0,
-  ExperimentalMV = 1,
-};
-
 class WebAssemblyABIInfo final : public ABIInfo {
   DefaultABIInfo defaultInfo;
   WebAssemblyABIKind Kind;
@@ -2239,12 +2234,6 @@
 
 
 namespace {
-/// The AVX ABI level for X86 targets.
-enum class X86AVXABILevel {
-  None,
-  AVX,
-  AVX512
-}

[PATCH] D148094: [clang][CodeGen] Break up TargetInfo.cpp [8/8]

2023-05-19 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 updated this revision to Diff 523846.
barannikov88 added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148094

Files:
  clang/docs/UsersManual.rst
  clang/docs/tools/clang-formatted-files.txt
  clang/lib/CodeGen/ABIInfo.cpp
  clang/lib/CodeGen/ABIInfo.h
  clang/lib/CodeGen/ABIInfoImpl.cpp
  clang/lib/CodeGen/ABIInfoImpl.h
  clang/lib/CodeGen/CMakeLists.txt
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/Targets/AArch64.cpp
  clang/lib/CodeGen/Targets/AMDGPU.cpp
  clang/lib/CodeGen/Targets/ARC.cpp
  clang/lib/CodeGen/Targets/ARM.cpp
  clang/lib/CodeGen/Targets/AVR.cpp
  clang/lib/CodeGen/Targets/BPF.cpp
  clang/lib/CodeGen/Targets/CSKY.cpp
  clang/lib/CodeGen/Targets/Hexagon.cpp
  clang/lib/CodeGen/Targets/Lanai.cpp
  clang/lib/CodeGen/Targets/LoongArch.cpp
  clang/lib/CodeGen/Targets/M68k.cpp
  clang/lib/CodeGen/Targets/MSP430.cpp
  clang/lib/CodeGen/Targets/Mips.cpp
  clang/lib/CodeGen/Targets/NVPTX.cpp
  clang/lib/CodeGen/Targets/PNaCl.cpp
  clang/lib/CodeGen/Targets/PPC.cpp
  clang/lib/CodeGen/Targets/RISCV.cpp
  clang/lib/CodeGen/Targets/SPIR.cpp
  clang/lib/CodeGen/Targets/Sparc.cpp
  clang/lib/CodeGen/Targets/SystemZ.cpp
  clang/lib/CodeGen/Targets/TCE.cpp
  clang/lib/CodeGen/Targets/VE.cpp
  clang/lib/CodeGen/Targets/WebAssembly.cpp
  clang/lib/CodeGen/Targets/X86.cpp
  clang/lib/CodeGen/Targets/XCore.cpp
  clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp
  llvm/utils/gn/secondary/clang/lib/CodeGen/BUILD.gn

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


[PATCH] D148094: [clang][CodeGen] Break up TargetInfo.cpp [8/8]

2023-05-19 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148094

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


[PATCH] D147731: [3/11][POC][Clang][RISCV] Add typedef of the tuple type and define tuple type variant of vlseg2e32

2023-05-19 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 523847.
eopXD added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147731

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/Basic/riscv_vector.td
  clang/include/clang/Basic/riscv_vector_common.td
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaRISCVVectorLookup.cpp
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg2e32_tuple.c
  clang/utils/TableGen/RISCVVEmitter.cpp

Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -65,6 +65,7 @@
   bool HasMaskedOffOperand :1;
   bool HasTailPolicy : 1;
   bool HasMaskPolicy : 1;
+  bool IsTuple : 1;
   uint8_t UnMaskedPolicyScheme : 2;
   uint8_t MaskedPolicyScheme : 2;
 };
@@ -363,6 +364,16 @@
 TypeModifier::UnsignedInteger));
 printType(*UT);
   }
+  // FIXME: Expand more type declaration
+  if (I == 'i' && Log2LMUL == 0) { // vint32m1x2_t
+auto TupleT = TypeCache.computeType(
+BT, Log2LMUL,
+PrototypeDescriptor(BaseTypeModifier::Vector,
+VectorTypeModifier::Tuple2,
+TypeModifier::SignedInteger));
+if (TupleT)
+  printType(*TupleT);
+  }
 }
   }
 
@@ -512,6 +523,7 @@
 StringRef IRName = R->getValueAsString("IRName");
 StringRef MaskedIRName = R->getValueAsString("MaskedIRName");
 unsigned NF = R->getValueAsInt("NF");
+bool IsTuple = R->getValueAsBit("IsTuple");
 
 const Policy DefaultPolicy;
 SmallVector SupportedUnMaskedPolicies =
@@ -532,10 +544,10 @@
 auto Prototype = RVVIntrinsic::computeBuiltinTypes(
 BasicPrototype, /*IsMasked=*/false,
 /*HasMaskedOffOperand=*/false, HasVL, NF, UnMaskedPolicyScheme,
-DefaultPolicy);
+DefaultPolicy, IsTuple);
 auto MaskedPrototype = RVVIntrinsic::computeBuiltinTypes(
 BasicPrototype, /*IsMasked=*/true, HasMaskedOffOperand, HasVL, NF,
-MaskedPolicyScheme, DefaultPolicy);
+MaskedPolicyScheme, DefaultPolicy, IsTuple);
 
 // Create Intrinsics for each type and LMUL.
 for (char I : TypeRange) {
@@ -557,14 +569,14 @@
 /*IsMasked=*/false, /*HasMaskedOffOperand=*/false, HasVL,
 UnMaskedPolicyScheme, SupportOverloading, HasBuiltinAlias,
 ManualCodegen, *Types, IntrinsicTypes, RequiredFeatures, NF,
-DefaultPolicy));
+DefaultPolicy, IsTuple));
 if (UnMaskedPolicyScheme != PolicyScheme::SchemeNone)
   for (auto P : SupportedUnMaskedPolicies) {
 SmallVector PolicyPrototype =
 RVVIntrinsic::computeBuiltinTypes(
 BasicPrototype, /*IsMasked=*/false,
 /*HasMaskedOffOperand=*/false, HasVL, NF,
-UnMaskedPolicyScheme, P);
+UnMaskedPolicyScheme, P, IsTuple);
 std::optional PolicyTypes =
 TypeCache.computeTypes(BT, Log2LMUL, NF, PolicyPrototype);
 Out.push_back(std::make_unique(
@@ -572,7 +584,7 @@
 /*IsMask=*/false, /*HasMaskedOffOperand=*/false, HasVL,
 UnMaskedPolicyScheme, SupportOverloading, HasBuiltinAlias,
 ManualCodegen, *PolicyTypes, IntrinsicTypes, RequiredFeatures,
-NF, P));
+NF, P, IsTuple));
   }
 if (!HasMasked)
   continue;
@@ -583,14 +595,14 @@
 Name, SuffixStr, OverloadedName, OverloadedSuffixStr, MaskedIRName,
 /*IsMasked=*/true, HasMaskedOffOperand, HasVL, MaskedPolicyScheme,
 SupportOverloading, HasBuiltinAlias, ManualCodegen, *MaskTypes,
-IntrinsicTypes, RequiredFeatures, NF, DefaultPolicy));
+IntrinsicTypes, RequiredFeatures, NF, DefaultPolicy, IsTuple));
 if (MaskedPolicyScheme == PolicyScheme::SchemeNone)
   continue;
 for (auto P : SupportedMaskedPolicies) {
   SmallVector PolicyPrototype =
   RVVIntrinsic::computeBuiltinTypes(
   BasicPrototype, /*IsMasked=*/true, HasMaskedOffOperand, HasVL,
-  NF, MaskedPolicyScheme, P);
+  NF, MaskedPolicyScheme, P, IsTuple);
   std::optional PolicyTypes =
   TypeCache.computeTypes(BT, Log2LMUL, NF, PolicyPrototype);
   Out.push_back(std::make_unique(
@@ -598,7 +610,7 @@
   MaskedIRName, /*IsMasked=*/true, HasMaskedOffOperand, HasVL,
   MaskedPolicyScheme, SupportOverloading, HasBuiltinAlias,
   ManualCodegen, *PolicyTypes, IntrinsicTypes, Requir

[PATCH] D147774: [4/11][POC][Clang][RISCV] Define tuple type variant of vsseg2e32

2023-05-19 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 523848.
eopXD added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147774

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/CodeGen/CGBuiltin.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsseg2e32_tuple.c

Index: clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsseg2e32_tuple.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsseg2e32_tuple.c
@@ -0,0 +1,31 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zfh \
+// RUN:   -target-feature +experimental-zvfh -disable-O0-optnone  \
+// RUN:   -emit-llvm %s -o - | opt -S -passes=mem2reg | \
+// RUN:   FileCheck --check-prefix=CHECK-RV64 %s
+#include 
+
+// CHECK-RV64-LABEL: define dso_local void @test_vsseg2e32_v_tuple_i32m1
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]],  [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { ,  } poison,  [[V_TUPLE_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { ,  } [[TMP1]], 0
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { ,  } [[TMP1]], 1
+// CHECK-RV64-NEXT:call void @llvm.riscv.vsseg2.nxv2i32.i64( [[TMP2]],  [[TMP3]], ptr [[BASE]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vsseg2e32_v_tuple_i32m1(int32_t *base, vint32m1x2_t v_tuple, size_t vl) {
+  return __riscv_vsseg2e32_v_tuple_i32m1(base, v_tuple, vl);
+}
+
+// CHECK-RV64-LABEL: define dso_local void @test_vsseg2e32_v_i32m1_m
+// CHECK-RV64-SAME: ( [[MASK:%.*]], ptr noundef [[BASE:%.*]],  [[V0:%.*]],  [[V1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:call void @llvm.riscv.vsseg2.mask.nxv2i32.i64( [[V0]],  [[V1]], ptr [[BASE]],  [[MASK]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vsseg2e32_v_i32m1_m(vbool32_t mask, int32_t *base, vint32m1_t v0, vint32m1_t v1, size_t vl) {
+  return __riscv_vsseg2e32_v_i32m1_m(mask, base, v0, v1, vl);
+}
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -19764,6 +19764,14 @@
 ICEArguments |= (1 << 2);
 
   for (unsigned i = 0, e = E->getNumArgs(); i != e; i++) {
+// Handle aggregate argument, namely RVV tuple types in segment load/store
+if (hasAggregateEvaluationKind(E->getArg(i)->getType())) {
+  LValue L = EmitAggExprToLValue(E->getArg(i));
+  llvm::Value *AggValue = Builder.CreateLoad(L.getAddress(*this));
+  Ops.push_back(AggValue);
+  continue;
+}
+
 // If this is a normal argument, just emit it as a scalar.
 if ((ICEArguments & (1 << i)) == 0) {
   Ops.push_back(EmitScalarExpr(E->getArg(i)));
Index: clang/include/clang/Basic/riscv_vector.td
===
--- clang/include/clang/Basic/riscv_vector.td
+++ clang/include/clang/Basic/riscv_vector.td
@@ -1548,6 +1548,49 @@
 }
   }
 }
+
+multiclass RVVUnitStridedSegStoreTuple {
+  foreach type = ["i"] in {
+defvar eew = !cond(!eq(type, "i") : "32");
+foreach nf = [2] in {
+  let Name = op # nf # "e" # eew # "_v_tuple",
+  OverloadedName = op # nf # "e" # eew # "_tuple",
+  IRName = op # nf,
+  MaskedIRName = op # nf # "_mask",
+  NF = nf,
+  HasMaskedOffOperand = false,
+  ManualCodegen = [{
+{
+  // Masked
+  // Builtin: (mask, ptr, v_tuple, vl)
+  // Intrinsic: (val0, val1, ..., ptr, mask, vl)
+  // Unmasked
+  // Builtin: (ptr, v_tuple, vl)
+  // Intrinsic: (val0, val1, ..., ptr, vl)
+  unsigned Offset = IsMasked ? 1 : 0;
+  llvm::Value *VTupleOperand = Ops[Offset + 1];
+
+  SmallVector Operands;
+  for (unsigned I = 0; I < NF; ++I) {
+llvm::Value *V = Builder.CreateExtractValue(VTupleOperand, {I});
+Operands.push_back(V);
+  }
+  Operands.push_back(Ops[Offset]); // Ptr
+  if (IsMasked)
+Operands.push_back(Ops[0]);
+  Operands.push_back(Ops[Offset + 2]); // VL
+
+  IntrinsicTypes = {Operands[0]->getType(), Operands.back()->getType()};
+  llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
+  return Builder.CreateCall(F, Operands, "");
+   }
+  }] in {
+  defvar T = "(Tuple:" # nf # ")";
+  def : RVVBuiltin<"v", "0Pe" # T # "v", type>;
+  }
+

[PATCH] D147911: [5/11][POC][Clang][RISCV] Define tuple type variant of vlseg2e32ff

2023-05-19 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 523849.
eopXD added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147911

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg2e32ff_tuple.c

Index: clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg2e32ff_tuple.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlseg2e32ff_tuple.c
@@ -0,0 +1,39 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zfh \
+// RUN:   -target-feature +experimental-zvfh -disable-O0-optnone  \
+// RUN:   -emit-llvm %s -o - | opt -S -passes=mem2reg | \
+// RUN:   FileCheck --check-prefix=CHECK-RV64 %s
+#include 
+
+// CHECK-RV64-LABEL: define dso_local { ,  } @test_vlseg2e32ff_v_tuple_i32m1
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]], ptr noundef [[NEW_VL:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call { , , i64 } @llvm.riscv.vlseg2ff.nxv2i32.i64( poison,  poison, ptr [[BASE]], i64 [[VL]])
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = extractvalue { , , i64 } [[TMP0]], 0
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = insertvalue { ,  } poison,  [[TMP1]], 0
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { , , i64 } [[TMP0]], 1
+// CHECK-RV64-NEXT:[[TMP4:%.*]] = insertvalue { ,  } [[TMP2]],  [[TMP3]], 1
+// CHECK-RV64-NEXT:[[TMP5:%.*]] = extractvalue { , , i64 } [[TMP0]], 2
+// CHECK-RV64-NEXT:store i64 [[TMP5]], ptr [[NEW_VL]], align 8
+// CHECK-RV64-NEXT:ret { ,  } [[TMP4]]
+//
+vint32m1x2_t test_vlseg2e32ff_v_tuple_i32m1(const int32_t *base, size_t *new_vl, size_t vl) {
+  return __riscv_vlseg2e32ff_v_tuple_i32m1(base, new_vl, vl);
+}
+
+// CHECK-RV64-LABEL: define dso_local { ,  } @test_vlseg2e32ff_v_tuple_i32m1_m
+// CHECK-RV64-SAME: ( [[MASK:%.*]], ptr noundef [[BASE:%.*]], ptr noundef [[NEW_VL:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call { , , i64 } @llvm.riscv.vlseg2ff.mask.nxv2i32.i64( poison,  poison, ptr [[BASE]],  [[MASK]], i64 [[VL]], i64 3)
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = extractvalue { , , i64 } [[TMP0]], 0
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = insertvalue { ,  } poison,  [[TMP1]], 0
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { , , i64 } [[TMP0]], 1
+// CHECK-RV64-NEXT:[[TMP4:%.*]] = insertvalue { ,  } [[TMP2]],  [[TMP3]], 1
+// CHECK-RV64-NEXT:[[TMP5:%.*]] = extractvalue { , , i64 } [[TMP0]], 2
+// CHECK-RV64-NEXT:store i64 [[TMP5]], ptr [[NEW_VL]], align 8
+// CHECK-RV64-NEXT:ret { ,  } [[TMP4]]
+//
+vint32m1x2_t test_vlseg2e32ff_v_tuple_i32m1_m(vbool32_t mask, const int32_t *base, size_t *new_vl, size_t vl) {
+  return __riscv_vlseg2e32ff_v_tuple_i32m1_m(mask, base, new_vl, vl);
+}
Index: clang/include/clang/Basic/riscv_vector.td
===
--- clang/include/clang/Basic/riscv_vector.td
+++ clang/include/clang/Basic/riscv_vector.td
@@ -1591,11 +1591,73 @@
 }
   }
 }
+
+multiclass RVVUnitStridedSegLoadFFTuple {
+  foreach type = ["i"] in {
+defvar eew = !cond(!eq(type, "i") : "32");
+  foreach nf = [2] in {
+let Name = op # nf # "e" # eew # "ff_v_tuple",
+OverloadedName = op # nf # "e" # eew # "ff_tuple",
+IRName = op # nf # "ff",
+MaskedIRName = op # nf # "ff_mask",
+NF = nf,
+ManualCodegen = [{
+{
+  assert(((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) ||
+ (!IsMasked && (PolicyAttrs & RVV_VTA))) &&
+ "FIXME: Only handling default policy (TAMA) for now");
+
+  llvm::Type *ElementVectorType = cast(ResultType)->elements()[0];
+
+  IntrinsicTypes = {ElementVectorType, Ops.back()->getType()};
+  SmallVector Operands;
+
+  Operands.append(NF, llvm::PoisonValue::get(ElementVectorType));
+
+  unsigned Offset = IsMasked ? 1 : 0;
+  Operands.push_back(Ops[Offset]); // Ptr
+  if (IsMasked)
+Operands.push_back(Ops[0]);
+  Operands.push_back(Ops[Offset + 2]); // vl
+  if (IsMasked)
+Operands.push_back(ConstantInt::get(Ops.back()->getType(), PolicyAttrs));
+
+  llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
+
+  llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
+  // Get alignment from the new vl operand
+  clang::CharUnits Align =
+  CGM.getNaturalPointeeTypeAlignment(E->getArg(Offset + 1)->getType());
+
+  llvm::Value *ReturnTuple = llvm::PoisonValue::get(ResultType);

[PATCH] D147912: [6/11][POC][Clang][RISCV] Define tuple type variant of vlsseg2e32

2023-05-19 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 523850.
eopXD added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147912

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlsseg2e32_tuple.c


Index: 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlsseg2e32_tuple.c
===
--- /dev/null
+++ 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlsseg2e32_tuple.c
@@ -0,0 +1,27 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 2
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zfh \
+// RUN:   -target-feature +experimental-zvfh -disable-O0-optnone  \
+// RUN:   -emit-llvm %s -o - | opt -S -passes=mem2reg | \
+// RUN:   FileCheck --check-prefix=CHECK-RV64 %s
+#include 
+
+// CHECK-RV64-LABEL: define dso_local { ,  
} @test_vlsseg2e32_v_tuple_i32m1
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]], i64 noundef [[BSTRIDE:%.*]], 
i64 noundef [[VL:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call { ,  } @llvm.riscv.vlsseg2.nxv2i32.i64( poison,  poison, ptr [[BASE]], i64 [[BSTRIDE]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret { ,  } [[TMP0]]
+//
+vint32m1x2_t test_vlsseg2e32_v_tuple_i32m1(const int32_t *base, ptrdiff_t 
bstride, size_t vl) {
+  return __riscv_vlsseg2e32_v_tuple_i32m1(base, bstride, vl);
+}
+
+// CHECK-RV64-LABEL: define dso_local { ,  
} @test_vlsseg2e32_v_tuple_i32m1_m
+// CHECK-RV64-SAME: ( [[MASK:%.*]], ptr noundef [[BASE:%.*]], 
i64 noundef [[BSTRIDE:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call { ,  } @llvm.riscv.vlsseg2.mask.nxv2i32.i64( poison,  poison, ptr [[BASE]], i64 [[BSTRIDE]],  [[MASK]], 
i64 [[VL]], i64 3)
+// CHECK-RV64-NEXT:ret { ,  } [[TMP0]]
+//
+vint32m1x2_t test_vlsseg2e32_v_tuple_i32m1_m(vbool32_t mask, const int32_t 
*base, ptrdiff_t bstride, size_t vl) {
+  return __riscv_vlsseg2e32_v_tuple_i32m1_m(mask, base, bstride, vl);
+}
Index: clang/include/clang/Basic/riscv_vector.td
===
--- clang/include/clang/Basic/riscv_vector.td
+++ clang/include/clang/Basic/riscv_vector.td
@@ -1652,12 +1652,60 @@
   }
 }
 
+multiclass RVVStridedSegLoadTuple {
+  foreach type = ["i"] in {
+defvar eew = !cond(!eq(type, "i") : "32");
+  foreach nf = [2] in {
+let Name = op # nf # "e" # eew # "_v_tuple",
+OverloadedName = op # nf # "e" # eew # "_tuple",
+IRName = op # nf,
+MaskedIRName = op # nf # "_mask",
+NF = nf,
+ManualCodegen = [{
+{
+  assert(((IsMasked && (PolicyAttrs & RVV_VTA) && (PolicyAttrs & RVV_VMA)) 
||
+ (!IsMasked && (PolicyAttrs & RVV_VTA))) &&
+ "FIXME: Only handling default policy (TAMA) for now");
+
+  llvm::Type *ElementVectorType = 
cast(ResultType)->elements()[0];
+
+  IntrinsicTypes = {ElementVectorType, Ops.back()->getType()};
+  SmallVector Operands;
+
+  Operands.append(NF, llvm::PoisonValue::get(ElementVectorType));
+
+  unsigned Offset = IsMasked ? 1 : 0;
+  Operands.push_back(Ops[Offset]); // Ptr
+  Operands.push_back(Ops[Offset + 1]); // Stride
+  if (IsMasked)
+Operands.push_back(Ops[0]);
+  Operands.push_back(Ops[Offset + 2]); // VL
+  if (IsMasked)
+Operands.push_back(ConstantInt::get(Ops.back()->getType(), 
PolicyAttrs));
+
+  llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
+  llvm::Value *LoadValue = Builder.CreateCall(F, Operands, "");
+
+  if (ReturnValue.isNull())
+return LoadValue;
+  else
+return Builder.CreateStore(LoadValue, ReturnValue.getValue());
+}
+}] in {
+  defvar T = "(Tuple:" # nf # ")";
+  def : RVVBuiltin<"v", T # "vPCet", type>;
+  }
+}
+  }
+}
+
 // TODO: Extend for policy
 let UnMaskedPolicyScheme = NonePolicy,
 MaskedPolicyScheme = NonePolicy,
 IsTuple = true in {
 defm : RVVUnitStridedSegLoadTuple<"vlseg">;
 defm : RVVUnitStridedSegLoadFFTuple<"vlseg">;
+defm : RVVStridedSegLoadTuple<"vlsseg">;
 }
 
 let UnMaskedPolicyScheme = NonePolicy,


Index: clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlsseg2e32_tuple.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vlsseg2e32_tuple.c
@@ -0,0 +1,27 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv6

[PATCH] D147913: [7/11][POC][Clang][RISCV] Define tuple type variant of vssseg2e32

2023-05-19 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 523851.
eopXD added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147913

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg2e32_tuple.c

Index: clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg2e32_tuple.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssseg2e32_tuple.c
@@ -0,0 +1,36 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zfh \
+// RUN:   -target-feature +experimental-zvfh -disable-O0-optnone  \
+// RUN:   -emit-llvm %s -o - | opt -S -passes=mem2reg | \
+// RUN:   FileCheck --check-prefix=CHECK-RV64 %s
+
+#include 
+
+// CHECK-RV64-LABEL: define dso_local void @test_vssseg2e32_v_tuple_i32m1
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]], i64 noundef [[BSTRIDE:%.*]],  [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { ,  } poison,  [[V_TUPLE_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { ,  } [[TMP1]], 0
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { ,  } [[TMP1]], 1
+// CHECK-RV64-NEXT:call void @llvm.riscv.vssseg2.nxv2i32.i64( [[TMP2]],  [[TMP3]], ptr [[BASE]], i64 [[BSTRIDE]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vssseg2e32_v_tuple_i32m1(int32_t *base, ptrdiff_t bstride, vint32m1x2_t v_tuple, size_t vl) {
+  return __riscv_vssseg2e32_v_tuple_i32m1(base, bstride, v_tuple, vl);
+}
+
+// CHECK-RV64-LABEL: define dso_local void @test_vssseg2e32_v_tuple_i32m1_m
+// CHECK-RV64-SAME: ( [[MASK:%.*]], ptr noundef [[BASE:%.*]], i64 noundef [[BSTRIDE:%.*]],  [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { ,  } poison,  [[V_TUPLE_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { ,  } [[TMP1]], 0
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { ,  } [[TMP1]], 1
+// CHECK-RV64-NEXT:call void @llvm.riscv.vssseg2.mask.nxv2i32.i64( [[TMP2]],  [[TMP3]], ptr [[BASE]], i64 [[BSTRIDE]],  [[MASK]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vssseg2e32_v_tuple_i32m1_m(vbool32_t mask, int32_t *base, ptrdiff_t bstride, vint32m1x2_t v_tuple, size_t vl) {
+  return __riscv_vssseg2e32_v_tuple_i32m1_m(mask, base, bstride, v_tuple, vl);
+}
Index: clang/include/clang/Basic/riscv_vector.td
===
--- clang/include/clang/Basic/riscv_vector.td
+++ clang/include/clang/Basic/riscv_vector.td
@@ -1699,6 +1699,51 @@
   }
 }
 
+multiclass RVVStridedSegStoreTuple {
+  foreach type = ["i"] in {
+defvar eew = !cond(!eq(type, "i") : "32");
+  foreach nf = [2] in {
+let Name = op # nf # "e" # eew # "_v_tuple",
+OverloadedName = op # nf # "e" # eew # "_tuple",
+IRName = op # nf,
+MaskedIRName = op # nf # "_mask",
+NF = nf,
+HasMaskedOffOperand = false,
+MaskedPolicyScheme = NonePolicy,
+ManualCodegen = [{
+{
+  // Masked
+  // Builtin: (mask, ptr, stride, v_tuple, vl)
+  // Intrinsic: (val0, val1, ..., ptr, stride, mask, vl)
+  // Unmasked
+  // Builtin: (ptr, stride, v_tuple, vl)
+  // Intrinsic: (val0, val1, ..., ptr, stride, vl)
+  unsigned Offset = IsMasked ? 1 : 0;
+  llvm::Value *VTupleOperand = Ops[Offset + 2];
+
+  SmallVector Operands;
+  for (unsigned I = 0; I < NF; ++I) {
+llvm::Value *V = Builder.CreateExtractValue(VTupleOperand, {I});
+Operands.push_back(V);
+  }
+  Operands.push_back(Ops[Offset]); // Ptr
+  Operands.push_back(Ops[Offset + 1]); // Stride
+  if (IsMasked)
+Operands.push_back(Ops[0]);
+  Operands.push_back(Ops[Offset + 3]); // VL
+
+  IntrinsicTypes = {Operands[0]->getType(), Operands.back()->getType()};
+  llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
+  return Builder.CreateCall(F, Operands, "");
+}
+}] in {
+  defvar T = "(Tuple:" # nf # ")";
+  def : RVVBuiltin<"v", "0Pet" # T # "v", type>;
+  }
+}
+  }
+}
+
 // TODO: Extend for policy
 let UnMaskedPolicyScheme = NonePolicy,
 MaskedPolicyScheme = NonePolicy,
@@ -1712,6 +1757,7 @@
  

[PATCH] D147914: [8/11][POC][Clang][RISCV] Define tuple type variant of vloxseg2ei32 vluxseg2ei32

2023-05-19 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 523852.
eopXD added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147914

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vloxseg2ei32_tuple.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vluxseg2ei32_tuple.c

Index: clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vluxseg2ei32_tuple.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vluxseg2ei32_tuple.c
@@ -0,0 +1,28 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zfh \
+// RUN:   -target-feature +experimental-zvfh -disable-O0-optnone  \
+// RUN:   -emit-llvm %s -o - | opt -S -passes=mem2reg | \
+// RUN:   FileCheck --check-prefix=CHECK-RV64 %s
+
+#include 
+
+// CHECK-RV64-LABEL: define dso_local { ,  } @test_vluxseg2ei32_v_tuple_i32m1
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]],  [[BINDEX:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call { ,  } @llvm.riscv.vluxseg2.nxv2i32.nxv2i32.i64( poison,  poison, ptr [[BASE]],  [[BINDEX]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret { ,  } [[TMP0]]
+//
+vint32m1x2_t test_vluxseg2ei32_v_tuple_i32m1(const int32_t *base, vuint32m1_t bindex, size_t vl) {
+  return __riscv_vluxseg2ei32_v_tuple_i32m1(base, bindex, vl);
+}
+
+// CHECK-RV64-LABEL: define dso_local { ,  } @test_vluxseg2ei32_v_tuple_i32m1_m
+// CHECK-RV64-SAME: ( [[MASK:%.*]], ptr noundef [[BASE:%.*]],  [[BINDEX:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call { ,  } @llvm.riscv.vluxseg2.mask.nxv2i32.nxv2i32.i64( poison,  poison, ptr [[BASE]],  [[BINDEX]],  [[MASK]], i64 [[VL]], i64 3)
+// CHECK-RV64-NEXT:ret { ,  } [[TMP0]]
+//
+vint32m1x2_t test_vluxseg2ei32_v_tuple_i32m1_m(vbool32_t mask, const int32_t *base, vuint32m1_t bindex, size_t vl) {
+  return __riscv_vluxseg2ei32_v_tuple_i32m1_m(mask, base, bindex, vl);
+}
Index: clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vloxseg2ei32_tuple.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vloxseg2ei32_tuple.c
@@ -0,0 +1,28 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zfh \
+// RUN:   -target-feature +experimental-zvfh -disable-O0-optnone  \
+// RUN:   -emit-llvm %s -o - | opt -S -passes=mem2reg | \
+// RUN:   FileCheck --check-prefix=CHECK-RV64 %s
+
+#include 
+
+// CHECK-RV64-LABEL: define dso_local { ,  } @test_vloxseg2ei32_v_tuple_i32m1
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]],  [[BINDEX:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call { ,  } @llvm.riscv.vloxseg2.nxv2i32.nxv2i32.i64( poison,  poison, ptr [[BASE]],  [[BINDEX]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret { ,  } [[TMP0]]
+//
+vint32m1x2_t test_vloxseg2ei32_v_tuple_i32m1(const int32_t *base, vuint32m1_t bindex, size_t vl) {
+  return __riscv_vloxseg2ei32_v_tuple_i32m1(base, bindex, vl);
+}
+
+// CHECK-RV64-LABEL: define dso_local { ,  } @test_vloxseg2ei32_v_tuple_i32m1_m
+// CHECK-RV64-SAME: ( [[MASK:%.*]], ptr noundef [[BASE:%.*]],  [[BINDEX:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call { ,  } @llvm.riscv.vloxseg2.mask.nxv2i32.nxv2i32.i64( poison,  poison, ptr [[BASE]],  [[BINDEX]],  [[MASK]], i64 [[VL]], i64 3)
+// CHECK-RV64-NEXT:ret { ,  } [[TMP0]]
+//
+vint32m1x2_t test_vloxseg2ei32_v_tuple_i32m1_m(vbool32_t mask, const int32_t *base, vuint32m1_t bindex, size_t vl) {
+  return __riscv_vloxseg2ei32_v_tuple_i32m1_m(mask, base, bindex, vl);
+}
Index: clang/include/clang/Basic/riscv_vector.td
===
--- clang/include/clang/Basic/riscv_vector.td
+++ clang/include/clang/Basic/riscv_vector.td
@@ -1744,6 +1744,57 @@
   }
 }
 
+multiclass RVVIndexedSegLoadTuple {
+  foreach type = ["i"] in {
+foreach eew_info = [["32", "(Log2EEW:5)"]] in {
+  defvar eew = eew_info[0];
+  defvar eew_type = eew_info[1];
+  foreach nf = [2] in {
+let Name = op # nf # "ei" # eew # "_v_tuple",
+OverloadedName = op # nf # "ei" # eew # "_tuple",
+IRName = op # nf,
+MaskedIR

[PATCH] D147915: [9/11][POC][Clang][RISCV] Define tuple type variant of vsoxseg2ei32 vsuxseg2ei32

2023-05-19 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 523853.
eopXD added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147915

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsoxseg2ei32_tuple.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsuxseg2ei32_tuple.c

Index: clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsuxseg2ei32_tuple.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsuxseg2ei32_tuple.c
@@ -0,0 +1,36 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zfh \
+// RUN:   -target-feature +experimental-zvfh -disable-O0-optnone  \
+// RUN:   -emit-llvm %s -o - | opt -S -passes=mem2reg | \
+// RUN:   FileCheck --check-prefix=CHECK-RV64 %s
+
+#include 
+
+// CHECK-RV64-LABEL: define dso_local void @test_vsuxseg2ei32_v_tuple_i32m1
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]],  [[BINDEX:%.*]],  [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { ,  } poison,  [[V_TUPLE_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { ,  } [[TMP1]], 0
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { ,  } [[TMP1]], 1
+// CHECK-RV64-NEXT:call void @llvm.riscv.vsuxseg2.nxv2i32.nxv2i32.i64( [[TMP2]],  [[TMP3]], ptr [[BASE]],  [[BINDEX]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vsuxseg2ei32_v_tuple_i32m1(int32_t *base, vuint32m1_t bindex, vint32m1x2_t v_tuple, size_t vl) {
+  return __riscv_vsuxseg2ei32_v_tuple_i32m1(base, bindex, v_tuple, vl);
+}
+
+// CHECK-RV64-LABEL: define dso_local void @test_vsuxseg2ei32_v_tuple_i32m1_m
+// CHECK-RV64-SAME: ( [[MASK:%.*]], ptr noundef [[BASE:%.*]],  [[BINDEX:%.*]],  [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { ,  } poison,  [[V_TUPLE_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { ,  } [[TMP1]], 0
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { ,  } [[TMP1]], 1
+// CHECK-RV64-NEXT:call void @llvm.riscv.vsuxseg2.mask.nxv2i32.nxv2i32.i64( [[TMP2]],  [[TMP3]], ptr [[BASE]],  [[BINDEX]],  [[MASK]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vsuxseg2ei32_v_tuple_i32m1_m(vbool32_t mask, int32_t *base, vuint32m1_t bindex, vint32m1x2_t v_tuple, size_t vl) {
+  return __riscv_vsuxseg2ei32_v_tuple_i32m1_m(mask, base, bindex, v_tuple, vl);
+}
Index: clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsoxseg2ei32_tuple.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsoxseg2ei32_tuple.c
@@ -0,0 +1,36 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zfh \
+// RUN:   -target-feature +experimental-zvfh -disable-O0-optnone  \
+// RUN:   -emit-llvm %s -o - | opt -S -passes=mem2reg | \
+// RUN:   FileCheck --check-prefix=CHECK-RV64 %s
+
+#include 
+
+// CHECK-RV64-LABEL: define dso_local void @test_vsoxseg2ei32_v_tuple_i32m1
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]],  [[BINDEX:%.*]],  [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { ,  } poison,  [[V_TUPLE_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { ,  } [[TMP1]], 0
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { ,  } [[TMP1]], 1
+// CHECK-RV64-NEXT:call void @llvm.riscv.vsoxseg2.nxv2i32.nxv2i32.i64( [[TMP2]],  [[TMP3]], ptr [[BASE]],  [[BINDEX]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vsoxseg2ei32_v_tuple_i32m1(int32_t *base, vuint32m1_t bindex, vint32m1x2_t v_tuple, size_t vl) {
+  return __riscv_vsoxseg2ei32_v_tuple_i32m1(base, bindex, v_tuple, vl);
+}
+
+// CHECK-RV64-LABEL: define dso_local void @test_vsoxseg2ei32_v_tuple_i32m1_m
+// CHECK-RV64-SAME: ( [[MASK:%.*]], ptr noundef [[BASE:%.*]],  [[BINDEX:%.*]],  [[V_TUPLE_COERCE0

[PATCH] D148723: [clang] Fix comdat for InlineBuiltin declarations

2023-05-19 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

I spoke a little loosely when I said "C++ code".  I meant "code using C++ 
'inline' semantics", which includes C code on Windows.


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

https://reviews.llvm.org/D148723

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


[clang] fe69bb6 - Fix tests failure on 75993812d5c1f269b781c34987748f2a792a579d

2023-05-19 Thread Zequan Wu via cfe-commits

Author: Zequan Wu
Date: 2023-05-19T13:34:40-04:00
New Revision: fe69bb64415ef6fe01ebbb1d1a801e85bd6bd879

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

LOG: Fix tests failure on 75993812d5c1f269b781c34987748f2a792a579d

It follows the rules:
1. Use native path if it's already absolute
2. Use Windows back-slash if it's windows formatting.
3. Use Posix style otherwise.

Added: 


Modified: 
clang/lib/AST/TypePrinter.cpp

Removed: 




diff  --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp
index 42bbbde6bfb7..dedcfde1 100644
--- a/clang/lib/AST/TypePrinter.cpp
+++ b/clang/lib/AST/TypePrinter.cpp
@@ -1392,9 +1392,11 @@ void TypePrinter::printTag(TagDecl *D, raw_ostream &OS) {
 // clang::DirectoryLookup::LookupFile when the file path is relative
 // path.
 llvm::sys::path::Style Style =
-!llvm::sys::path::is_absolute(WrittenFile) && Policy.MSVCFormatting
-? llvm::sys::path::Style::windows_backslash
-: llvm::sys::path::Style::native;
+llvm::sys::path::is_absolute(WrittenFile)
+? llvm::sys::path::Style::native
+: (Policy.MSVCFormatting
+   ? llvm::sys::path::Style::windows_backslash
+   : llvm::sys::path::Style::posix);
 llvm::sys::path::native(WrittenFile, Style);
 OS << WrittenFile << ':' << PLoc.getLine() << ':' << PLoc.getColumn();
   }



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


[PATCH] D150817: Use windows baskslash on anonymous tag locations if using MSVCFormatting and it's not absolute path.

2023-05-19 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu added a comment.

In D150817#4356305 , @TWeaver wrote:

> Hello and good afternoon from the UK,
>
> I believe this patch has caused failures on the following buildbot:
>
> https://lab.llvm.org/buildbot/#/builders/216/builds/21493
>
> are you able to take a look?
>
> thanks,
> Tom W

Thanks for reporting. Hope this fix it: 
https://reviews.llvm.org/rGfe69bb64415ef6fe01ebbb1d1a801e85bd6bd879.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150817

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


[PATCH] D150752: [BOLT][CMake] Use correct output paths and passthrough necessary options

2023-05-19 Thread Petr Hosek via Phabricator via cfe-commits
phosek added inline comments.



Comment at: bolt/CMakeLists.txt:88
+  if(CMAKE_SYSROOT)
+list(APPEND extra_args -DCMAKE_SYSROOT=${CMAKE_SYSROOT})
+  endif()

michaelplatings wrote:
> phosek wrote:
> > michaelplatings wrote:
> > > michaelplatings wrote:
> > > > The [[ 
> > > > https://cmake.org/cmake/help/latest/variable/CMAKE_TOOLCHAIN_FILE.html 
> > > > | documentation for CMAKE_SYSROOT  ]] says "This variable may only be 
> > > > set in a toolchain file specified by the CMAKE_TOOLCHAIN_FILE variable."
> > > > 
> > > > Maybe pass CMAKE_TOOLCHAIN_FILE through instead?
> > > `list(APPEND variable_that_may_or_may_not_exist ...` is quite fragile. 
> > > Should someone have `-Dextra_args=X` on their cmake command line then 
> > > that will be included here, which I don't think is the intent. I suggest 
> > > adding `set(extra_args "")` above the `if`. This also improves 
> > > readability because otherwise you have to scan the whole file to figure 
> > > out that `extra_args` wasn't previously defined.
> > That documentation is inaccurate. `CMAKE_SYSROOT` can be set outside of the 
> > toolchain file, and thus needs to be passed through as is frequently done 
> > in LLVM, see for example 
> > https://github.com/llvm/llvm-project/blob/7ca1bcbc6043b7ab4635f04746d1b9480960e384/llvm/cmake/modules/LLVMExternalProjectUtils.cmake#L261
> >  or 
> > https://github.com/llvm/llvm-project/blob/7ca1bcbc6043b7ab4635f04746d1b9480960e384/compiler-rt/cmake/Modules/AddCompilerRT.cmake#L650.
> Deviating from what's documented as permitted could cause a problem with 
> future CMake versions. But evidently this pattern is already established in 
> LLVM, and if it becomes a problem in future then it can be fixed at that time.
I agree, ideally we would use the same helper function everywhere where we need 
to invoke CMake as a subbuild so the passthrough is handled uniformly, but that 
can be done as a future improvement.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150752

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


[clang] 9e6e337 - [BOLT][CMake] Use correct output paths and passthrough necessary options

2023-05-19 Thread Petr Hosek via cfe-commits

Author: Petr Hosek
Date: 2023-05-19T17:43:27Z
New Revision: 9e6e3375f12e5e61dd2e371d94c263e3862f58a1

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

LOG: [BOLT][CMake] Use correct output paths and passthrough necessary options

This addresses https://github.com/llvm/llvm-project/issues/62748.

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

Added: 


Modified: 
bolt/CMakeLists.txt
bolt/runtime/CMakeLists.txt
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/bolt/CMakeLists.txt b/bolt/CMakeLists.txt
index 875a5cd8703c1..a9bc770a95e93 100644
--- a/bolt/CMakeLists.txt
+++ b/bolt/CMakeLists.txt
@@ -84,6 +84,10 @@ endif()
 
 if (BOLT_ENABLE_RUNTIME)
   message(STATUS "Building BOLT runtime libraries for X86")
+  set(extra_args "")
+  if(CMAKE_SYSROOT)
+list(APPEND extra_args -DCMAKE_SYSROOT=${CMAKE_SYSROOT})
+  endif()
   ExternalProject_Add(bolt_rt
 SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/runtime"
 STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/bolt_rt-stamps
@@ -92,8 +96,10 @@ if (BOLT_ENABLE_RUNTIME)
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
-   -DCMAKE_INSTALL_PREFIX=${LLVM_BINARY_DIR}
-DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX}
+   -DLLVM_LIBRARY_DIR=${LLVM_LIBRARY_DIR}
+   ${extra_args}
+INSTALL_COMMAND ""
 BUILD_ALWAYS True
 )
   install(CODE "execute_process\(COMMAND \${CMAKE_COMMAND} 
-DCMAKE_INSTALL_PREFIX=\${CMAKE_INSTALL_PREFIX} -P 
${CMAKE_CURRENT_BINARY_DIR}/bolt_rt-bins/cmake_install.cmake \)"

diff  --git a/bolt/runtime/CMakeLists.txt b/bolt/runtime/CMakeLists.txt
index 7d177f7c598b1..6aa8edb8424a3 100644
--- a/bolt/runtime/CMakeLists.txt
+++ b/bolt/runtime/CMakeLists.txt
@@ -15,12 +15,12 @@ add_library(bolt_rt_instr STATIC
   instr.cpp
   ${CMAKE_CURRENT_BINARY_DIR}/config.h
   )
-set_target_properties(bolt_rt_instr PROPERTIES LIBRARY_OUTPUT_DIRECTORY 
"lib${LLVM_LIBDIR_SUFFIX}")
+set_target_properties(bolt_rt_instr PROPERTIES ARCHIVE_OUTPUT_DIRECTORY 
"${LLVM_LIBRARY_DIR}")
 add_library(bolt_rt_hugify STATIC
   hugify.cpp
   ${CMAKE_CURRENT_BINARY_DIR}/config.h
   )
-set_target_properties(bolt_rt_hugify PROPERTIES LIBRARY_OUTPUT_DIRECTORY 
"lib${LLVM_LIBDIR_SUFFIX}")
+set_target_properties(bolt_rt_hugify PROPERTIES ARCHIVE_OUTPUT_DIRECTORY 
"${LLVM_LIBRARY_DIR}")
 
 set(BOLT_RT_FLAGS
   -ffreestanding
@@ -44,7 +44,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES ".*Clang.*")
 instr.cpp
 ${CMAKE_CURRENT_BINARY_DIR}/config.h
   )
-  set_target_properties(bolt_rt_instr_osx PROPERTIES LIBRARY_OUTPUT_DIRECTORY 
"lib${LLVM_LIBDIR_SUFFIX}")
+  set_target_properties(bolt_rt_instr_osx PROPERTIES ARCHIVE_OUTPUT_DIRECTORY 
"${LLVM_LIBRARY_DIR}")
   target_include_directories(bolt_rt_instr_osx PRIVATE 
${CMAKE_CURRENT_BINARY_DIR})
   target_compile_options(bolt_rt_instr_osx PRIVATE
 -target x86_64-apple-darwin19.6.0

diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 7778a7f84b051..8f5aa21be6fb8 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -294,7 +294,6 @@ set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "")
 set(LLVM_TOOLCHAIN_TOOLS
   dsymutil
   llvm-ar
-  llvm-bolt
   llvm-cov
   llvm-cxxfilt
   llvm-debuginfod-find
@@ -329,6 +328,7 @@ set(LLVM_TOOLCHAIN_TOOLS
   CACHE STRING "")
 
 set(LLVM_Toolchain_DISTRIBUTION_COMPONENTS
+  bolt
   clang
   lld
   clang-apply-replacements



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


[PATCH] D150752: [BOLT][CMake] Use correct output paths and passthrough necessary options

2023-05-19 Thread Petr Hosek 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 rG9e6e3375f12e: [BOLT][CMake] Use correct output paths and 
passthrough necessary options (authored by phosek).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150752

Files:
  bolt/CMakeLists.txt
  bolt/runtime/CMakeLists.txt
  clang/cmake/caches/Fuchsia-stage2.cmake


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -294,7 +294,6 @@
 set(LLVM_TOOLCHAIN_TOOLS
   dsymutil
   llvm-ar
-  llvm-bolt
   llvm-cov
   llvm-cxxfilt
   llvm-debuginfod-find
@@ -329,6 +328,7 @@
   CACHE STRING "")
 
 set(LLVM_Toolchain_DISTRIBUTION_COMPONENTS
+  bolt
   clang
   lld
   clang-apply-replacements
Index: bolt/runtime/CMakeLists.txt
===
--- bolt/runtime/CMakeLists.txt
+++ bolt/runtime/CMakeLists.txt
@@ -15,12 +15,12 @@
   instr.cpp
   ${CMAKE_CURRENT_BINARY_DIR}/config.h
   )
-set_target_properties(bolt_rt_instr PROPERTIES LIBRARY_OUTPUT_DIRECTORY 
"lib${LLVM_LIBDIR_SUFFIX}")
+set_target_properties(bolt_rt_instr PROPERTIES ARCHIVE_OUTPUT_DIRECTORY 
"${LLVM_LIBRARY_DIR}")
 add_library(bolt_rt_hugify STATIC
   hugify.cpp
   ${CMAKE_CURRENT_BINARY_DIR}/config.h
   )
-set_target_properties(bolt_rt_hugify PROPERTIES LIBRARY_OUTPUT_DIRECTORY 
"lib${LLVM_LIBDIR_SUFFIX}")
+set_target_properties(bolt_rt_hugify PROPERTIES ARCHIVE_OUTPUT_DIRECTORY 
"${LLVM_LIBRARY_DIR}")
 
 set(BOLT_RT_FLAGS
   -ffreestanding
@@ -44,7 +44,7 @@
 instr.cpp
 ${CMAKE_CURRENT_BINARY_DIR}/config.h
   )
-  set_target_properties(bolt_rt_instr_osx PROPERTIES LIBRARY_OUTPUT_DIRECTORY 
"lib${LLVM_LIBDIR_SUFFIX}")
+  set_target_properties(bolt_rt_instr_osx PROPERTIES ARCHIVE_OUTPUT_DIRECTORY 
"${LLVM_LIBRARY_DIR}")
   target_include_directories(bolt_rt_instr_osx PRIVATE 
${CMAKE_CURRENT_BINARY_DIR})
   target_compile_options(bolt_rt_instr_osx PRIVATE
 -target x86_64-apple-darwin19.6.0
Index: bolt/CMakeLists.txt
===
--- bolt/CMakeLists.txt
+++ bolt/CMakeLists.txt
@@ -84,6 +84,10 @@
 
 if (BOLT_ENABLE_RUNTIME)
   message(STATUS "Building BOLT runtime libraries for X86")
+  set(extra_args "")
+  if(CMAKE_SYSROOT)
+list(APPEND extra_args -DCMAKE_SYSROOT=${CMAKE_SYSROOT})
+  endif()
   ExternalProject_Add(bolt_rt
 SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/runtime"
 STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/bolt_rt-stamps
@@ -92,8 +96,10 @@
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
-   -DCMAKE_INSTALL_PREFIX=${LLVM_BINARY_DIR}
-DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX}
+   -DLLVM_LIBRARY_DIR=${LLVM_LIBRARY_DIR}
+   ${extra_args}
+INSTALL_COMMAND ""
 BUILD_ALWAYS True
 )
   install(CODE "execute_process\(COMMAND \${CMAKE_COMMAND} 
-DCMAKE_INSTALL_PREFIX=\${CMAKE_INSTALL_PREFIX} -P 
${CMAKE_CURRENT_BINARY_DIR}/bolt_rt-bins/cmake_install.cmake \)"


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -294,7 +294,6 @@
 set(LLVM_TOOLCHAIN_TOOLS
   dsymutil
   llvm-ar
-  llvm-bolt
   llvm-cov
   llvm-cxxfilt
   llvm-debuginfod-find
@@ -329,6 +328,7 @@
   CACHE STRING "")
 
 set(LLVM_Toolchain_DISTRIBUTION_COMPONENTS
+  bolt
   clang
   lld
   clang-apply-replacements
Index: bolt/runtime/CMakeLists.txt
===
--- bolt/runtime/CMakeLists.txt
+++ bolt/runtime/CMakeLists.txt
@@ -15,12 +15,12 @@
   instr.cpp
   ${CMAKE_CURRENT_BINARY_DIR}/config.h
   )
-set_target_properties(bolt_rt_instr PROPERTIES LIBRARY_OUTPUT_DIRECTORY "lib${LLVM_LIBDIR_SUFFIX}")
+set_target_properties(bolt_rt_instr PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${LLVM_LIBRARY_DIR}")
 add_library(bolt_rt_hugify STATIC
   hugify.cpp
   ${CMAKE_CURRENT_BINARY_DIR}/config.h
   )
-set_target_properties(bolt_rt_hugify PROPERTIES LIBRARY_OUTPUT_DIRECTORY "lib${LLVM_LIBDIR_SUFFIX}")
+set_target_properties(bolt_rt_hugify PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${LLVM_LIBRARY_DIR}")
 
 set(BOLT_RT_FLAGS
   -ffreestanding
@@ -44,7 +44,7 @@
 instr.cpp
 ${CMAKE_CURRENT_BINARY_DIR}/config.h
   )
-  set_target_properties(bolt_rt_instr_osx PROPERTIES LIBRARY_OUTPUT_DIRECTORY "lib${LLVM_LIBDIR_SUFFIX}")
+  set_target_properties(bolt_rt_instr_osx PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${LLVM_LIBRARY_DIR}")
   target_include_directories(bolt_rt_instr_osx PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
   target_compile_options(

[PATCH] D148505: Allow `__attribute__((warn_unused))` on individual constructors

2023-05-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D148505#4356951 , @erichkeane 
wrote:

> I'm still on the fence.  I think properly documenting all of this entire 
> attribute would make me more comfortable here, particularly since it will 
> allow GCC to follow us easily some day.  I think that would move the needle 
> for me.

I think I've got a slightly different idea there: let's add a new documentation 
section for all of the related attributes in this area and document (or update) 
all of them in a block. This way, users have a good way to answer "which one do 
I use in what circumstance?" as well as other compiler devs who want to match 
our behavior. I think if we can make the documentation sufficiently clear, then 
this is fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148505

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


[PATCH] D146358: [clang][AST] Print name instead of type when diagnosing uninitialized subobject in constexpr variables

2023-05-19 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet added a comment.

In D146358#4352792 , @erichkeane 
wrote:

> In D146358#4351787 , @hazohelet 
> wrote:
>
>> In D146358#4350810 , @erichkeane 
>> wrote:
>>
>>> Our downstream discovered that this causes a regression when compiling 
>>> `utility` with `ast-dump`.  I've put up a minimal reproducer: 
>>> https://godbolt.org/z/oaezas7Ws
>>>
>>> @hazohelet : Will you be able to look into this soon?
>>
>> Thanks for the report and the reproducer.
>> I cannot take sufficient time for about 36 hours, but I'll be able to 
>> investigate it after that.
>
> That is long enough away that I unfortunately have to revert (see 
> 34e49d3e85a6dd03856af0fb4b7f8d8ae1f4f06a 
> ). 
> Please note that in the LLVM project reverts are common/frequent (we have a 
> policy of 'revert often'), and should not be taken negatively!  Please feel 
> free to re-submit this patch with a fix/the test provided, and we'll 
> re-review promptly!

Thanks for the revert!

It seems that the problem is around the list initializer in template variable 
definition.
Minimum reproducible example:
`template  constexpr T foo{};`

When the `TextNodeDumper` enabled through `-ast-dump` visits a constexpr 
`VarDecl` with initializer, it evaluates the `VarDecl` and prints the value if 
evaluation comes successful.
(https://github.com/llvm/llvm-project/blob/55903151a2a505284ce3fcd955b1d394df0b55ea/clang/lib/AST/TextNodeDumper.cpp#L1825)
The `VarDecl::evaluateValue()` does not show the notes generated during its 
failed evaluation. The uninitialized-subobject note is actually generated 
BEFORE this patch when compiling the reproducers with `-ast-dump` flag on, but 
is not shown to the user.
The message should not be generated here and I assume this is an internal bug 
that we have to fix before resubmitting this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146358

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


[PATCH] D147916: [10/11][POC][Clang][RISCV] Define vget for tuple type

2023-05-19 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 523861.
eopXD added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147916

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vget_tuple.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vget-index-out-of-range.c


Index: 
clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vget-index-out-of-range.c
===
--- 
clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vget-index-out-of-range.c
+++ 
clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vget-index-out-of-range.c
@@ -339,3 +339,8 @@
   // expected-error@+1 {{argument value 2 is outside the valid range [0, 1]}}
   return __riscv_vget_v_f16m8_f16m4(src, 2);
 }
+
+vint32m1_t test_vget_v_i32m1x2_i32m1(vint32m1x2_t src) {
+  // expected-error@+1 {{argument value 2 is outside the valid range [0, 1]}}
+  return __riscv_vget_v_i32m1x2_i32m1(src, 2);
+}
Index: 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vget_tuple.c
===
--- /dev/null
+++ 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vget_tuple.c
@@ -0,0 +1,20 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 2
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zfh \
+// RUN:   -target-feature +experimental-zvfh -disable-O0-optnone  \
+// RUN:   -emit-llvm %s -o - | opt -S -passes=mem2reg | \
+// RUN:   FileCheck --check-prefix=CHECK-RV64 %s
+
+#include 
+
+// CHECK-RV64-LABEL: define dso_local  
@test_vget_v_i32m1x2_i32m1
+// CHECK-RV64-SAME: ( [[SRC_COERCE0:%.*]],  [[SRC_COERCE1:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { , 
 } poison,  [[SRC_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { , 
 } [[TMP0]],  [[SRC_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { , 
 } [[TMP1]], 0
+// CHECK-RV64-NEXT:ret  [[TMP2]]
+//
+vint32m1_t test_vget_v_i32m1x2_i32m1(vint32m1x2_t src) {
+  return __riscv_vget_v_i32m1x2_i32m1(src, 0);
+}
Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -332,6 +332,8 @@
   }
   if (isVector())
 ShortStr += LMUL.str();
+  if (isTuple())
+ShortStr += "x" + utostr(NF);
 }
 
 void RVVType::applyBasicType() {
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -4519,9 +4519,12 @@
 ASTContext::BuiltinVectorTypeInfo VecInfo =
 Context.getBuiltinVectorTypeInfo(cast(
 TheCall->getArg(0)->getType().getCanonicalType().getTypePtr()));
-unsigned MaxIndex =
-(VecInfo.EC.getKnownMinValue() * VecInfo.NumVectors) /
-(ResVecInfo.EC.getKnownMinValue() * ResVecInfo.NumVectors);
+unsigned MaxIndex;
+if (VecInfo.NumVectors != 1) // vget for tuple type
+  MaxIndex = VecInfo.NumVectors;
+else // vget for non-tuple type
+  MaxIndex = (VecInfo.EC.getKnownMinValue() * VecInfo.NumVectors) /
+ (ResVecInfo.EC.getKnownMinValue() * ResVecInfo.NumVectors);
 return SemaBuiltinConstantArgRange(TheCall, 1, 0, MaxIndex - 1);
   }
   case RISCVVector::BI__builtin_rvv_vset_v: {
Index: clang/include/clang/Basic/riscv_vector.td
===
--- clang/include/clang/Basic/riscv_vector.td
+++ clang/include/clang/Basic/riscv_vector.td
@@ -2536,6 +2536,11 @@
   let Name = "vget_v", MaskedPolicyScheme = NonePolicy,
   ManualCodegen = [{
   {
+if (isa(Ops[0]->getType())) // For tuple type
+  // Extract value from index (operand 1) of vtuple (operand 0)
+  return Builder.CreateExtractValue(
+Ops[0],
+{cast(Ops[1])->getZExtValue()});
 auto *VecTy = cast(ResultType);
 auto *OpVecTy = cast(Ops[0]->getType());
 // Mask to only valid indices.
@@ -2553,6 +2558,12 @@
   def : RVVBuiltin<"v" # dst_lmul # "v", dst_lmul # "vvKz", "csilxfd", 
dst_lmul # "v">;
   def : RVVBuiltin<"Uv" # dst_lmul # "Uv", dst_lmul # "UvUvKz", "csil", 
dst_lmul # "Uv">;
 }
+foreach nf = [2] in {
+  let Log2LMUL = [0] in {
+defvar T = "(Tuple:" # nf # ")";
+def : RVVBuiltin;
+  }
+}
   }
 
   let Name = "vset_v", Log2LMUL = [0, 1, 2], MaskedPolicyScheme = NonePolicy,


Index: clang/test/CodeGen/RISCV/rvv-

[PATCH] D147917: [11/11][POC][Clang][RISCV] Define vset for tuple type

2023-05-19 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 523862.
eopXD added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147917

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/Sema/SemaChecking.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vset_tuple.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vset-index-out-of-range.c


Index: 
clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vset-index-out-of-range.c
===
--- 
clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vset-index-out-of-range.c
+++ 
clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vset-index-out-of-range.c
@@ -339,3 +339,8 @@
   // expected-error@+1 {{argument value 2 is outside the valid range [0, 1]}}
   return __riscv_vset_v_f16m4_f16m8(dest, 2, val);
 }
+
+vint32m1x2_t test_vset_v_i32m1x2_i32m1(vint32m1x2_t dest, vint32m1_t val) {
+  // expected-error@+1 {{argument value 2 is outside the valid range [0, 1]}}
+  return __riscv_vset_v_i32m1x2_i32m1(dest, 2, val);
+}
Index: 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vset_tuple.c
===
--- /dev/null
+++ 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vset_tuple.c
@@ -0,0 +1,20 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 2
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zfh \
+// RUN:   -target-feature +experimental-zvfh -disable-O0-optnone  \
+// RUN:   -emit-llvm %s -o - | opt -S -passes=mem2reg | \
+// RUN:   FileCheck --check-prefix=CHECK-RV64 %s
+
+#include 
+
+// CHECK-RV64-LABEL: define dso_local { ,  
} @test_vset_v_i32m1x2_i32m1
+// CHECK-RV64-SAME: ( [[DEST_COERCE0:%.*]],  [[DEST_COERCE1:%.*]],  [[VAL:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { , 
 } poison,  [[DEST_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { , 
 } [[TMP0]],  [[DEST_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = insertvalue { , 
 } [[TMP1]],  [[VAL]], 0
+// CHECK-RV64-NEXT:ret { ,  } [[TMP2]]
+//
+vint32m1x2_t test_vset_v_i32m1x2_i32m1(vint32m1x2_t dest, vint32m1_t val) {
+  return __riscv_vset_v_i32m1x2_i32m1(dest, 0, val);
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -4534,9 +4534,12 @@
 ASTContext::BuiltinVectorTypeInfo VecInfo =
 Context.getBuiltinVectorTypeInfo(cast(
 TheCall->getArg(2)->getType().getCanonicalType().getTypePtr()));
-unsigned MaxIndex =
-(ResVecInfo.EC.getKnownMinValue() * ResVecInfo.NumVectors) /
-(VecInfo.EC.getKnownMinValue() * VecInfo.NumVectors);
+unsigned MaxIndex;
+if (ResVecInfo.NumVectors != 1) // vset for tuple type
+  MaxIndex = ResVecInfo.NumVectors;
+else // vset fo non-tuple type
+  MaxIndex = (ResVecInfo.EC.getKnownMinValue() * ResVecInfo.NumVectors) /
+ (VecInfo.EC.getKnownMinValue() * VecInfo.NumVectors);
 return SemaBuiltinConstantArgRange(TheCall, 1, 0, MaxIndex - 1);
   }
   case RISCVVector::BI__builtin_rvv_sf_vc_i_se_u8mf8:
Index: clang/include/clang/Basic/riscv_vector.td
===
--- clang/include/clang/Basic/riscv_vector.td
+++ clang/include/clang/Basic/riscv_vector.td
@@ -2569,6 +2569,10 @@
   let Name = "vset_v", Log2LMUL = [0, 1, 2], MaskedPolicyScheme = NonePolicy,
   ManualCodegen = [{
   {
+if (isa(ResultType)) // For tuple type
+  // Insert value (operand 2) into index (operand 1) of vtuple 
(operand 0)
+  return Builder.CreateInsertValue(Ops[0], Ops[2],
+   
{cast(Ops[1])->getZExtValue()});
 auto *ResVecTy = cast(ResultType);
 auto *VecTy = cast(Ops[2]->getType());
 // Mask to only valid indices.
@@ -2586,5 +2590,11 @@
   def : RVVBuiltin<"v" # dst_lmul # "v", dst_lmul # "v" # dst_lmul # 
"vKzv", "csilxfd">;
   def : RVVBuiltin<"Uv" # dst_lmul # "Uv", dst_lmul # "Uv" # dst_lmul 
#"UvKzUv", "csil">;
 }
+foreach nf = [2] in {
+  let Log2LMUL = [0] in {
+defvar T = "(Tuple:" # nf # ")";
+def : RVVBuiltin;
+  }
+}
   }
 }


Index: clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vset-index-out-of-range.c
===
--- clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vset-index-out-of-range.c
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vset-index-out-of-range.c
@@ -339,3 +339,8 @@
   // expected-error@+1 {{argument va

[PATCH] D150820: [NVPTX, CUDA] added optional src_size argument to __nvvm_cp_async*

2023-05-19 Thread Artem Belevich 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 rG6963c61f0f6e: [NVPTX/CUDA] added an optional src_size 
argument to __nvvm_cp_async* (authored by tra).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150820

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-nvptx.c
  clang/test/SemaCUDA/builtins.cu
  llvm/include/llvm/IR/IntrinsicsNVVM.td
  llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
  llvm/test/CodeGen/NVPTX/async-copy.ll

Index: llvm/test/CodeGen/NVPTX/async-copy.ll
===
--- llvm/test/CodeGen/NVPTX/async-copy.ll
+++ llvm/test/CodeGen/NVPTX/async-copy.ll
@@ -1,35 +1,35 @@
-; RUN: llc < %s -march=nvptx -mcpu=sm_80 -mattr=+ptx70 | FileCheck -check-prefixes=ALL,CHECK_PTX32 %s
-; RUN: llc < %s -march=nvptx64 -mcpu=sm_80 -mattr=+ptx70 | FileCheck -check-prefixes=ALL,CHECK_PTX64 %s
+; RUN: llc < %s -march=nvptx -mcpu=sm_80 -mattr=+ptx70 | FileCheck -check-prefixes=CHECK,CHECK_PTX32 %s
+; RUN: llc < %s -march=nvptx64 -mcpu=sm_80 -mattr=+ptx70 | FileCheck -check-prefixes=CHECK,CHECK_PTX64 %s
 ; RUN: %if ptxas-11.0 %{ llc < %s -march=nvptx -mcpu=sm_80 -mattr=+ptx70 | %ptxas-verify -arch=sm_80 %}
 ; RUN: %if ptxas-11.0 %{ llc < %s -march=nvptx64 -mcpu=sm_80 -mattr=+ptx70 | %ptxas-verify -arch=sm_80 %}
 
 declare void @llvm.nvvm.cp.async.wait.group(i32)
 
-; ALL-LABEL: asyncwaitgroup
+; CHECK-LABEL: asyncwaitgroup
 define void @asyncwaitgroup() {
-  ; ALL: cp.async.wait_group 8;
+  ; CHECK: cp.async.wait_group 8;
   tail call void @llvm.nvvm.cp.async.wait.group(i32 8)
-  ; ALL: cp.async.wait_group 0;
+  ; CHECK: cp.async.wait_group 0;
   tail call void @llvm.nvvm.cp.async.wait.group(i32 0)
-  ; ALL: cp.async.wait_group 16;
+  ; CHECK: cp.async.wait_group 16;
   tail call void @llvm.nvvm.cp.async.wait.group(i32 16)
   ret void
 }
 
 declare void @llvm.nvvm.cp.async.wait.all()
 
-; ALL-LABEL: asyncwaitall
+; CHECK-LABEL: asyncwaitall
 define void @asyncwaitall() {
-; ALL: cp.async.wait_all
+; CHECK: cp.async.wait_all
   tail call void @llvm.nvvm.cp.async.wait.all()
   ret void
 }
 
 declare void @llvm.nvvm.cp.async.commit.group()
 
-; ALL-LABEL: asynccommitgroup
+; CHECK-LABEL: asynccommitgroup
 define void @asynccommitgroup() {
-; ALL: cp.async.commit_group
+; CHECK: cp.async.commit_group
   tail call void @llvm.nvvm.cp.async.commit.group()
   ret void
 }
@@ -41,72 +41,87 @@
 
 ; CHECK-LABEL: asyncmbarrier
 define void @asyncmbarrier(ptr %a) {
-; CHECK_PTX32: cp.async.mbarrier.arrive.b64 [%r{{[0-9]+}}];
-; CHECK_PTX64: cp.async.mbarrier.arrive.b64 [%rd{{[0-9]+}}];
+; The distinction between PTX32/PTX64 here is only to capture pointer register type
+; in R to be used in subsequent tests.
+; CHECK_PTX32: cp.async.mbarrier.arrive.b64 [%[[R:r]]{{[0-9]+}}];
+; CHECK_PTX64: cp.async.mbarrier.arrive.b64 [%[[R:rd]]{{[0-9]+}}];
   tail call void @llvm.nvvm.cp.async.mbarrier.arrive(ptr %a)
   ret void
 }
 
 ; CHECK-LABEL: asyncmbarriershared
 define void @asyncmbarriershared(ptr addrspace(3) %a) {
-; CHECK_PTX32: cp.async.mbarrier.arrive.shared.b64 [%r{{[0-9]+}}];
-; CHECK_PTX64: cp.async.mbarrier.arrive.shared.b64 [%rd{{[0-9]+}}];
+; CHECK: cp.async.mbarrier.arrive.shared.b64 [%[[R]]{{[0-9]+}}];
   tail call void @llvm.nvvm.cp.async.mbarrier.arrive.shared(ptr addrspace(3) %a)
   ret void
 }
 
 ; CHECK-LABEL: asyncmbarriernoinc
 define void @asyncmbarriernoinc(ptr %a) {
-; CHECK_PTX32: cp.async.mbarrier.arrive.noinc.b64 [%r{{[0-9]+}}];
-; CHECK_PTX64: cp.async.mbarrier.arrive.noinc.b64 [%rd{{[0-9]+}}];
+; CHECK_PTX64: cp.async.mbarrier.arrive.noinc.b64 [%[[R]]{{[0-9]+}}];
   tail call void @llvm.nvvm.cp.async.mbarrier.arrive.noinc(ptr %a)
   ret void
 }
 
 ; CHECK-LABEL: asyncmbarriernoincshared
 define void @asyncmbarriernoincshared(ptr addrspace(3) %a) {
-; CHECK_PTX32: cp.async.mbarrier.arrive.noinc.shared.b64 [%r{{[0-9]+}}];
-; CHECK_PTX64: cp.async.mbarrier.arrive.noinc.shared.b64 [%rd{{[0-9]+}}];
+; CHECK: cp.async.mbarrier.arrive.noinc.shared.b64 [%[[R]]{{[0-9]+}}];
   tail call void @llvm.nvvm.cp.async.mbarrier.arrive.noinc.shared(ptr addrspace(3) %a)
   ret void
 }
 
 declare void @llvm.nvvm.cp.async.ca.shared.global.4(ptr addrspace(3) %a, ptr addrspace(1) %b)
+declare void @llvm.nvvm.cp.async.ca.shared.global.4.s(ptr addrspace(3) %a, ptr addrspace(1) %b, i32 %c)
 
 ; CHECK-LABEL: asynccasharedglobal4i8
-define void @asynccasharedglobal4i8(ptr addrspace(3) %a, ptr addrspace(1) %b) {
-; CHECK_PTX32: cp.async.ca.shared.global [%r{{[0-9]+}}], [%r{{[0-9]+}}], 4;
-; CHECK_PTX64: cp.async.ca.shared.global [%rd{{[0-9]+}}], [%rd{{[0-9]+}}], 4;
+define void @asynccasharedglobal4i8(ptr addrspace(3) %a, ptr addrspace(1) %b, i32 %c) {
+; CHECK: cp.async.ca.

[clang] 6963c61 - [NVPTX/CUDA] added an optional src_size argument to __nvvm_cp_async*

2023-05-19 Thread Artem Belevich via cfe-commits

Author: Artem Belevich
Date: 2023-05-19T10:59:36-07:00
New Revision: 6963c61f0f6e4be2039cb45e824ea1e83a8f1526

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

LOG: [NVPTX/CUDA] added an optional src_size argument to __nvvm_cp_async*

The optional argument is needed for CUDA-11+ headers when we're compiling for
sm_80+ GPUs.

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

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsNVPTX.def
clang/include/clang/Sema/Sema.h
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Sema/SemaChecking.cpp
clang/test/CodeGen/builtins-nvptx.c
clang/test/SemaCUDA/builtins.cu
llvm/include/llvm/IR/IntrinsicsNVVM.td
llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
llvm/test/CodeGen/NVPTX/async-copy.ll

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsNVPTX.def 
b/clang/include/clang/Basic/BuiltinsNVPTX.def
index 96531def77a78..9179fa47eb690 100644
--- a/clang/include/clang/Basic/BuiltinsNVPTX.def
+++ b/clang/include/clang/Basic/BuiltinsNVPTX.def
@@ -968,10 +968,10 @@ TARGET_BUILTIN(__nvvm_cp_async_mbarrier_arrive_shared, 
"vWi*3", "", AND(SM_80,PT
 TARGET_BUILTIN(__nvvm_cp_async_mbarrier_arrive_noinc, "vWi*", "", 
AND(SM_80,PTX70))
 TARGET_BUILTIN(__nvvm_cp_async_mbarrier_arrive_noinc_shared, "vWi*3", "", 
AND(SM_80,PTX70))
 
-TARGET_BUILTIN(__nvvm_cp_async_ca_shared_global_4, "vv*3vC*1", "", 
AND(SM_80,PTX70))
-TARGET_BUILTIN(__nvvm_cp_async_ca_shared_global_8, "vv*3vC*1", "", 
AND(SM_80,PTX70))
-TARGET_BUILTIN(__nvvm_cp_async_ca_shared_global_16, "vv*3vC*1", "", 
AND(SM_80,PTX70))
-TARGET_BUILTIN(__nvvm_cp_async_cg_shared_global_16, "vv*3vC*1", "", 
AND(SM_80,PTX70))
+TARGET_BUILTIN(__nvvm_cp_async_ca_shared_global_4, "vv*3vC*1.", "", 
AND(SM_80,PTX70))
+TARGET_BUILTIN(__nvvm_cp_async_ca_shared_global_8, "vv*3vC*1.", "", 
AND(SM_80,PTX70))
+TARGET_BUILTIN(__nvvm_cp_async_ca_shared_global_16, "vv*3vC*1.", "", 
AND(SM_80,PTX70))
+TARGET_BUILTIN(__nvvm_cp_async_cg_shared_global_16, "vv*3vC*1.", "", 
AND(SM_80,PTX70))
 
 TARGET_BUILTIN(__nvvm_cp_async_commit_group, "v", "", AND(SM_80,PTX70))
 TARGET_BUILTIN(__nvvm_cp_async_wait_group, "vIi", "", AND(SM_80,PTX70))

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 6e2734da2bea6..bc6fb74df4d62 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -13564,6 +13564,8 @@ class Sema final {
   bool CheckWebAssemblyBuiltinFunctionCall(const TargetInfo &TI,
unsigned BuiltinID,
CallExpr *TheCall);
+  bool CheckNVPTXBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
+ CallExpr *TheCall);
 
   bool SemaBuiltinVAStart(unsigned BuiltinID, CallExpr *TheCall);
   bool SemaBuiltinVAStartARMMicrosoft(CallExpr *Call);

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 02345651f0abb..b4dae69702608 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -18177,6 +18177,19 @@ static Value *MakeScopedAtomic(unsigned IntrinsicID, 
CodeGenFunction &CGF,
   {Ptr, CGF.EmitScalarExpr(E->getArg(1))});
 }
 
+static Value *MakeCpAsync(unsigned IntrinsicID, unsigned IntrinsicIDS,
+  CodeGenFunction &CGF, const CallExpr *E,
+  int SrcSize) {
+  return E->getNumArgs() == 3
+ ? CGF.Builder.CreateCall(CGF.CGM.getIntrinsic(IntrinsicIDS),
+  {CGF.EmitScalarExpr(E->getArg(0)),
+   CGF.EmitScalarExpr(E->getArg(1)),
+   CGF.EmitScalarExpr(E->getArg(2))})
+ : CGF.Builder.CreateCall(CGF.CGM.getIntrinsic(IntrinsicID),
+  {CGF.EmitScalarExpr(E->getArg(0)),
+   CGF.EmitScalarExpr(E->getArg(1))});
+}
+
 static Value *MakeHalfType(unsigned IntrinsicID, unsigned BuiltinID,
const CallExpr *E, CodeGenFunction &CGF) {
   auto &C = CGF.CGM.getContext();
@@ -18840,6 +18853,22 @@ Value *CodeGenFunction::EmitNVPTXBuiltinExpr(unsigned 
BuiltinID,
   case NVPTX::BI__nvvm_ldu_h2: {
 return MakeHalfType(Intrinsic::nvvm_ldu_global_f, BuiltinID, E, *this);
   }
+  case NVPTX::BI__nvvm_cp_async_ca_shared_global_4:
+return MakeCpAsync(Intrinsic::nvvm_cp_async_ca_shared_global_4,
+   Intrinsic::nvvm_cp_async_ca_shared_global_4_s, *this, E,
+   4);
+  case NVPTX::BI__nvvm_cp_async_ca_shared_global_8:
+return MakeCpAsync(Intrinsic::nvvm_cp_async_ca_shared_global_8,
+   Intrinsic::nvvm_cp_async_ca_shared_global_8_s, *th

[PATCH] D150965: [HIP] Allow std::malloc in device function

2023-05-19 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/test/Headers/Inputs/include/math.h:108-109
 long lroundf(float __a);
-int max(int __a, int __b);
-int min(int __a, int __b);
 double modf(double __a, double *__b);

tra wrote:
> Why were these functions removed? It does not seem related to the changes in 
> the patch?
These functions caused failure in the added lit test.

For C++, max/min are defined as templates in . There is no max/min 
in either standard C or C++ math.h. Their existence cause false alarms in lit 
tests. Removing them to be consistent with standard C/C++ headers.


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

https://reviews.llvm.org/D150965

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


[PATCH] D149677: [clang][TypePrinter] Add option to skip over elaborated types

2023-05-19 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D149677#4356863 , @aaron.ballman 
wrote:

> In D149677#4350337 , @li.zhe.hua 
> wrote:
>
>> In D149677#4349523 , 
>> @aaron.ballman wrote:
>>
>>> In D149677#4320178 , @li.zhe.hua 
>>> wrote:
>>>
 Some additional context: I'm working on a refactoring tool to, in part, 
 deprecate an alias by replacing it with its definition. That functionality 
 by itself could be provided through something like a clang-tidy, so I say 
 "initially".
>>>
>>> We typically don't add new printing policies in tree without some need for 
>>> them in the project itself (otherwise this becomes a maintenance problem), 
>>> and I'm not certain I see a strong need for this to live in Clang. I think 
>>> it might be best to wait until you're closer to having a clang-tidy check 
>>> that would use this functionality before we continue with this patch. WDYT?
>>
>> I believe there is value for having this option, as without it, the 
>> `PrintingCallbacks::isScopeVisible` callback is effectively useless in 
>> practice. It won't be triggered in non-canonical types because the 
>> `ElaboratedType` represents a fixed qualification on the name.
>>
>> Note: there may be an argument for folding this functionality directly into 
>> `FullyQualifiedName` (which currently affects template-ids despite the 
>> comment on it suggesting it only is for function names). If the template 
>> name was elaborated, `FullyQualifiedName` does nothing, which seems 
>> inconsistent/incorrect.
>
> Adding @dblaikie as he might have some opinions here.

Not sure I'm quite understanding everything going on here, but I think it's a 
reasonable request that the change be observable in some way in addition 
to/other than a unit test. If not, yeah, maybe wait until it can be/the work 
where it is used is at least up on phab.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149677

___
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-05-19 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/include/clang/Basic/IdentifierTable.h:316
+  unsigned getInterestingIdentifierID() {
+if (ObjCOrBuiltinID >= 1341 &&  ObjCOrBuiltinID < 1343)
+  return ObjCOrBuiltinID;

This is closer to the right approach, thanks.  I think the best way to do this 
is to put the ObjC keywords first, then the interesting identifiers, then the 
builtins.  That means the builtin ID code above should check for / add / 
subtract `tok::NUM_OBJC_KEYWORDS + tok::NUM_INTERESTING_IDENTIFIERS`; please 
add a `FirstBuiltinID` constant for that in this class so that we can more 
easily rework things in the future (e.g. if we decide to stuff more things into 
this field).  And then the code for InterestingIdentifierID should add/subtract 
`tok::NUM_OBJC_KEYWORDS`; again, please add a `FirstInterestingIdentifier` 
constant for that.

Please make these two functions use `tok::InterestingIdentifierKind`.  For 
`getInterestingIdentifierID()`, you'll have to decide how you want to represent 
that something isn't an interesting identifier. `ObjCKeywordKind` has a special 
enumerator (`not_keyword`) at value 0, so you could do the same thing here, but 
I think it might be better to use `llvm::Optional`.


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] D147916: [10/11][POC][Clang][RISCV] Define vget for tuple type

2023-05-19 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 523865.
eopXD added a comment.

Add unsigned cast to eliminate compile warning.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147916

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vget_tuple.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vget-index-out-of-range.c


Index: 
clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vget-index-out-of-range.c
===
--- 
clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vget-index-out-of-range.c
+++ 
clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vget-index-out-of-range.c
@@ -339,3 +339,8 @@
   // expected-error@+1 {{argument value 2 is outside the valid range [0, 1]}}
   return __riscv_vget_v_f16m8_f16m4(src, 2);
 }
+
+vint32m1_t test_vget_v_i32m1x2_i32m1(vint32m1x2_t src) {
+  // expected-error@+1 {{argument value 2 is outside the valid range [0, 1]}}
+  return __riscv_vget_v_i32m1x2_i32m1(src, 2);
+}
Index: 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vget_tuple.c
===
--- /dev/null
+++ 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vget_tuple.c
@@ -0,0 +1,20 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 2
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zfh \
+// RUN:   -target-feature +experimental-zvfh -disable-O0-optnone  \
+// RUN:   -emit-llvm %s -o - | opt -S -passes=mem2reg | \
+// RUN:   FileCheck --check-prefix=CHECK-RV64 %s
+
+#include 
+
+// CHECK-RV64-LABEL: define dso_local  
@test_vget_v_i32m1x2_i32m1
+// CHECK-RV64-SAME: ( [[SRC_COERCE0:%.*]],  [[SRC_COERCE1:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { , 
 } poison,  [[SRC_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { , 
 } [[TMP0]],  [[SRC_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { , 
 } [[TMP1]], 0
+// CHECK-RV64-NEXT:ret  [[TMP2]]
+//
+vint32m1_t test_vget_v_i32m1x2_i32m1(vint32m1x2_t src) {
+  return __riscv_vget_v_i32m1x2_i32m1(src, 0);
+}
Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -332,6 +332,8 @@
   }
   if (isVector())
 ShortStr += LMUL.str();
+  if (isTuple())
+ShortStr += "x" + utostr(NF);
 }
 
 void RVVType::applyBasicType() {
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -4519,9 +4519,12 @@
 ASTContext::BuiltinVectorTypeInfo VecInfo =
 Context.getBuiltinVectorTypeInfo(cast(
 TheCall->getArg(0)->getType().getCanonicalType().getTypePtr()));
-unsigned MaxIndex =
-(VecInfo.EC.getKnownMinValue() * VecInfo.NumVectors) /
-(ResVecInfo.EC.getKnownMinValue() * ResVecInfo.NumVectors);
+unsigned MaxIndex;
+if (VecInfo.NumVectors != 1) // vget for tuple type
+  MaxIndex = VecInfo.NumVectors;
+else // vget for non-tuple type
+  MaxIndex = (VecInfo.EC.getKnownMinValue() * VecInfo.NumVectors) /
+ (ResVecInfo.EC.getKnownMinValue() * ResVecInfo.NumVectors);
 return SemaBuiltinConstantArgRange(TheCall, 1, 0, MaxIndex - 1);
   }
   case RISCVVector::BI__builtin_rvv_vset_v: {
Index: clang/include/clang/Basic/riscv_vector.td
===
--- clang/include/clang/Basic/riscv_vector.td
+++ clang/include/clang/Basic/riscv_vector.td
@@ -2536,6 +2536,11 @@
   let Name = "vget_v", MaskedPolicyScheme = NonePolicy,
   ManualCodegen = [{
   {
+if (isa(Ops[0]->getType())) // For tuple type
+  // Extract value from index (operand 1) of vtuple (operand 0)
+  return Builder.CreateExtractValue(
+Ops[0],
+{(unsigned)cast(Ops[1])->getZExtValue()});
 auto *VecTy = cast(ResultType);
 auto *OpVecTy = cast(Ops[0]->getType());
 // Mask to only valid indices.
@@ -2553,6 +2558,12 @@
   def : RVVBuiltin<"v" # dst_lmul # "v", dst_lmul # "vvKz", "csilxfd", 
dst_lmul # "v">;
   def : RVVBuiltin<"Uv" # dst_lmul # "Uv", dst_lmul # "UvUvKz", "csil", 
dst_lmul # "Uv">;
 }
+foreach nf = [2] in {
+  let Log2LMUL = [0] in {
+defvar T = "(Tuple:" # nf # ")";
+def : RVVBuiltin;
+  }
+}
   }
 
   let Name = "vset_v", Log2LMUL = [0, 1, 2], MaskedPolicyScheme = 

[PATCH] D147917: [11/11][POC][Clang][RISCV] Define vset for tuple type

2023-05-19 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 523867.
eopXD added a comment.

Add unsigned cast to eliminate compile warning.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147917

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/Sema/SemaChecking.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vset_tuple.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vset-index-out-of-range.c


Index: 
clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vset-index-out-of-range.c
===
--- 
clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vset-index-out-of-range.c
+++ 
clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vset-index-out-of-range.c
@@ -339,3 +339,8 @@
   // expected-error@+1 {{argument value 2 is outside the valid range [0, 1]}}
   return __riscv_vset_v_f16m4_f16m8(dest, 2, val);
 }
+
+vint32m1x2_t test_vset_v_i32m1x2_i32m1(vint32m1x2_t dest, vint32m1_t val) {
+  // expected-error@+1 {{argument value 2 is outside the valid range [0, 1]}}
+  return __riscv_vset_v_i32m1x2_i32m1(dest, 2, val);
+}
Index: 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vset_tuple.c
===
--- /dev/null
+++ 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vset_tuple.c
@@ -0,0 +1,20 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 2
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zfh \
+// RUN:   -target-feature +experimental-zvfh -disable-O0-optnone  \
+// RUN:   -emit-llvm %s -o - | opt -S -passes=mem2reg | \
+// RUN:   FileCheck --check-prefix=CHECK-RV64 %s
+
+#include 
+
+// CHECK-RV64-LABEL: define dso_local { ,  
} @test_vset_v_i32m1x2_i32m1
+// CHECK-RV64-SAME: ( [[DEST_COERCE0:%.*]],  [[DEST_COERCE1:%.*]],  [[VAL:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { , 
 } poison,  [[DEST_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { , 
 } [[TMP0]],  [[DEST_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = insertvalue { , 
 } [[TMP1]],  [[VAL]], 0
+// CHECK-RV64-NEXT:ret { ,  } [[TMP2]]
+//
+vint32m1x2_t test_vset_v_i32m1x2_i32m1(vint32m1x2_t dest, vint32m1_t val) {
+  return __riscv_vset_v_i32m1x2_i32m1(dest, 0, val);
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -4534,9 +4534,12 @@
 ASTContext::BuiltinVectorTypeInfo VecInfo =
 Context.getBuiltinVectorTypeInfo(cast(
 TheCall->getArg(2)->getType().getCanonicalType().getTypePtr()));
-unsigned MaxIndex =
-(ResVecInfo.EC.getKnownMinValue() * ResVecInfo.NumVectors) /
-(VecInfo.EC.getKnownMinValue() * VecInfo.NumVectors);
+unsigned MaxIndex;
+if (ResVecInfo.NumVectors != 1) // vset for tuple type
+  MaxIndex = ResVecInfo.NumVectors;
+else // vset fo non-tuple type
+  MaxIndex = (ResVecInfo.EC.getKnownMinValue() * ResVecInfo.NumVectors) /
+ (VecInfo.EC.getKnownMinValue() * VecInfo.NumVectors);
 return SemaBuiltinConstantArgRange(TheCall, 1, 0, MaxIndex - 1);
   }
   case RISCVVector::BI__builtin_rvv_sf_vc_i_se_u8mf8:
Index: clang/include/clang/Basic/riscv_vector.td
===
--- clang/include/clang/Basic/riscv_vector.td
+++ clang/include/clang/Basic/riscv_vector.td
@@ -2569,6 +2569,11 @@
   let Name = "vset_v", Log2LMUL = [0, 1, 2], MaskedPolicyScheme = NonePolicy,
   ManualCodegen = [{
   {
+if (isa(ResultType)) // For tuple type
+  // Insert value (operand 2) into index (operand 1) of vtuple 
(operand 0)
+  return Builder.CreateInsertValue(
+Ops[0], Ops[2],
+{(unsigned)cast(Ops[1])->getZExtValue()});
 auto *ResVecTy = cast(ResultType);
 auto *VecTy = cast(Ops[2]->getType());
 // Mask to only valid indices.
@@ -2586,5 +2591,11 @@
   def : RVVBuiltin<"v" # dst_lmul # "v", dst_lmul # "v" # dst_lmul # 
"vKzv", "csilxfd">;
   def : RVVBuiltin<"Uv" # dst_lmul # "Uv", dst_lmul # "Uv" # dst_lmul 
#"UvKzUv", "csil">;
 }
+foreach nf = [2] in {
+  let Log2LMUL = [0] in {
+defvar T = "(Tuple:" # nf # ")";
+def : RVVBuiltin;
+  }
+}
   }
 }


Index: clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vset-index-out-of-range.c
===
--- clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vset-index-out-of-range.c
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vset-index-out-of-range.c
@@ -339,3 +339,8 @@
   //

[PATCH] D150985: [clang] Allow fp in atomic fetch max/min builtins

2023-05-19 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: rjmccall, tra.
Herald added subscribers: kerbowa, jvesely.
Herald added a project: All.
yaxunl requested review of this revision.

LLVM IR already allows floating point type in atomicrmw.
Update clang atomic fetch max/min builtins to accept
floating point type like we did for fetch add/sub.


https://reviews.llvm.org/D150985

Files:
  clang/lib/CodeGen/CGAtomic.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGenCUDA/amdgpu-atomic-ops.cu
  clang/test/Sema/atomic-ops.c
  clang/test/SemaOpenCL/atomic-ops.cl

Index: clang/test/SemaOpenCL/atomic-ops.cl
===
--- clang/test/SemaOpenCL/atomic-ops.cl
+++ clang/test/SemaOpenCL/atomic-ops.cl
@@ -61,8 +61,8 @@
 
   __opencl_atomic_fetch_min(i, 1, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_fetch_max(i, 1, memory_order_seq_cst, memory_scope_work_group);
-  __opencl_atomic_fetch_min(f, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to atomic integer ('__generic atomic_float *' (aka '__generic _Atomic(float) *') invalid)}}
-  __opencl_atomic_fetch_max(f, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to atomic integer ('__generic atomic_float *' (aka '__generic _Atomic(float) *') invalid)}}
+  __opencl_atomic_fetch_min(f, 1, memory_order_seq_cst, memory_scope_work_group);
+  __opencl_atomic_fetch_max(f, 1, memory_order_seq_cst, memory_scope_work_group);
 
   bool cmpexch_1 = __opencl_atomic_compare_exchange_strong(i, I, 1, memory_order_seq_cst, memory_order_seq_cst, memory_scope_work_group);
   bool cmpexch_2 = __opencl_atomic_compare_exchange_strong(p, P, 1, memory_order_seq_cst, memory_order_seq_cst, memory_scope_work_group);
Index: clang/test/Sema/atomic-ops.c
===
--- clang/test/Sema/atomic-ops.c
+++ clang/test/Sema/atomic-ops.c
@@ -205,8 +205,8 @@
   __atomic_fetch_sub(P, 3, memory_order_seq_cst);
   __atomic_fetch_sub(D, 3, memory_order_seq_cst);
   __atomic_fetch_sub(s1, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer, pointer or supported floating point type}}
-  __atomic_fetch_min(D, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer}}
-  __atomic_fetch_max(P, 3, memory_order_seq_cst); // expected-error {{must be a pointer to integer}}
+  __atomic_fetch_min(D, 3, memory_order_seq_cst);
+  __atomic_fetch_max(P, 3, memory_order_seq_cst);
   __atomic_fetch_max(p, 3);   // expected-error {{too few arguments to function call, expected 3, have 2}}
 
   __c11_atomic_fetch_and(i, 1, memory_order_seq_cst);
Index: clang/test/CodeGenCUDA/amdgpu-atomic-ops.cu
===
--- clang/test/CodeGenCUDA/amdgpu-atomic-ops.cu
+++ clang/test/CodeGenCUDA/amdgpu-atomic-ops.cu
@@ -1,29 +1,98 @@
-// RUN: %clang_cc1 %s -emit-llvm -o - -triple=amdgcn-amd-amdhsa \
+// RUN: %clang_cc1 -x hip %s -emit-llvm -o - -triple=amdgcn-amd-amdhsa \
 // RUN:   -fcuda-is-device -target-cpu gfx906 -fnative-half-type \
 // RUN:   -fnative-half-arguments-and-returns | FileCheck %s
 
+// RUN: %clang_cc1 -x hip %s -O3 -S -o - -triple=amdgcn-amd-amdhsa \
+// RUN:   -fcuda-is-device -target-cpu gfx1100 -fnative-half-type \
+// RUN:   -fnative-half-arguments-and-returns | FileCheck -check-prefix=SAFE %s
+
+// RUN: %clang_cc1 -x hip %s -O3 -S -o - -triple=amdgcn-amd-amdhsa \
+// RUN:   -fcuda-is-device -target-cpu gfx940 -fnative-half-type \
+// RUN:   -fnative-half-arguments-and-returns -munsafe-fp-atomics \
+// RUN:   | FileCheck -check-prefix=UNSAFE %s
+
 // REQUIRES: amdgpu-registered-target
 
 #include "Inputs/cuda.h"
 #include 
 
-__device__ float ffp1(float *p) {
+__global__ void ffp1(float *p) {
   // CHECK-LABEL: @_Z4ffp1Pf
   // CHECK: atomicrmw fadd ptr {{.*}} monotonic
-  return __atomic_fetch_add(p, 1.0f, memory_order_relaxed);
+  // CHECK: atomicrmw fmax ptr {{.*}} monotonic
+  // CHECK: atomicrmw fmin ptr {{.*}} monotonic
+  // CHECK: atomicrmw fmax ptr {{.*}} syncscope("agent-one-as") monotonic
+  // CHECK: atomicrmw fmin ptr {{.*}} syncscope("workgroup-one-as") monotonic
+  // SAFE: _Z4ffp1Pf
+  // SAFE: global_atomic_cmpswap
+  // SAFE: global_atomic_cmpswap
+  // SAFE: global_atomic_cmpswap
+  // SAFE: global_atomic_cmpswap
+  // SAFE: global_atomic_cmpswap
+  // UNSAFE: _Z4ffp1Pf
+  // UNSAFE: global_atomic_add_f32
+  // UNSAFE: global_atomic_cmpswap
+  // UNSAFE: global_atomic_cmpswap
+  // UNSAFE: global_atomic_cmpswap
+  // UNSAFE: global_atomic_cmpswap
+  __atomic_fetch_add(p, 1.0f, memory_order_relaxed);
+  __atomic_fetch_max(p, 1.0f, memory_order_relaxed);
+  __atomic_fetch_min(p, 1.0f, memory_order_relaxed);
+  __hip_atomic_fetch_max(p, 1.0f, memory_order_relaxed, __HIP_MEMORY_SCOPE_AGENT);
+  __hip_

[PATCH] D150948: [clang][RecoveryExpr] Fix a crash where a dependent type crahes on c-only code path.

2023-05-19 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 523868.
hokein added a comment.

add release note.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150948

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDecl.cpp
  clang/test/AST/ast-dump-recovery.c


Index: clang/test/AST/ast-dump-recovery.c
===
--- clang/test/AST/ast-dump-recovery.c
+++ clang/test/AST/ast-dump-recovery.c
@@ -98,3 +98,14 @@
   // CHECK-NEXT: `-RecoveryExpr {{.*}} ''
   ext(undef_var);
 }
+
+// Verify no crash.
+void test4() {
+  enum GH62446 {
+// CHECK:  RecoveryExpr {{.*}} '' contains-errors 
lvalue
+// CHECK-NEXT: |-StringLiteral {{.*}} "a"
+// CHECK-NEXT: `-IntegerLiteral {{.*}} 2
+invalid_enum_value = "a" * 2,
+b,
+  };
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -19307,6 +19307,7 @@
 if (!getLangOpts().CPlusPlus && !T.isNull())
   Diag(IdLoc, diag::warn_enum_value_overflow);
   } else if (!getLangOpts().CPlusPlus &&
+ !EltTy->isDependentType() &&
  !isRepresentableIntegerValue(Context, EnumVal, EltTy)) {
 // Enforce C99 6.7.2.2p2 even when we compute the next value.
 Diag(IdLoc, diag::ext_enum_value_not_int)
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -406,6 +406,9 @@
   when it had been instantiated from a partial template specialization with 
different
   template arguments on the containing class. This fixes:
   (`#60778 `_).
+- Fix a crash when an enum constant has a dependent-type recovery expression 
for
+  C.
+  (`#62446 `_).
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/AST/ast-dump-recovery.c
===
--- clang/test/AST/ast-dump-recovery.c
+++ clang/test/AST/ast-dump-recovery.c
@@ -98,3 +98,14 @@
   // CHECK-NEXT: `-RecoveryExpr {{.*}} ''
   ext(undef_var);
 }
+
+// Verify no crash.
+void test4() {
+  enum GH62446 {
+// CHECK:  RecoveryExpr {{.*}} '' contains-errors lvalue
+// CHECK-NEXT: |-StringLiteral {{.*}} "a"
+// CHECK-NEXT: `-IntegerLiteral {{.*}} 2
+invalid_enum_value = "a" * 2,
+b,
+  };
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -19307,6 +19307,7 @@
 if (!getLangOpts().CPlusPlus && !T.isNull())
   Diag(IdLoc, diag::warn_enum_value_overflow);
   } else if (!getLangOpts().CPlusPlus &&
+ !EltTy->isDependentType() &&
  !isRepresentableIntegerValue(Context, EnumVal, EltTy)) {
 // Enforce C99 6.7.2.2p2 even when we compute the next value.
 Diag(IdLoc, diag::ext_enum_value_not_int)
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -406,6 +406,9 @@
   when it had been instantiated from a partial template specialization with different
   template arguments on the containing class. This fixes:
   (`#60778 `_).
+- Fix a crash when an enum constant has a dependent-type recovery expression for
+  C.
+  (`#62446 `_).
 
 Bug Fixes to Compiler Builtins
 ^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150948: [clang][RecoveryExpr] Fix a crash where a dependent type crahes on c-only code path.

2023-05-19 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

Thanks for the fast review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150948

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


[PATCH] D149612: [Sema] avoid merge error type

2023-05-19 Thread Congcong Cai via Phabricator via cfe-commits
HerrCai0907 updated this revision to Diff 523870.
HerrCai0907 added a comment.

revert untill first version


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149612

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Sema/merge-decls.c


Index: clang/test/Sema/merge-decls.c
===
--- clang/test/Sema/merge-decls.c
+++ clang/test/Sema/merge-decls.c
@@ -91,3 +91,7 @@
   int x[5];
   test7_f(&x); // expected-warning {{incompatible pointer types passing 'int 
(*)[5]' to parameter of type 'int (*)[10]}}
 }
+
+char d;
+char x[sizeof(d.data) == 8]; // expected-error {{member reference base type 
'char' is not a structure or union}}
+char x[sizeof(d.data) == 4]; // expected-error {{member reference base type 
'char' is not a structure or union}}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -4396,7 +4396,7 @@
 /// is attached.
 void Sema::MergeVarDeclTypes(VarDecl *New, VarDecl *Old,
  bool MergeTypeWithOld) {
-  if (New->isInvalidDecl() || Old->isInvalidDecl())
+  if (New->isInvalidDecl() || Old->isInvalidDecl() || 
New->getType()->containsErrors() || Old->getType()->containsErrors())
 return;
 
   QualType MergedT;
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -383,6 +383,8 @@
 - Fix crash when attempting to perform parenthesized initialization of an
   aggregate with a base class with only non-public constructors.
   (`#62296 `_)
+- Fix crash when redefine variant with invalid type as another invalid type.
+  (`#62447 `_)
 - Fix a stack overflow issue when evaluating ``consteval`` default arguments.
   (`#60082` `_)
 - Fix the assertion hit when generating code for global variable initializer of


Index: clang/test/Sema/merge-decls.c
===
--- clang/test/Sema/merge-decls.c
+++ clang/test/Sema/merge-decls.c
@@ -91,3 +91,7 @@
   int x[5];
   test7_f(&x); // expected-warning {{incompatible pointer types passing 'int (*)[5]' to parameter of type 'int (*)[10]}}
 }
+
+char d;
+char x[sizeof(d.data) == 8]; // expected-error {{member reference base type 'char' is not a structure or union}}
+char x[sizeof(d.data) == 4]; // expected-error {{member reference base type 'char' is not a structure or union}}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -4396,7 +4396,7 @@
 /// is attached.
 void Sema::MergeVarDeclTypes(VarDecl *New, VarDecl *Old,
  bool MergeTypeWithOld) {
-  if (New->isInvalidDecl() || Old->isInvalidDecl())
+  if (New->isInvalidDecl() || Old->isInvalidDecl() || New->getType()->containsErrors() || Old->getType()->containsErrors())
 return;
 
   QualType MergedT;
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -383,6 +383,8 @@
 - Fix crash when attempting to perform parenthesized initialization of an
   aggregate with a base class with only non-public constructors.
   (`#62296 `_)
+- Fix crash when redefine variant with invalid type as another invalid type.
+  (`#62447 `_)
 - Fix a stack overflow issue when evaluating ``consteval`` default arguments.
   (`#60082` `_)
 - Fix the assertion hit when generating code for global variable initializer of
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150212: [clang][Sema] Improve diagnostics for auto return type

2023-05-19 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

ping

The pre-merge check failure seems not related to the patch. Other patches also 
fail the same way.


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

https://reviews.llvm.org/D150212

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


[PATCH] D149516: [Sema] `setInvalidDecl` for error deduction declaration

2023-05-19 Thread Congcong Cai via Phabricator via cfe-commits
HerrCai0907 added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149516

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


[PATCH] D149612: [Sema] avoid merge error type

2023-05-19 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

I think this is looking fine to me.  Thanks for your patience on this, I know 
it was a tough review.




Comment at: clang/lib/Sema/SemaDecl.cpp:4399
  bool MergeTypeWithOld) {
-  if (New->isInvalidDecl() || Old->isInvalidDecl())
+  if (New->isInvalidDecl() || Old->isInvalidDecl() || 
New->getType()->containsErrors() || Old->getType()->containsErrors())
 return;

NIT: 80 line character limit per  line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149612

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


[clang] a62e205 - [clang][RecoveryExpr] Fix a crash where a dependent type crahes on c-only code path.

2023-05-19 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2023-05-19T20:24:54+02:00
New Revision: a62e205254c0f482ba38bacc1f7f6927e6bc6375

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

LOG: [clang][RecoveryExpr] Fix a crash where a dependent type crahes on c-only 
code path.

A depenent type is possible in C-only path, add a proper handling when
checking the enum constant.

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

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaDecl.cpp
clang/test/AST/ast-dump-recovery.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 9bcc17b0c5ff8..3035e23f0b45c 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -410,6 +410,9 @@ Bug Fixes in This Version
   when it had been instantiated from a partial template specialization with 
diff erent
   template arguments on the containing class. This fixes:
   (`#60778 `_).
+- Fix a crash when an enum constant has a dependent-type recovery expression 
for
+  C.
+  (`#62446 `_).
 
 Bug Fixes to Compiler Builtins
 ^^

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index f499a8658d73a..eff5f38960f7e 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -19307,6 +19307,7 @@ EnumConstantDecl *Sema::CheckEnumConstant(EnumDecl 
*Enum,
 if (!getLangOpts().CPlusPlus && !T.isNull())
   Diag(IdLoc, diag::warn_enum_value_overflow);
   } else if (!getLangOpts().CPlusPlus &&
+ !EltTy->isDependentType() &&
  !isRepresentableIntegerValue(Context, EnumVal, EltTy)) {
 // Enforce C99 6.7.2.2p2 even when we compute the next value.
 Diag(IdLoc, diag::ext_enum_value_not_int)

diff  --git a/clang/test/AST/ast-dump-recovery.c 
b/clang/test/AST/ast-dump-recovery.c
index f7b3c7bb4f2f4..75441c1c9de0a 100644
--- a/clang/test/AST/ast-dump-recovery.c
+++ b/clang/test/AST/ast-dump-recovery.c
@@ -98,3 +98,14 @@ void test3() {
   // CHECK-NEXT: `-RecoveryExpr {{.*}} ''
   ext(undef_var);
 }
+
+// Verify no crash.
+void test4() {
+  enum GH62446 {
+// CHECK:  RecoveryExpr {{.*}} '' contains-errors 
lvalue
+// CHECK-NEXT: |-StringLiteral {{.*}} "a"
+// CHECK-NEXT: `-IntegerLiteral {{.*}} 2
+invalid_enum_value = "a" * 2,
+b,
+  };
+}



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


[PATCH] D150948: [clang][RecoveryExpr] Fix a crash where a dependent type crahes on c-only code path.

2023-05-19 Thread Haojian Wu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa62e205254c0: [clang][RecoveryExpr] Fix a crash where a 
dependent type crahes on c-only code… (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150948

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDecl.cpp
  clang/test/AST/ast-dump-recovery.c


Index: clang/test/AST/ast-dump-recovery.c
===
--- clang/test/AST/ast-dump-recovery.c
+++ clang/test/AST/ast-dump-recovery.c
@@ -98,3 +98,14 @@
   // CHECK-NEXT: `-RecoveryExpr {{.*}} ''
   ext(undef_var);
 }
+
+// Verify no crash.
+void test4() {
+  enum GH62446 {
+// CHECK:  RecoveryExpr {{.*}} '' contains-errors 
lvalue
+// CHECK-NEXT: |-StringLiteral {{.*}} "a"
+// CHECK-NEXT: `-IntegerLiteral {{.*}} 2
+invalid_enum_value = "a" * 2,
+b,
+  };
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -19307,6 +19307,7 @@
 if (!getLangOpts().CPlusPlus && !T.isNull())
   Diag(IdLoc, diag::warn_enum_value_overflow);
   } else if (!getLangOpts().CPlusPlus &&
+ !EltTy->isDependentType() &&
  !isRepresentableIntegerValue(Context, EnumVal, EltTy)) {
 // Enforce C99 6.7.2.2p2 even when we compute the next value.
 Diag(IdLoc, diag::ext_enum_value_not_int)
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -410,6 +410,9 @@
   when it had been instantiated from a partial template specialization with 
different
   template arguments on the containing class. This fixes:
   (`#60778 `_).
+- Fix a crash when an enum constant has a dependent-type recovery expression 
for
+  C.
+  (`#62446 `_).
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/AST/ast-dump-recovery.c
===
--- clang/test/AST/ast-dump-recovery.c
+++ clang/test/AST/ast-dump-recovery.c
@@ -98,3 +98,14 @@
   // CHECK-NEXT: `-RecoveryExpr {{.*}} ''
   ext(undef_var);
 }
+
+// Verify no crash.
+void test4() {
+  enum GH62446 {
+// CHECK:  RecoveryExpr {{.*}} '' contains-errors lvalue
+// CHECK-NEXT: |-StringLiteral {{.*}} "a"
+// CHECK-NEXT: `-IntegerLiteral {{.*}} 2
+invalid_enum_value = "a" * 2,
+b,
+  };
+}
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -19307,6 +19307,7 @@
 if (!getLangOpts().CPlusPlus && !T.isNull())
   Diag(IdLoc, diag::warn_enum_value_overflow);
   } else if (!getLangOpts().CPlusPlus &&
+ !EltTy->isDependentType() &&
  !isRepresentableIntegerValue(Context, EnumVal, EltTy)) {
 // Enforce C99 6.7.2.2p2 even when we compute the next value.
 Diag(IdLoc, diag::ext_enum_value_not_int)
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -410,6 +410,9 @@
   when it had been instantiated from a partial template specialization with different
   template arguments on the containing class. This fixes:
   (`#60778 `_).
+- Fix a crash when an enum constant has a dependent-type recovery expression for
+  C.
+  (`#62446 `_).
 
 Bug Fixes to Compiler Builtins
 ^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150985: [clang] Allow fp in atomic fetch max/min builtins

2023-05-19 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

The code changes look OK to me.

Whether allowing FP for clang builtins is OK -- I have no idea, especially for 
the c11 ones.


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

https://reviews.llvm.org/D150985

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


[PATCH] D148089: [clang][CodeGen] Break up TargetInfo.cpp [1/8]

2023-05-19 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Sergei, feel free to start landing patches like this one that were already 
approved.  You don't need the entire sequence to be approved first.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148089

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


[PATCH] D150965: [HIP] Allow std::malloc in device function

2023-05-19 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/test/Headers/Inputs/include/math.h:108-109
 long lroundf(float __a);
-int max(int __a, int __b);
-int min(int __a, int __b);
 double modf(double __a, double *__b);

yaxunl wrote:
> tra wrote:
> > Why were these functions removed? It does not seem related to the changes 
> > in the patch?
> These functions caused failure in the added lit test.
> 
> For C++, max/min are defined as templates in . There is no max/min 
> in either standard C or C++ math.h. Their existence cause false alarms in lit 
> tests. Removing them to be consistent with standard C/C++ headers.
I suspect those may have been used for some CUDA tests. CUDA headers used to 
define `::min()` and `::max()`.

As long as it does not affect the tests, removing them is fine.




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

https://reviews.llvm.org/D150965

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


[PATCH] D148851: Disable llvm-symbolizer on some of the driver tests that are timing out

2023-05-19 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148851

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


[PATCH] D150955: [clang][AST] Propagate the value-dependent bit for VAArgExpr.

2023-05-19 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 523875.
hokein added a comment.

add release note


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150955

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/AST/ComputeDependence.cpp
  clang/test/AST/ast-dump-recovery.c


Index: clang/test/AST/ast-dump-recovery.c
===
--- clang/test/AST/ast-dump-recovery.c
+++ clang/test/AST/ast-dump-recovery.c
@@ -109,3 +109,11 @@
 b,
   };
 }
+
+// Verify no crash
+void test5_GH62711() {
+  // CHECK:  VAArgExpr {{.*}} 'int' contains-errors
+  // CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '' contains-errors
+  // CHECK-NEXT: |   `-RecoveryExpr {{.*}} '' contains-errors
+  if (__builtin_va_arg(undef, int) << 1);
+}
Index: clang/lib/AST/ComputeDependence.cpp
===
--- clang/lib/AST/ComputeDependence.cpp
+++ clang/lib/AST/ComputeDependence.cpp
@@ -227,7 +227,7 @@
   auto D = toExprDependenceAsWritten(
E->getWrittenTypeInfo()->getType()->getDependence()) |
(E->getSubExpr()->getDependence() & ~ExprDependence::Type);
-  return D & ~ExprDependence::Value;
+  return D;
 }
 
 ExprDependence clang::computeDependence(NoInitExpr *E) {
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -413,6 +413,9 @@
 - Fix a crash when an enum constant has a dependent-type recovery expression 
for
   C.
   (`#62446 `_).
+- Propagate the value-dependent bit for VAArgExpr. Fixes a crash where a
+  __builtin_va_arg call has invalid arguments.
+  (`#62711 `_).
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/AST/ast-dump-recovery.c
===
--- clang/test/AST/ast-dump-recovery.c
+++ clang/test/AST/ast-dump-recovery.c
@@ -109,3 +109,11 @@
 b,
   };
 }
+
+// Verify no crash
+void test5_GH62711() {
+  // CHECK:  VAArgExpr {{.*}} 'int' contains-errors
+  // CHECK-NEXT: | `-ImplicitCastExpr {{.*}} '' contains-errors
+  // CHECK-NEXT: |   `-RecoveryExpr {{.*}} '' contains-errors
+  if (__builtin_va_arg(undef, int) << 1);
+}
Index: clang/lib/AST/ComputeDependence.cpp
===
--- clang/lib/AST/ComputeDependence.cpp
+++ clang/lib/AST/ComputeDependence.cpp
@@ -227,7 +227,7 @@
   auto D = toExprDependenceAsWritten(
E->getWrittenTypeInfo()->getType()->getDependence()) |
(E->getSubExpr()->getDependence() & ~ExprDependence::Type);
-  return D & ~ExprDependence::Value;
+  return D;
 }
 
 ExprDependence clang::computeDependence(NoInitExpr *E) {
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -413,6 +413,9 @@
 - Fix a crash when an enum constant has a dependent-type recovery expression for
   C.
   (`#62446 `_).
+- Propagate the value-dependent bit for VAArgExpr. Fixes a crash where a
+  __builtin_va_arg call has invalid arguments.
+  (`#62711 `_).
 
 Bug Fixes to Compiler Builtins
 ^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150955: [clang][AST] Propagate the value-dependent bit for VAArgExpr.

2023-05-19 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

Thanks for the review.

In D150955#4356580 , @aaron.ballman 
wrote:

> LGTM assuming CI is okay with it -- the patch did not apply so precommit CI 
> never ran. I'm surprised no tests break as a result of this because it 
> changes both C and C++ behavior. The changes should have a release note, too.

This patch was based on my another fix (this probably explains why it failed to 
apply on pre-merge testing CI). I have test it with `ninja check-clang`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150955

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


[PATCH] D150894: [CUDA] provide wrapper functions for new NVCC builtins.

2023-05-19 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 523879.
tra added a comment.

Added __nv_associate_access_property_impl() stub.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150894

Files:
  clang/lib/Headers/__clang_cuda_intrinsics.h


Index: clang/lib/Headers/__clang_cuda_intrinsics.h
===
--- clang/lib/Headers/__clang_cuda_intrinsics.h
+++ clang/lib/Headers/__clang_cuda_intrinsics.h
@@ -512,6 +512,78 @@
 __device__ inline cuuint32_t __nvvm_get_smem_pointer(void *__ptr) {
   return __nv_cvta_generic_to_shared_impl(__ptr);
 }
+
+#if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 800
+__device__ inline unsigned __reduce_add_sync_unsigned_impl(unsigned __mask,
+   unsigned __value) {
+  return __nvvm_redux_sync_add(__mask, __value);
+}
+__device__ inline int __reduce_add_sync_signed_impl(unsigned __mask,
+int __value) {
+  return __nvvm_redux_sync_add(__mask, __value);
+}
+__device__ inline unsigned __reduce_min_sync_unsigned_impl(unsigned __mask,
+   unsigned __value) {
+  return __nvvm_redux_sync_umin(__mask, __value);
+}
+__device__ inline unsigned __reduce_max_sync_unsigned_impl(unsigned __mask,
+   unsigned __value) {
+  return __nvvm_redux_sync_umax(__mask, __value);
+}
+__device__ inline int __reduce_min_sync_signed_impl(unsigned __mask,
+int __value) {
+  return __nvvm_redux_sync_min(__mask, __value);
+}
+__device__ inline int __reduce_max_sync_signed_impl(unsigned __mask,
+int __value) {
+  return __nvvm_redux_sync_max(__mask, __value);
+}
+__device__ inline unsigned __reduce_or_sync_unsigned_impl(unsigned __mask,
+  unsigned __value) {
+  return __nvvm_redux_sync_or(__mask, __value);
+}
+__device__ inline unsigned __reduce_and_sync_unsigned_impl(unsigned __mask,
+   unsigned __value) {
+  return __nvvm_redux_sync_and(__mask, __value);
+}
+__device__ inline unsigned __reduce_xor_sync_unsigned_impl(unsigned __mask,
+   unsigned __value) {
+  return __nvvm_redux_sync_xor(__mask, __value);
+}
+
+__device__ inline void
+__nv_memcpy_async_shared_global_4_impl(void *__dst, const void *__src,
+   unsigned __src_size) {
+  __nvvm_cp_async_ca_shared_global_4(
+  (void __attribute__((address_space(3))) *)__dst,
+  (const void __attribute__((address_space(1))) *)__src, __src_size);
+}
+__device__ inline void
+__nv_memcpy_async_shared_global_8_impl(void *__dst, const void *__src,
+   unsigned __src_size) {
+  __nvvm_cp_async_ca_shared_global_8(
+  (void __attribute__((address_space(3))) *)__dst,
+  (const void __attribute__((address_space(1))) *)__src, __src_size);
+}
+__device__ inline void
+__nv_memcpy_async_shared_global_16_impl(void *__dst, const void *__src,
+unsigned __src_size) {
+  __nvvm_cp_async_ca_shared_global_16(
+  (void __attribute__((address_space(3))) *)__dst,
+  (const void __attribute__((address_space(1))) *)__src, __src_size);
+}
+
+__device__ inline void *
+__nv_associate_access_property_impl(const void *__ptr,
+unsigned long long __prop) {
+  // TODO: it appears to provide compiler with some sort of a hint. We do not
+  // know what exactly it is supposed to do. However, CUDA headers suggest that
+  // just passing through __ptr should not affect correctness. The do so on
+  // pre-sm80 GPUs where this builtin is not available.
+  return (void*)__ptr;
+}
+#endif // !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 800
+
 } // extern "C"
 #endif // CUDA_VERSION >= 11000
 


Index: clang/lib/Headers/__clang_cuda_intrinsics.h
===
--- clang/lib/Headers/__clang_cuda_intrinsics.h
+++ clang/lib/Headers/__clang_cuda_intrinsics.h
@@ -512,6 +512,78 @@
 __device__ inline cuuint32_t __nvvm_get_smem_pointer(void *__ptr) {
   return __nv_cvta_generic_to_shared_impl(__ptr);
 }
+
+#if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 800
+__device__ inline unsigned __reduce_add_sync_unsigned_impl(unsigned __mask,
+   unsigned __value) {
+  return __nvvm_redux_sync_add(__mask, __value);
+}
+__device__ inline int __reduce_add_sync_signed_impl(unsigned __mask,
+int __value) {
+  return __nvvm_redux_sync_add(__mask, __value);
+}
+__device__ inline unsigned __reduce_min

[PATCH] D148089: [clang][CodeGen] Break up TargetInfo.cpp [1/8]

2023-05-19 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added a comment.

In D148089#4357219 , @rjmccall wrote:

> Sergei, feel free to start landing patches like this one that were already 
> approved.  You don't need the entire sequence to be approved first.

Ah, OK! I thought it is required.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148089

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


[PATCH] D150894: [CUDA] provide wrapper functions for new NVCC builtins.

2023-05-19 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 523881.
tra added a comment.

typo fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150894

Files:
  clang/lib/Headers/__clang_cuda_intrinsics.h


Index: clang/lib/Headers/__clang_cuda_intrinsics.h
===
--- clang/lib/Headers/__clang_cuda_intrinsics.h
+++ clang/lib/Headers/__clang_cuda_intrinsics.h
@@ -512,6 +512,78 @@
 __device__ inline cuuint32_t __nvvm_get_smem_pointer(void *__ptr) {
   return __nv_cvta_generic_to_shared_impl(__ptr);
 }
+
+#if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 800
+__device__ inline unsigned __reduce_add_sync_unsigned_impl(unsigned __mask,
+   unsigned __value) {
+  return __nvvm_redux_sync_add(__mask, __value);
+}
+__device__ inline int __reduce_add_sync_signed_impl(unsigned __mask,
+int __value) {
+  return __nvvm_redux_sync_add(__mask, __value);
+}
+__device__ inline unsigned __reduce_min_sync_unsigned_impl(unsigned __mask,
+   unsigned __value) {
+  return __nvvm_redux_sync_umin(__mask, __value);
+}
+__device__ inline unsigned __reduce_max_sync_unsigned_impl(unsigned __mask,
+   unsigned __value) {
+  return __nvvm_redux_sync_umax(__mask, __value);
+}
+__device__ inline int __reduce_min_sync_signed_impl(unsigned __mask,
+int __value) {
+  return __nvvm_redux_sync_min(__mask, __value);
+}
+__device__ inline int __reduce_max_sync_signed_impl(unsigned __mask,
+int __value) {
+  return __nvvm_redux_sync_max(__mask, __value);
+}
+__device__ inline unsigned __reduce_or_sync_unsigned_impl(unsigned __mask,
+  unsigned __value) {
+  return __nvvm_redux_sync_or(__mask, __value);
+}
+__device__ inline unsigned __reduce_and_sync_unsigned_impl(unsigned __mask,
+   unsigned __value) {
+  return __nvvm_redux_sync_and(__mask, __value);
+}
+__device__ inline unsigned __reduce_xor_sync_unsigned_impl(unsigned __mask,
+   unsigned __value) {
+  return __nvvm_redux_sync_xor(__mask, __value);
+}
+
+__device__ inline void
+__nv_memcpy_async_shared_global_4_impl(void *__dst, const void *__src,
+   unsigned __src_size) {
+  __nvvm_cp_async_ca_shared_global_4(
+  (void __attribute__((address_space(3))) *)__dst,
+  (const void __attribute__((address_space(1))) *)__src, __src_size);
+}
+__device__ inline void
+__nv_memcpy_async_shared_global_8_impl(void *__dst, const void *__src,
+   unsigned __src_size) {
+  __nvvm_cp_async_ca_shared_global_8(
+  (void __attribute__((address_space(3))) *)__dst,
+  (const void __attribute__((address_space(1))) *)__src, __src_size);
+}
+__device__ inline void
+__nv_memcpy_async_shared_global_16_impl(void *__dst, const void *__src,
+unsigned __src_size) {
+  __nvvm_cp_async_ca_shared_global_16(
+  (void __attribute__((address_space(3))) *)__dst,
+  (const void __attribute__((address_space(1))) *)__src, __src_size);
+}
+
+__device__ inline void *
+__nv_associate_access_property_impl(const void *__ptr,
+unsigned long long __prop) {
+  // TODO: it appears to provide compiler with some sort of a hint. We do not
+  // know what exactly it is supposed to do. However, CUDA headers suggest that
+  // just passing through __ptr should not affect correctness. They do so on
+  // pre-sm80 GPUs where this builtin is not available.
+  return (void*)__ptr;
+}
+#endif // !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 800
+
 } // extern "C"
 #endif // CUDA_VERSION >= 11000
 


Index: clang/lib/Headers/__clang_cuda_intrinsics.h
===
--- clang/lib/Headers/__clang_cuda_intrinsics.h
+++ clang/lib/Headers/__clang_cuda_intrinsics.h
@@ -512,6 +512,78 @@
 __device__ inline cuuint32_t __nvvm_get_smem_pointer(void *__ptr) {
   return __nv_cvta_generic_to_shared_impl(__ptr);
 }
+
+#if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 800
+__device__ inline unsigned __reduce_add_sync_unsigned_impl(unsigned __mask,
+   unsigned __value) {
+  return __nvvm_redux_sync_add(__mask, __value);
+}
+__device__ inline int __reduce_add_sync_signed_impl(unsigned __mask,
+int __value) {
+  return __nvvm_redux_sync_add(__mask, __value);
+}
+__device__ inline unsigned __reduce_min_sync_unsigned_impl(unsigned __mask,
+ 

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

2023-05-19 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

In D137872#4348314 , @akhuang wrote:

> In D137872#4327615 , @efriedma 
> wrote:
>
>> I'm having a bit of trouble following how exactly the thunk creation is 
>> working here... do we generate different code depending on whether the call 
>> operator and/or the static invoker are referenced?
>
> So I think it used to be that the static invoker calls the call operator 
> which contains the body of the lambda? And now both the static invoker and 
> the call operator are delegating to this new __impl function. In 
> EmitLambdaStaticInvokeBody it first calls EmitLambdaInAllocaCallOpFn to make 
> the new call operator (which is populated using 
> EmitLambdaDelegatingInvokeBody). And then inside 
> EmitLambdaDelegatingInvokeBody it generates the new impl function and calls 
> it in the body. Not sure if that answers the question, I agree the code is a 
> bit roundabout.
>
>> Why is the function in EmitLambdaInAllocaCallOpFn not getting defined using 
>> the normal CodeGenModule machinery?
>
> Do you mean why it's not using CodeGenModule machinery to generate the new 
> call op body or why we're changing the original call op body?

I mean why it's not using the CodeGenModule machinery.  I understand there are 
three function bodies involved.  But I would expect that when you "emit" the 
lambda call operator, it emits the entry point for the call and for the call 
impl, and when you emit the static invoker, it just emits a call to the call 
impl.

Or... hmm.  Is this actually erasing the existing definition of the call 
operator, if it was already emitted?  That probably doesn't actually work in 
general; once a function is emitted, you can't re-emit it.  Emitting a function 
emits other related stuff like static variables; you can't EmitFunctionBody() 
more than once.  Either you need to decide when it's first emitted, or you need 
to rewrite the signature of the definition and splice the existing body in.


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


[clang] 4450285 - [CUDA] provide wrapper functions for new NVCC builtins.

2023-05-19 Thread Artem Belevich via cfe-commits

Author: Artem Belevich
Date: 2023-05-19T11:48:08-07:00
New Revision: 4450285bd74079bf87ba7b824a8dec8dcfb586ef

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

LOG: [CUDA] provide wrapper functions for new NVCC builtins.

For sm_80 NVCC introduced a handful of builtins with the names that deviate from
the historic __nvvm_/__nv naming convention. Clang/LLVM does provide equivalent
builtins, but using different names. This patch maps NVCC-style builtins to
their clang counterparts.

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

Added: 


Modified: 
clang/lib/Headers/__clang_cuda_intrinsics.h

Removed: 




diff  --git a/clang/lib/Headers/__clang_cuda_intrinsics.h 
b/clang/lib/Headers/__clang_cuda_intrinsics.h
index b87413e12a272..d085bf6536efc 100644
--- a/clang/lib/Headers/__clang_cuda_intrinsics.h
+++ b/clang/lib/Headers/__clang_cuda_intrinsics.h
@@ -512,6 +512,78 @@ __device__ inline void 
*__nv_cvta_local_to_generic_impl(size_t __ptr) {
 __device__ inline cuuint32_t __nvvm_get_smem_pointer(void *__ptr) {
   return __nv_cvta_generic_to_shared_impl(__ptr);
 }
+
+#if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 800
+__device__ inline unsigned __reduce_add_sync_unsigned_impl(unsigned __mask,
+   unsigned __value) {
+  return __nvvm_redux_sync_add(__mask, __value);
+}
+__device__ inline int __reduce_add_sync_signed_impl(unsigned __mask,
+int __value) {
+  return __nvvm_redux_sync_add(__mask, __value);
+}
+__device__ inline unsigned __reduce_min_sync_unsigned_impl(unsigned __mask,
+   unsigned __value) {
+  return __nvvm_redux_sync_umin(__mask, __value);
+}
+__device__ inline unsigned __reduce_max_sync_unsigned_impl(unsigned __mask,
+   unsigned __value) {
+  return __nvvm_redux_sync_umax(__mask, __value);
+}
+__device__ inline int __reduce_min_sync_signed_impl(unsigned __mask,
+int __value) {
+  return __nvvm_redux_sync_min(__mask, __value);
+}
+__device__ inline int __reduce_max_sync_signed_impl(unsigned __mask,
+int __value) {
+  return __nvvm_redux_sync_max(__mask, __value);
+}
+__device__ inline unsigned __reduce_or_sync_unsigned_impl(unsigned __mask,
+  unsigned __value) {
+  return __nvvm_redux_sync_or(__mask, __value);
+}
+__device__ inline unsigned __reduce_and_sync_unsigned_impl(unsigned __mask,
+   unsigned __value) {
+  return __nvvm_redux_sync_and(__mask, __value);
+}
+__device__ inline unsigned __reduce_xor_sync_unsigned_impl(unsigned __mask,
+   unsigned __value) {
+  return __nvvm_redux_sync_xor(__mask, __value);
+}
+
+__device__ inline void
+__nv_memcpy_async_shared_global_4_impl(void *__dst, const void *__src,
+   unsigned __src_size) {
+  __nvvm_cp_async_ca_shared_global_4(
+  (void __attribute__((address_space(3))) *)__dst,
+  (const void __attribute__((address_space(1))) *)__src, __src_size);
+}
+__device__ inline void
+__nv_memcpy_async_shared_global_8_impl(void *__dst, const void *__src,
+   unsigned __src_size) {
+  __nvvm_cp_async_ca_shared_global_8(
+  (void __attribute__((address_space(3))) *)__dst,
+  (const void __attribute__((address_space(1))) *)__src, __src_size);
+}
+__device__ inline void
+__nv_memcpy_async_shared_global_16_impl(void *__dst, const void *__src,
+unsigned __src_size) {
+  __nvvm_cp_async_ca_shared_global_16(
+  (void __attribute__((address_space(3))) *)__dst,
+  (const void __attribute__((address_space(1))) *)__src, __src_size);
+}
+
+__device__ inline void *
+__nv_associate_access_property_impl(const void *__ptr,
+unsigned long long __prop) {
+  // TODO: it appears to provide compiler with some sort of a hint. We do not
+  // know what exactly it is supposed to do. However, CUDA headers suggest that
+  // just passing through __ptr should not affect correctness. They do so on
+  // pre-sm80 GPUs where this builtin is not available.
+  return (void*)__ptr;
+}
+#endif // !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 800
+
 } // extern "C"
 #endif // CUDA_VERSION >= 11000
 



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


[PATCH] D150894: [CUDA] provide wrapper functions for new NVCC builtins.

2023-05-19 Thread Artem Belevich 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 rG4450285bd740: [CUDA] provide wrapper functions for new NVCC 
builtins. (authored by tra).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150894

Files:
  clang/lib/Headers/__clang_cuda_intrinsics.h


Index: clang/lib/Headers/__clang_cuda_intrinsics.h
===
--- clang/lib/Headers/__clang_cuda_intrinsics.h
+++ clang/lib/Headers/__clang_cuda_intrinsics.h
@@ -512,6 +512,78 @@
 __device__ inline cuuint32_t __nvvm_get_smem_pointer(void *__ptr) {
   return __nv_cvta_generic_to_shared_impl(__ptr);
 }
+
+#if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 800
+__device__ inline unsigned __reduce_add_sync_unsigned_impl(unsigned __mask,
+   unsigned __value) {
+  return __nvvm_redux_sync_add(__mask, __value);
+}
+__device__ inline int __reduce_add_sync_signed_impl(unsigned __mask,
+int __value) {
+  return __nvvm_redux_sync_add(__mask, __value);
+}
+__device__ inline unsigned __reduce_min_sync_unsigned_impl(unsigned __mask,
+   unsigned __value) {
+  return __nvvm_redux_sync_umin(__mask, __value);
+}
+__device__ inline unsigned __reduce_max_sync_unsigned_impl(unsigned __mask,
+   unsigned __value) {
+  return __nvvm_redux_sync_umax(__mask, __value);
+}
+__device__ inline int __reduce_min_sync_signed_impl(unsigned __mask,
+int __value) {
+  return __nvvm_redux_sync_min(__mask, __value);
+}
+__device__ inline int __reduce_max_sync_signed_impl(unsigned __mask,
+int __value) {
+  return __nvvm_redux_sync_max(__mask, __value);
+}
+__device__ inline unsigned __reduce_or_sync_unsigned_impl(unsigned __mask,
+  unsigned __value) {
+  return __nvvm_redux_sync_or(__mask, __value);
+}
+__device__ inline unsigned __reduce_and_sync_unsigned_impl(unsigned __mask,
+   unsigned __value) {
+  return __nvvm_redux_sync_and(__mask, __value);
+}
+__device__ inline unsigned __reduce_xor_sync_unsigned_impl(unsigned __mask,
+   unsigned __value) {
+  return __nvvm_redux_sync_xor(__mask, __value);
+}
+
+__device__ inline void
+__nv_memcpy_async_shared_global_4_impl(void *__dst, const void *__src,
+   unsigned __src_size) {
+  __nvvm_cp_async_ca_shared_global_4(
+  (void __attribute__((address_space(3))) *)__dst,
+  (const void __attribute__((address_space(1))) *)__src, __src_size);
+}
+__device__ inline void
+__nv_memcpy_async_shared_global_8_impl(void *__dst, const void *__src,
+   unsigned __src_size) {
+  __nvvm_cp_async_ca_shared_global_8(
+  (void __attribute__((address_space(3))) *)__dst,
+  (const void __attribute__((address_space(1))) *)__src, __src_size);
+}
+__device__ inline void
+__nv_memcpy_async_shared_global_16_impl(void *__dst, const void *__src,
+unsigned __src_size) {
+  __nvvm_cp_async_ca_shared_global_16(
+  (void __attribute__((address_space(3))) *)__dst,
+  (const void __attribute__((address_space(1))) *)__src, __src_size);
+}
+
+__device__ inline void *
+__nv_associate_access_property_impl(const void *__ptr,
+unsigned long long __prop) {
+  // TODO: it appears to provide compiler with some sort of a hint. We do not
+  // know what exactly it is supposed to do. However, CUDA headers suggest that
+  // just passing through __ptr should not affect correctness. They do so on
+  // pre-sm80 GPUs where this builtin is not available.
+  return (void*)__ptr;
+}
+#endif // !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 800
+
 } // extern "C"
 #endif // CUDA_VERSION >= 11000
 


Index: clang/lib/Headers/__clang_cuda_intrinsics.h
===
--- clang/lib/Headers/__clang_cuda_intrinsics.h
+++ clang/lib/Headers/__clang_cuda_intrinsics.h
@@ -512,6 +512,78 @@
 __device__ inline cuuint32_t __nvvm_get_smem_pointer(void *__ptr) {
   return __nv_cvta_generic_to_shared_impl(__ptr);
 }
+
+#if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 800
+__device__ inline unsigned __reduce_add_sync_unsigned_impl(unsigned __mask,
+   unsigned __value) {
+  return __nvvm_redux_sync_add(__mask, __value);
+}
+__device__ inline int __reduce_add_sync_signed_impl(unsigned __mask,
+   

[PATCH] D146358: [clang][AST] Print name instead of type when diagnosing uninitialized subobject in constexpr variables

2023-05-19 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D146358#4357106 , @hazohelet wrote:

> In D146358#4352792 , @erichkeane 
> wrote:
>
>> In D146358#4351787 , @hazohelet 
>> wrote:
>>
>>> In D146358#4350810 , @erichkeane 
>>> wrote:
>>>
 Our downstream discovered that this causes a regression when compiling 
 `utility` with `ast-dump`.  I've put up a minimal reproducer: 
 https://godbolt.org/z/oaezas7Ws

 @hazohelet : Will you be able to look into this soon?
>>>
>>> Thanks for the report and the reproducer.
>>> I cannot take sufficient time for about 36 hours, but I'll be able to 
>>> investigate it after that.
>>
>> That is long enough away that I unfortunately have to revert (see 
>> 34e49d3e85a6dd03856af0fb4b7f8d8ae1f4f06a 
>> ). 
>> Please note that in the LLVM project reverts are common/frequent (we have a 
>> policy of 'revert often'), and should not be taken negatively!  Please feel 
>> free to re-submit this patch with a fix/the test provided, and we'll 
>> re-review promptly!
>
> Thanks for the revert!
>
> It seems that the problem is around the list initializer in template variable 
> definition.
> Minimum reproducible example:
> `template  constexpr T foo{};`
>
> When the `TextNodeDumper` enabled through `-ast-dump` visits a constexpr 
> `VarDecl` with initializer, it evaluates the `VarDecl` and prints the value 
> if evaluation comes successful.
> (https://github.com/llvm/llvm-project/blob/55903151a2a505284ce3fcd955b1d394df0b55ea/clang/lib/AST/TextNodeDumper.cpp#L1825)
> The `VarDecl::evaluateValue()` does not show the notes generated during its 
> failed evaluation. The uninitialized-subobject note is actually generated 
> BEFORE this patch when compiling the reproducers with `-ast-dump` flag on, 
> but is not shown to the user.
> The message should not be generated here and I assume this is an internal bug 
> that we have to fix before resubmitting this patch.

It seems to me that perhaps the assert you added is not appropriate?  Instead, 
could we have the OLD diagnostic 'back' as an alternate form (when this is 
empty)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146358

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


  1   2   3   >