[PATCH] D134626: [clang-format] Correctly indent closing brace of compound requires

2022-09-27 Thread Emilia Dreamer via Phabricator via cfe-commits
rymiel added a comment.

I built 2 versions of clang-format, before and after this patch, and made 2 
separate clones of all of LLVM+clang and ran them through either, removing all 
`.clang-format`s, then ran a recursive diff.

I found 1 difference, in a test case at 
`clang/test/CodeGen/constrained-math-builtins.c` and reduced it to the 
following:

clang-format before the patch produced this:

  int foo() { ; };
  
// Comment
  
  #preprocessor

clang-format after this patch produced this:

  int foo() { ; };
  
  // Comment
  
  #preprocessor

Very specific requirements here, needing a comment which follows a function 
with a non-empty body and with a (redundant) trailing semicolon, followed by 
any preprocessor directive.

Nevertheless, the output seems to make more sense *with* the patch, so I think 
this counts as a bug fix rather than a regression?

My testing surely isn't perfect but this was the only difference I found 
(besides instances of the specific bug that this patch was intended to fix)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134626

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


[PATCH] D134705: [clang][DebugInfo] Emit debuginfo for non-constant case value

2022-09-27 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song created this revision.
yonghong-song added a reviewer: dblaikie.
Herald added a project: All.
yonghong-song requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Currently, clang does not emit debuginfo for the switch stmt
case value if it is an enum value. For example,

  $ cat test.c
  enum { AA = 1, BB = 2 };
  int func1(int a) {
switch(a) {
case AA: return 10; 
case BB: return 11; 
default: break;
}   
return 0;
  }
  $ llvm-dwarfdump test.o | grep AA
  $

Note that gcc does emit debuginfo for the same test case.

This patch added such a support with similar implementation
to CodeGenFunction::EmitDeclRefExprDbgValue(). With this patch,

  $ clang -g -c test.c
  $ llvm-dwarfdump test.o | grep AA
  DW_AT_name("AA")
  $   


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134705

Files:
  clang/lib/CodeGen/CGStmt.cpp
  clang/test/CodeGen/debug-info-enum-case-val.c


Index: clang/test/CodeGen/debug-info-enum-case-val.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-enum-case-val.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s
+
+enum { A = 1, B = 2 };
+int func1(int a) {
+  switch(a) {
+  case A: return 10;
+  case B: return 11;
+  default: break;
+  }
+  return 0;
+}
+// CHECK:   !DIEnumerator(name: "A", value: 1)
+// CHECK-NEXT:  !DIEnumerator(name: "B", value: 2)
+
+enum { C = 1, D = 2 };
+typedef unsigned long long __t1;
+typedef __t1 __t2;
+int func2(__t2 a) {
+  switch(a) {
+  case C: return 10;
+  case D: return 11;
+  default: break;
+  }
+  return 0;
+}
+// CHECK:   !DIEnumerator(name: "C", value: 1)
+// CHECK-NEXT:  !DIEnumerator(name: "D", value: 2)
Index: clang/lib/CodeGen/CGStmt.cpp
===
--- clang/lib/CodeGen/CGStmt.cpp
+++ clang/lib/CodeGen/CGStmt.cpp
@@ -1509,6 +1509,21 @@
 
   llvm::ConstantInt *CaseVal =
 Builder.getInt(S.getLHS()->EvaluateKnownConstInt(getContext()));
+
+  // Emit debuginfo for the case value if it is an enum value.
+  const ConstantExpr *CE;
+  if (auto ICE = dyn_cast(S.getLHS()))
+CE = dyn_cast(ICE->getSubExpr());
+  else
+CE = dyn_cast(S.getLHS());
+  if (CE) {
+if (auto DE = dyn_cast(CE->getSubExpr()))
+  if (CGDebugInfo *Dbg = getDebugInfo())
+if (CGM.getCodeGenOpts().hasReducedDebugInfo())
+  Dbg->EmitGlobalVariable(DE->getDecl(),
+  APValue(llvm::APSInt(CaseVal->getValue(;
+  }
+
   if (SwitchLikelihood)
 SwitchLikelihood->push_back(Stmt::getLikelihood(Attrs));
 


Index: clang/test/CodeGen/debug-info-enum-case-val.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-enum-case-val.c
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s
+
+enum { A = 1, B = 2 };
+int func1(int a) {
+  switch(a) {
+  case A: return 10;
+  case B: return 11;
+  default: break;
+  }
+  return 0;
+}
+// CHECK:   !DIEnumerator(name: "A", value: 1)
+// CHECK-NEXT:  !DIEnumerator(name: "B", value: 2)
+
+enum { C = 1, D = 2 };
+typedef unsigned long long __t1;
+typedef __t1 __t2;
+int func2(__t2 a) {
+  switch(a) {
+  case C: return 10;
+  case D: return 11;
+  default: break;
+  }
+  return 0;
+}
+// CHECK:   !DIEnumerator(name: "C", value: 1)
+// CHECK-NEXT:  !DIEnumerator(name: "D", value: 2)
Index: clang/lib/CodeGen/CGStmt.cpp
===
--- clang/lib/CodeGen/CGStmt.cpp
+++ clang/lib/CodeGen/CGStmt.cpp
@@ -1509,6 +1509,21 @@
 
   llvm::ConstantInt *CaseVal =
 Builder.getInt(S.getLHS()->EvaluateKnownConstInt(getContext()));
+
+  // Emit debuginfo for the case value if it is an enum value.
+  const ConstantExpr *CE;
+  if (auto ICE = dyn_cast(S.getLHS()))
+CE = dyn_cast(ICE->getSubExpr());
+  else
+CE = dyn_cast(S.getLHS());
+  if (CE) {
+if (auto DE = dyn_cast(CE->getSubExpr()))
+  if (CGDebugInfo *Dbg = getDebugInfo())
+if (CGM.getCodeGenOpts().hasReducedDebugInfo())
+  Dbg->EmitGlobalVariable(DE->getDecl(),
+  APValue(llvm::APSInt(CaseVal->getValue(;
+  }
+
   if (SwitchLikelihood)
 SwitchLikelihood->push_back(Stmt::getLikelihood(Attrs));
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D134337: [clang] [Driver] More flexible rules for loading default configs (WIP)

2022-09-27 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

In D134337#3815705 , @MaskRay wrote:

> In D134337#3815412 , @mgorny wrote:
>
>> In D134337#3815339 , @sepavloff 
>> wrote:
>>
>>> In D134337#3805368 , @mgorny 
>>> wrote:
>>>
 For target, it will try:

 1. `i386.cfg` (effective triple)
 2. `i386-pc-linux-gnu.cfg` ("fixed" prefix)
 3. `x86_64-pc-linux-gnu.cfg` (orig. prefix)
>>>
>>> Does it mean that `i386.cfg` would be tried before `i386-pc-linux-gnu.cfg`? 
>>> It looks more natural to try specific variant first then generic. File 
>>> `x86_64.cfg` is not used in this algorithm, what is the reason for this?
>>
>> Yes but this is only because the example explicitly passes `-target i386`, 
>> i.e. incompletely triple. If you passed `-target i386-pc-linux-gnu`, then it 
>> would try that one instead. Perhaps I should try and see what triple 
>> normalization does here.
>
> Trying just `i386.cfg` for `x86_64-pc-linux-gnu-clang --target=i386` makes 
> sense to me. Trying `x86_64*.cfg` seems inappropriate.
> I do not recommend `i386-pc-linux-gnu.cfg` since `--target=` is as if 
> completely ignoring the executable prefix.
>
> If `x86_64-pc-linux-gnu-clang --target=i386-pc-linux-gnu` is specified, 
> trying `i386-pc-linux-gnu-clang.cfg` makes sense. I do not know whether 
> `i386-clang.cfg` should be tried as well.

It make sense but the algorithm looks overcomplicated. The current 
implementation is already too complex and documenting the new algorithm is a 
challenge.

What about making minimal changes to the current algorithm so that the task of 
@mgorny can be done, without reasoning about possible profit for someone else? 
Our customers don't use target overloading and prefixes longer than target, so 
any change that preserve existing functionality is OK.

A part of this algorithm that loads driver mode configuration is worth 
implementing:

In D134337#3805368 , @mgorny wrote:

> For driver, it will try:
>
> 1. `clang++.cfg` (effective mode)
> 2. `clang.cfg` (suffix)

It must not break compatibility with existing implementation and allows further 
extension in future. For more complex use cases driver configuration may 
implement mode complex syntax as proposed in 
https://discourse.llvm.org/t/rfc-adding-a-default-file-location-to-config-file-support/63606/41.

@mgorny what modifications to target mode file search are necessary for your 
task?


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

https://reviews.llvm.org/D134337

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


[PATCH] D130510: Missing tautological compare warnings due to unary operators

2022-09-27 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added a comment.

Hi! A bit of late feedback on this patch. We found a failure in our downstream 
testing likely originating from here.

The failing case is:

  void f(int a)
  {
  (0 != (a | !0LL));
  }

built with `clang -cc1 -emit-llvm-bc -O2 -v -o foo.bc -x c foo.c`




Comment at: clang/lib/Analysis/CFG.cpp:1044
+case UO_LNot:
+  return llvm::APInt(Value.getBitWidth(), !Value);
+default:

This isn't returning an APInt of the right width. It will construct an APInt 
with a width of the input value, but that isn't the same as the required width 
of what a logical not produces; that should have a width of 'int'.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130510

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


[PATCH] D134597: [CMake] install clang resource headers into `CLANG_RESOURCE_DIR/include` if `CLANG_RESOURCE_DIR` is not empty

2022-09-27 Thread LJC via Phabricator via cfe-commits
paperchalice updated this revision to Diff 463114.
paperchalice added a comment.

Update the //output_dir//.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134597

Files:
  clang/lib/Headers/CMakeLists.txt


Index: clang/lib/Headers/CMakeLists.txt
===
--- clang/lib/Headers/CMakeLists.txt
+++ clang/lib/Headers/CMakeLists.txt
@@ -263,7 +263,11 @@
   openmp_wrappers/new
 )
 
-set(output_dir ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/include)
+if(NOT CLANG_RESOURCE_DIR STREQUAL "")
+  set(output_dir ${LLVM_RUNTIME_OUTPUT_INTDIR}/${CLANG_RESOURCE_DIR}/include)
+else()
+  set(output_dir ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/include)
+endif()
 set(out_files)
 set(generated_files)
 
@@ -420,7 +424,11 @@
 add_header_target("windows-resource-headers" ${windows_only_files})
 add_header_target("utility-resource-headers" ${utility_files})
 
-set(header_install_dir lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include)
+if(NOT CLANG_RESOURCE_DIR STREQUAL "")
+  set(header_install_dir ${CMAKE_INSTALL_BINDIR}/${CLANG_RESOURCE_DIR}/include)
+else()
+  set(header_install_dir 
lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include)
+endif()
 
 #
 # Install rules for the catch-all clang-resource-headers target


Index: clang/lib/Headers/CMakeLists.txt
===
--- clang/lib/Headers/CMakeLists.txt
+++ clang/lib/Headers/CMakeLists.txt
@@ -263,7 +263,11 @@
   openmp_wrappers/new
 )
 
-set(output_dir ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/include)
+if(NOT CLANG_RESOURCE_DIR STREQUAL "")
+  set(output_dir ${LLVM_RUNTIME_OUTPUT_INTDIR}/${CLANG_RESOURCE_DIR}/include)
+else()
+  set(output_dir ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION}/include)
+endif()
 set(out_files)
 set(generated_files)
 
@@ -420,7 +424,11 @@
 add_header_target("windows-resource-headers" ${windows_only_files})
 add_header_target("utility-resource-headers" ${utility_files})
 
-set(header_install_dir lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include)
+if(NOT CLANG_RESOURCE_DIR STREQUAL "")
+  set(header_install_dir ${CMAKE_INSTALL_BINDIR}/${CLANG_RESOURCE_DIR}/include)
+else()
+  set(header_install_dir lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION}/include)
+endif()
 
 #
 # Install rules for the catch-all clang-resource-headers target
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D134671: [Driver] Prevent Mips specific code from claiming -mabi argument on other targets.

2022-09-27 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson accepted this revision.
arichardson 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/D134671/new/

https://reviews.llvm.org/D134671

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


[PATCH] D134410: [clang][CodeGen] Add noundef metadata to load instructions (preliminary)

2022-09-27 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

> Also I applied this patch with D134698  and 
> used on our large test set, expecting significant number of pre-existing 
> reports. To my surprise I see not many of them.

Something wrong with my msan experiment, I'll re-evaluate size and reports 
tomorrow.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134410

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


[PATCH] D134523: [clang][Interp] Fix copy constructors with record array members

2022-09-27 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added inline comments.



Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:332
+  // ArrayIndex might not be set if a ArrayInitIndexExpr is being evaluated
+  // stand-alone, e.g. via EvaluateAsInt().
+  if (!ArrayIndex)

erichkeane wrote:
> For my edification: what reproducer causes us to do this?
The copy constructor in the test added in this patch:
```
constexpr FourBoolPairs LT2 = LT;
```

The backtrace is:

```
#0  0x7fffca0a2c4c in __pthread_kill_implementation () from /lib64/libc.so.6
#1  0x7fffca0529c6 in raise () from /lib64/libc.so.6
#2  0x7fffca03c7f4 in abort () from /lib64/libc.so.6
#3  0x7fffca03c71b in __assert_fail_base.cold () from /lib64/libc.so.6
#4  0x7fffca04b576 in __assert_fail () from /lib64/libc.so.6
#5  0x7fffeab8823e in 
clang::interp::ByteCodeExprGen::VisitArrayInitIndexExpr
 (this=0x7ffd9580, E=0x62193ab0)
at 
/home/tbaeder/code/llvm-project/clang/lib/AST/Interp/ByteCodeExprGen.cpp:335
#6  0x7fffeab806aa in clang::StmtVisitorBase, bool>::Visit 
(this=0x7ffd9580, S=0x62193ab0)
at tools/clang/include/clang/AST/StmtNodes.inc:741
#7  0x7fffeab83b0f in 
clang::interp::ByteCodeExprGen::visit (
this=0x7ffd9580, E=0x62193ab0)
at 
/home/tbaeder/code/llvm-project/clang/lib/AST/Interp/ByteCodeExprGen.cpp:352
#8  0x7fffeab884a7 in 
clang::interp::ByteCodeExprGen::visitExpr (
this=0x7ffd9580, Exp=0x62193ab0)
at 
/home/tbaeder/code/llvm-project/clang/lib/AST/Interp/ByteCodeExprGen.cpp:845
#9  0x7fffeabcdef4 in clang::interp::EvalEmitter::interpretExpr 
(this=0x7ffd9580,
E=0x62193ab0) at 
/home/tbaeder/code/llvm-project/clang/lib/AST/Interp/EvalEmitter.cpp:30
#10 0x7fffeaba93a4 in clang::interp::Context::evaluateAsRValue 
(this=0x60610340, Parent=...,
E=0x62193ab0, Result=...) at 
/home/tbaeder/code/llvm-project/clang/lib/AST/Interp/Context.cpp:61
#11 0x7fffea8e1ae7 in EvaluateAsRValue (Info=..., E=0x62193ab0, 
Result=...)
at /home/tbaeder/code/llvm-project/clang/lib/AST/ExprConstant.cpp:14949
#12 0x7fffea8d69c5 in EvaluateAsRValue (E=0x62193ab0, Result=..., 
Ctx=..., Info=...)
at /home/tbaeder/code/llvm-project/clang/lib/AST/ExprConstant.cpp:15012
#13 0x7fffea8d7490 in EvaluateAsInt (E=0x62193ab0, ExprResult=..., 
Ctx=...,
AllowSideEffects=clang::Expr::SE_AllowSideEffects, Info=...)
at /home/tbaeder/code/llvm-project/clang/lib/AST/ExprConstant.cpp:15023
#14 0x7fffea8d7290 in clang::Expr::EvaluateAsInt (this=0x62193ab0, 
Result=..., Ctx=...,
AllowSideEffects=clang::Expr::SE_AllowSideEffects, InConstantContext=false)
at /home/tbaeder/code/llvm-project/clang/lib/AST/ExprConstant.cpp:15079
#15 0x7fffec9e1d8c in clang::Sema::CheckArrayAccess (this=0x62800100, 
BaseExpr=0x62193a90,
IndexExpr=0x62193ab0, ASE=0x62193b50, AllowOnePastEnd=false, 
IndexNegated=false)
at /home/tbaeder/code/llvm-project/clang/lib/Sema/SemaChecking.cpp:16002
#16 0x7fffec9d9926 in clang::Sema::CheckArrayAccess (this=0x62800100, 
expr=0x62193b50)
at /home/tbaeder/code/llvm-project/clang/lib/Sema/SemaChecking.cpp:16177
#17 0x7fffed8293df in clang::Sema::GatherArgumentsForCall 
(this=0x62800100, CallLoc=...,
FDecl=0x621900e8, Proto=0x62190c20, FirstParam=0, Args=..., 
AllArgs=...,
CallType=clang::Sema::VariadicDoesNotApply, AllowExplicit=true, 
IsListInitialization=false)
at /home/tbaeder/code/llvm-project/clang/lib/Sema/SemaExpr.cpp:6193
#18 0x7fffed3f48aa in clang::Sema::CompleteConstructorCall 
(this=0x62800100,
Constructor=0x621900e8, DeclInitType=..., ArgsPtr=..., Loc=..., 
ConvertedArgs=..., AllowExplicit=true,
IsListInitialization=false) at 
/home/tbaeder/code/llvm-project/clang/lib/Sema/SemaDeclCXX.cpp:15715
#19 0x7fffee39ca73 in PerformConstructorInitialization (S=..., Entity=..., 
Kind=..., Args=...,
Step=..., ConstructorInitRequiresZeroInit=@0x7ffdd5b0: false, 
IsListInitialization=false,
IsStdInitListInitialization=false, LBraceLoc=..., RBraceLoc=...)
at /home/tbaeder/code/llvm-project/clang/lib/Sema/SemaInit.cpp:6591

#20 0x7fffee3841bf in clang::InitializationSequence::Perform 
(this=0x7ffe1390, S=...,
--Type  for more, q to quit, c to continue without paging--
Entity=..., Kind=..., Args=..., ResultType=0x0)
at /home/tbaeder/code/llvm-project/clang/lib/Sema/SemaInit.cpp:8635
#21 0x7fffed4423e5 in BuildImplicitMemberInitializer (SemaRef=..., 
Constructor=0x621904c8,
ImplicitInitKind=IIK_Copy, Field=0x6216c340, Indirect=0x0, 
CXXMemberInit=@0x7ffe5ac0: 0x0)
at /home/tbaeder/code/llvm-project/clang/lib/Sema/SemaDeclCXX.cpp:4854
#22 0x7fffed36f025 in CollectFieldInitializer (SemaRef=..., Info=..., 
Field=0x6216c340,
Indirect=0x0) at 
/home/tbaeder/code/llvm-project/clang/lib/Sema/SemaDeclCXX.cpp:5107
#23 0x7fffed36af43 in clang::Se

[clang] fbb1194 - [AArch64] Add Neoverse V2 CPU support

2022-09-27 Thread David Sherwood via cfe-commits

Author: David Sherwood
Date: 2022-09-27T07:56:08Z
New Revision: fbb119412f143530a23d22b6b0f90d4cf2303fbf

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

LOG: [AArch64] Add Neoverse V2 CPU support

Adds support for the Neoverse V2 CPU to the AArch64 backend.

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/test/Driver/aarch64-mcpu.c
clang/test/Misc/target-invalid-cpu-note.c
llvm/include/llvm/Support/AArch64TargetParser.def
llvm/lib/Support/Host.cpp
llvm/lib/Target/AArch64/AArch64.td
llvm/lib/Target/AArch64/AArch64Subtarget.cpp
llvm/lib/Target/AArch64/AArch64Subtarget.h
llvm/test/CodeGen/AArch64/cpus.ll
llvm/unittests/Support/TargetParserTest.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 5fe86f8bdecd..0dd3b54aa475 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -404,6 +404,8 @@ Arm and AArch64 Support in Clang
 - ``-march`` values for targeting armv2, armv2A, armv3 and armv3M have been 
removed.
   Their presence gave the impression that Clang can correctly generate code for
   them, which it cannot.
+- Add driver and tuning support for Neoverse V2 via the flag 
``-mcpu=neoverse-v2``.
+  Native detection is also supported via ``-mcpu=native``.
 
 Floating Point Support in Clang
 ---

diff  --git a/clang/test/Driver/aarch64-mcpu.c 
b/clang/test/Driver/aarch64-mcpu.c
index d3c30b31f4fc..8b2701f27a9e 100644
--- a/clang/test/Driver/aarch64-mcpu.c
+++ b/clang/test/Driver/aarch64-mcpu.c
@@ -49,6 +49,8 @@
 // NEOVERSE-E1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-e1"
 // RUN: %clang -target aarch64 -mcpu=neoverse-v1  -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-V1 %s
 // NEOVERSE-V1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-v1"
+// RUN: %clang -target aarch64 -mcpu=neoverse-v2  -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-V2 %s
+// NEOVERSE-V2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-v2"
 // RUN: %clang -target aarch64 -mcpu=neoverse-n1 -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-N1 %s
 // NEOVERSE-N1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-n1"
 // RUN: %clang -target aarch64 -mcpu=neoverse-n2 -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-N2 %s

diff  --git a/clang/test/Misc/target-invalid-cpu-note.c 
b/clang/test/Misc/target-invalid-cpu-note.c
index 1f5899fa2649..0fa4d3164111 100644
--- a/clang/test/Misc/target-invalid-cpu-note.c
+++ b/clang/test/Misc/target-invalid-cpu-note.c
@@ -5,11 +5,11 @@
 
 // RUN: not %clang_cc1 -triple arm64--- -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix AARCH64
 // AARCH64: error: unknown target CPU 'not-a-cpu'
-// AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, 
cortex-a53, cortex-a55, cortex-a510, cortex-a57, cortex-a65, cortex-a65ae, 
cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, cortex-a77, 
cortex-a78, cortex-a78c, cortex-a710, cortex-r82, cortex-x1, cortex-x1c, 
cortex-x2, neoverse-e1, neoverse-n1, neoverse-n2, neoverse-512tvb, neoverse-v1, 
cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, apple-a12, 
apple-a13, apple-a14, apple-a15, apple-a16, apple-m1, apple-m2, apple-s4, 
apple-s5, exynos-m3, exynos-m4, exynos-m5, falkor, saphira, kryo, thunderx2t99, 
thunderx3t110, thunderx, thunderxt88, thunderxt81, thunderxt83, tsv110, a64fx, 
carmel, ampere1{{$}}
+// AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, 
cortex-a53, cortex-a55, cortex-a510, cortex-a57, cortex-a65, cortex-a65ae, 
cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, cortex-a77, 
cortex-a78, cortex-a78c, cortex-a710, cortex-r82, cortex-x1, cortex-x1c, 
cortex-x2, neoverse-e1, neoverse-n1, neoverse-n2, neoverse-512tvb, neoverse-v1, 
neoverse-v2, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, 
apple-a12, apple-a13, apple-a14, apple-a15, apple-a16, apple-m1, apple-m2, 
apple-s4, apple-s5, exynos-m3, exynos-m4, exynos-m5, falkor, saphira, kryo, 
thunderx2t99, thunderx3t110, thunderx, thunderxt88, thunderxt81, thunderxt83, 
tsv110, a64fx, carmel, ampere1{{$}}
 
 // RUN: not %clang_cc1 -triple arm64--- -tune-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix TUNE_AARCH64
 // TUNE_AARCH64: error: unknown target CPU 'not-a-cpu'
-// TUNE_AARCH64-NEXT: note: valid target CPU values are: cortex-a34, 
cortex-a35, cortex-a53, cortex-a55, cortex-a510, cortex-a57, cortex-a65, 
cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, 
cortex-a77, cortex-a78, cortex-a78c, cortex-a710, cortex-r82, cortex-x1, 
cortex

[PATCH] D134352: [AArch64] Add Neoverse V2 CPU support

2022-09-27 Thread David Sherwood via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
david-arm marked 3 inline comments as done.
Closed by commit rGfbb119412f14: [AArch64] Add Neoverse V2 CPU support 
(authored by david-arm).

Changed prior to commit:
  https://reviews.llvm.org/D134352?vs=462833&id=463132#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134352

Files:
  clang/docs/ReleaseNotes.rst
  clang/test/Driver/aarch64-mcpu.c
  clang/test/Misc/target-invalid-cpu-note.c
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/lib/Support/Host.cpp
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64Subtarget.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/test/CodeGen/AArch64/cpus.ll
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -1026,6 +1026,17 @@
 AArch64::AEK_PROFILE | AArch64::AEK_RAND |
 AArch64::AEK_FP16FML | AArch64::AEK_I8MM,
 "8.4-A"),
+ARMCPUTestParams(
+"neoverse-v2", "armv9-a", "neon-fp-armv8",
+AArch64::AEK_RAS | AArch64::AEK_SVE | AArch64::AEK_SSBS |
+AArch64::AEK_RCPC | AArch64::AEK_CRC | AArch64::AEK_FP |
+AArch64::AEK_SIMD | AArch64::AEK_MTE | AArch64::AEK_LSE |
+AArch64::AEK_RDM | AArch64::AEK_RCPC | AArch64::AEK_DOTPROD |
+AArch64::AEK_FP16 | AArch64::AEK_BF16 | AArch64::AEK_SVE2 |
+AArch64::AEK_PROFILE | AArch64::AEK_FP16FML |
+AArch64::AEK_I8MM | AArch64::AEK_SVE2BITPERM |
+AArch64::AEK_RAND,
+"9-A"),
 ARMCPUTestParams("cortex-r82", "armv8-r", "crypto-neon-fp-armv8",
  AArch64::AEK_CRC | AArch64::AEK_RDM |
  AArch64::AEK_SSBS | AArch64::AEK_DOTPROD |
@@ -1284,7 +1295,7 @@
  AArch64::AEK_LSE | AArch64::AEK_RDM,
  "8.2-A")));
 
-static constexpr unsigned NumAArch64CPUArchs = 57;
+static constexpr unsigned NumAArch64CPUArchs = 58;
 
 TEST(TargetParserTest, testAArch64CPUArchList) {
   SmallVector List;
Index: llvm/test/CodeGen/AArch64/cpus.ll
===
--- llvm/test/CodeGen/AArch64/cpus.ll
+++ llvm/test/CodeGen/AArch64/cpus.ll
@@ -23,6 +23,7 @@
 ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=neoverse-n2 2>&1 | FileCheck %s
 ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=neoverse-512tvb 2>&1 | FileCheck %s
 ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=neoverse-v1 2>&1 | FileCheck %s
+; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=neoverse-v2 2>&1 | FileCheck %s
 ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=exynos-m3 2>&1 | FileCheck %s
 ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=exynos-m4 2>&1 | FileCheck %s
 ; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=exynos-m5 2>&1 | FileCheck %s
Index: llvm/lib/Target/AArch64/AArch64Subtarget.h
===
--- llvm/lib/Target/AArch64/AArch64Subtarget.h
+++ llvm/lib/Target/AArch64/AArch64Subtarget.h
@@ -76,6 +76,7 @@
 NeoverseN2,
 Neoverse512TVB,
 NeoverseV1,
+NeoverseV2,
 Saphira,
 ThunderX2T99,
 ThunderX,
Index: llvm/lib/Target/AArch64/AArch64Subtarget.cpp
===
--- llvm/lib/Target/AArch64/AArch64Subtarget.cpp
+++ llvm/lib/Target/AArch64/AArch64Subtarget.cpp
@@ -201,6 +201,7 @@
 MaxBytesForLoopAlignment = 16;
 break;
   case NeoverseN2:
+  case NeoverseV2:
 PrefFunctionLogAlignment = 4;
 PrefLoopLogAlignment = 5;
 MaxBytesForLoopAlignment = 16;
Index: llvm/lib/Target/AArch64/AArch64.td
===
--- llvm/lib/Target/AArch64/AArch64.td
+++ llvm/lib/Target/AArch64/AArch64.td
@@ -984,6 +984,12 @@
   FeatureLSLFast,
   FeaturePostRAScheduler]>;
 
+def TuneNeoverseV2 : SubtargetFeature<"neoversev2", "ARMProcFamily", "NeoverseV2",
+  "Neoverse V2 ARM processors", [
+  FeatureFuseAES,
+  FeatureLSLFast,
+  FeaturePostRAScheduler]>;
+
 def TuneSaphira  : SubtargetFeature<"saphira", "ARMProcFamily", "Saphira",
"Qualcomm Saphira processors", [
FeatureCustomCheapAsMoveHandling,
@@ -1155,6 +1161,10 @@
FeatureFullFP16, FeatureMatMulI

[PATCH] D132819: [RISCV] Add MC support of RISCV zcmp Extension

2022-09-27 Thread Xinlong Wu via Phabricator via cfe-commits
VincentWu updated this revision to Diff 463134.
VincentWu marked 9 inline comments as done.
VincentWu added a comment.

address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132819

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.h
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZc.td
  llvm/lib/Target/RISCV/RISCVRegisterInfo.td
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/rv32zcmp-Invalid.s
  llvm/test/MC/RISCV/rv32zcmp-valid.s
  llvm/test/MC/RISCV/rv64zcmp-Invalid.s
  llvm/test/MC/RISCV/rv64zcmp-valid.s

Index: llvm/test/MC/RISCV/rv64zcmp-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv64zcmp-valid.s
@@ -0,0 +1,149 @@
+# RUN: llvm-mc %s -triple=riscv64 -mattr=experimental-zcmp -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=experimental-zcmp < %s \
+# RUN: | llvm-objdump --mattr=-c,experimental-zcmp -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefixes=CHECK-ASM-AND-OBJ %s
+
+# CHECK-ASM-AND-OBJ: cm.mvsa01 s1, s0
+# CHECK-ASM: encoding: [0xa2,0xac]
+cm.mvsa01 s1, s0
+
+# CHECK-ASM-AND-OBJ: cm.mva01s s1, s0
+# CHECK-ASM: encoding: [0xe2,0xac]
+cm.mva01s s1, s0
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra}, 16
+# CHECK-ASM: encoding: [0x42,0xbe]
+cm.popret {ra}, 16
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra}, 32
+# CHECK-ASM: encoding: [0x46,0xbe]
+cm.popret {ra}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0}, 64
+# CHECK-ASM: encoding: [0x5e,0xbe]
+cm.popret {ra, s0}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s1}, 32
+# CHECK-ASM: encoding: [0x62,0xbe]
+cm.popret {ra,s0-s1}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s2}, 32
+# CHECK-ASM: encoding: [0x72,0xbe]
+cm.popret {ra, s0-s2}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s3}, 64
+# CHECK-ASM: encoding: [0x86,0xbe]
+cm.popret {ra, s0-s3}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s5}, 64
+# CHECK-ASM: encoding: [0xa2,0xbe]
+cm.popret {ra, s0-s5}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s7}, 80
+# CHECK-ASM: encoding: [0xc2,0xbe]
+cm.popret {ra, s0-s7}, 80
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s11}, 112
+# CHECK-ASM: encoding: [0xf2,0xbe]
+cm.popret {ra, s0-s11}, 112
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra}, 16
+# CHECK-ASM: encoding: [0x42,0xbc]
+cm.popretz {ra}, 16
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra}, 32
+# CHECK-ASM: encoding: [0x46,0xbc]
+cm.popretz {ra}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0}, 64
+# CHECK-ASM: encoding: [0x5e,0xbc]
+cm.popretz {ra, s0}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s1}, 32
+# CHECK-ASM: encoding: [0x62,0xbc]
+cm.popretz {ra, s0-s1}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s2}, 32
+# CHECK-ASM: encoding: [0x72,0xbc]
+cm.popretz {ra, s0-s2}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s3}, 64
+# CHECK-ASM: encoding: [0x86,0xbc]
+cm.popretz {ra, s0-s3}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s5}, 64
+# CHECK-ASM: encoding: [0xa2,0xbc]
+cm.popretz {ra, s0-s5}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s7}, 80
+# CHECK-ASM: encoding: [0xc2,0xbc]
+cm.popretz {ra, s0-s7}, 80
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s11}, 112
+# CHECK-ASM: encoding: [0xf2,0xbc]
+cm.popretz {ra, s0-s11}, 112
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra}, 16
+# CHECK-ASM: encoding: [0x42,0xba]
+cm.pop {ra}, 16
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra}, 32
+# CHECK-ASM: encoding: [0x46,0xba]
+cm.pop {ra}, 32
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0}, 16
+# CHECK-ASM: encoding: [0x52,0xba]
+cm.pop {ra, s0}, 16
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0-s1}, 32
+# CHECK-ASM: encoding: [0x62,0xba]
+cm.pop {ra, s0-s1}, 32
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0-s2}, 32
+# CHECK-ASM: encoding: [0x72,0xba]
+cm.pop {ra, s0-s2}, 32
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0-s5}, 64
+# CHECK-ASM: encoding: [0xa2,0xba]
+cm.pop {ra, s0-s5}, 64
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0-s7}, 80
+# CHECK-ASM: encoding: [0xc2,0xba]
+cm.pop {ra, s0-s7}, 80
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0-s11}, 112
+# CHECK-ASM: encoding: [0xf2,0xba]
+cm.pop {ra, s0-s11}, 112
+
+# CHECK-ASM-AND-OBJ: cm.push {ra}, -16
+# CHECK-ASM: encoding: [0x42,0xb8]
+cm.push {ra}, -16
+
+# CHECK-ASM-AND-OBJ: cm.push {ra, s0}, -32
+# CHECK-ASM: encoding: [0x56,0xb8]
+cm.push {ra, s0}, -32
+
+# CHECK-ASM-AND-OBJ: cm.push {ra, s0-s1}, -32
+# C

[PATCH] D132819: [RISCV] Add MC support of RISCV zcmp Extension

2022-09-27 Thread Xinlong Wu via Phabricator via cfe-commits
VincentWu updated this revision to Diff 463137.
VincentWu added a comment.

format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132819

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.h
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZc.td
  llvm/lib/Target/RISCV/RISCVRegisterInfo.td
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/rv32zcmp-Invalid.s
  llvm/test/MC/RISCV/rv32zcmp-valid.s
  llvm/test/MC/RISCV/rv64zcmp-Invalid.s
  llvm/test/MC/RISCV/rv64zcmp-valid.s

Index: llvm/test/MC/RISCV/rv64zcmp-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv64zcmp-valid.s
@@ -0,0 +1,149 @@
+# RUN: llvm-mc %s -triple=riscv64 -mattr=experimental-zcmp -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=experimental-zcmp < %s \
+# RUN: | llvm-objdump --mattr=-c,experimental-zcmp -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefixes=CHECK-ASM-AND-OBJ %s
+
+# CHECK-ASM-AND-OBJ: cm.mvsa01 s1, s0
+# CHECK-ASM: encoding: [0xa2,0xac]
+cm.mvsa01 s1, s0
+
+# CHECK-ASM-AND-OBJ: cm.mva01s s1, s0
+# CHECK-ASM: encoding: [0xe2,0xac]
+cm.mva01s s1, s0
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra}, 16
+# CHECK-ASM: encoding: [0x42,0xbe]
+cm.popret {ra}, 16
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra}, 32
+# CHECK-ASM: encoding: [0x46,0xbe]
+cm.popret {ra}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0}, 64
+# CHECK-ASM: encoding: [0x5e,0xbe]
+cm.popret {ra, s0}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s1}, 32
+# CHECK-ASM: encoding: [0x62,0xbe]
+cm.popret {ra,s0-s1}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s2}, 32
+# CHECK-ASM: encoding: [0x72,0xbe]
+cm.popret {ra, s0-s2}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s3}, 64
+# CHECK-ASM: encoding: [0x86,0xbe]
+cm.popret {ra, s0-s3}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s5}, 64
+# CHECK-ASM: encoding: [0xa2,0xbe]
+cm.popret {ra, s0-s5}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s7}, 80
+# CHECK-ASM: encoding: [0xc2,0xbe]
+cm.popret {ra, s0-s7}, 80
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s11}, 112
+# CHECK-ASM: encoding: [0xf2,0xbe]
+cm.popret {ra, s0-s11}, 112
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra}, 16
+# CHECK-ASM: encoding: [0x42,0xbc]
+cm.popretz {ra}, 16
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra}, 32
+# CHECK-ASM: encoding: [0x46,0xbc]
+cm.popretz {ra}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0}, 64
+# CHECK-ASM: encoding: [0x5e,0xbc]
+cm.popretz {ra, s0}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s1}, 32
+# CHECK-ASM: encoding: [0x62,0xbc]
+cm.popretz {ra, s0-s1}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s2}, 32
+# CHECK-ASM: encoding: [0x72,0xbc]
+cm.popretz {ra, s0-s2}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s3}, 64
+# CHECK-ASM: encoding: [0x86,0xbc]
+cm.popretz {ra, s0-s3}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s5}, 64
+# CHECK-ASM: encoding: [0xa2,0xbc]
+cm.popretz {ra, s0-s5}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s7}, 80
+# CHECK-ASM: encoding: [0xc2,0xbc]
+cm.popretz {ra, s0-s7}, 80
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s11}, 112
+# CHECK-ASM: encoding: [0xf2,0xbc]
+cm.popretz {ra, s0-s11}, 112
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra}, 16
+# CHECK-ASM: encoding: [0x42,0xba]
+cm.pop {ra}, 16
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra}, 32
+# CHECK-ASM: encoding: [0x46,0xba]
+cm.pop {ra}, 32
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0}, 16
+# CHECK-ASM: encoding: [0x52,0xba]
+cm.pop {ra, s0}, 16
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0-s1}, 32
+# CHECK-ASM: encoding: [0x62,0xba]
+cm.pop {ra, s0-s1}, 32
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0-s2}, 32
+# CHECK-ASM: encoding: [0x72,0xba]
+cm.pop {ra, s0-s2}, 32
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0-s5}, 64
+# CHECK-ASM: encoding: [0xa2,0xba]
+cm.pop {ra, s0-s5}, 64
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0-s7}, 80
+# CHECK-ASM: encoding: [0xc2,0xba]
+cm.pop {ra, s0-s7}, 80
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0-s11}, 112
+# CHECK-ASM: encoding: [0xf2,0xba]
+cm.pop {ra, s0-s11}, 112
+
+# CHECK-ASM-AND-OBJ: cm.push {ra}, -16
+# CHECK-ASM: encoding: [0x42,0xb8]
+cm.push {ra}, -16
+
+# CHECK-ASM-AND-OBJ: cm.push {ra, s0}, -32
+# CHECK-ASM: encoding: [0x56,0xb8]
+cm.push {ra, s0}, -32
+
+# CHECK-ASM-AND-OBJ: cm.push {ra, s0-s1}, -32
+# CHECK-ASM: encoding: [0x62,0xb8]
+cm.push {ra, s0-s1}, 

[clang] 712de9d - [AArch64] Add all predecessor archs in target info

2022-09-27 Thread Daniel Kiss via cfe-commits

Author: Daniel Kiss
Date: 2022-09-27T10:23:21+02:00
New Revision: 712de9d1716c010e895a578ad86cbd47680a4fdd

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

LOG: [AArch64] Add all predecessor archs in target info

A given function is compatible with all previous arch versions.
To avoid compering values of the attribute this logic adds all predecessor
architecture values.

Reviewed By: dmgreen, DavidSpickett

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

Added: 
clang/test/CodeGen/aarch64-subarch-compatbility.c

Modified: 
clang/lib/Basic/Targets/AArch64.cpp
clang/lib/Basic/Targets/AArch64.h
llvm/include/llvm/Support/AArch64TargetParser.def
llvm/include/llvm/Support/AArch64TargetParser.h
llvm/lib/Support/AArch64TargetParser.cpp
llvm/unittests/Support/TargetParserTest.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index e8745402b58f..604c7bbb8153 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -529,6 +529,22 @@ bool AArch64TargetInfo::hasFeature(StringRef Feature) 
const {
 .Default(false);
 }
 
+void AArch64TargetInfo::setFeatureEnabled(llvm::StringMap &Features,
+  StringRef Name, bool Enabled) const {
+  Features[Name] = Enabled;
+  llvm::AArch64::ArchKind AK = llvm::AArch64::getSubArchArchKind(Name);
+  // Add all previous architecture versions.
+  // In case of v9.x the v8.x counterparts are added too.
+  if ("9" == getArchVersionString(AK))
+for (llvm::AArch64::ArchKind I = llvm::AArch64::convertV9toV8(AK);
+ I != llvm::AArch64::ArchKind::INVALID; --I)
+  Features[llvm::AArch64::getSubArch(I)] = Enabled;
+
+  for (llvm::AArch64::ArchKind I = --AK; I != llvm::AArch64::ArchKind::INVALID;
+   --I)
+Features[llvm::AArch64::getSubArch(I)] = Enabled;
+}
+
 bool AArch64TargetInfo::handleTargetFeatures(std::vector 
&Features,
  DiagnosticsEngine &Diags) {
   FPU = FPUMode;
@@ -620,31 +636,32 @@ bool 
AArch64TargetInfo::handleTargetFeatures(std::vector &Features,
   HasSM4 = true;
 if (Feature == "+strict-align")
   HasUnaligned = false;
-if (Feature == "+v8a")
+// All predecessor archs are added but select the latest one for ArchKind.
+if (Feature == "+v8a" && ArchKind < llvm::AArch64::ArchKind::ARMV8A)
   ArchKind = llvm::AArch64::ArchKind::ARMV8A;
-if (Feature == "+v8.1a")
+if (Feature == "+v8.1a" && ArchKind < llvm::AArch64::ArchKind::ARMV8_1A)
   ArchKind = llvm::AArch64::ArchKind::ARMV8_1A;
-if (Feature == "+v8.2a")
+if (Feature == "+v8.2a" && ArchKind < llvm::AArch64::ArchKind::ARMV8_2A)
   ArchKind = llvm::AArch64::ArchKind::ARMV8_2A;
-if (Feature == "+v8.3a")
+if (Feature == "+v8.3a" && ArchKind < llvm::AArch64::ArchKind::ARMV8_3A)
   ArchKind = llvm::AArch64::ArchKind::ARMV8_3A;
-if (Feature == "+v8.4a")
+if (Feature == "+v8.4a" && ArchKind < llvm::AArch64::ArchKind::ARMV8_4A)
   ArchKind = llvm::AArch64::ArchKind::ARMV8_4A;
-if (Feature == "+v8.5a")
+if (Feature == "+v8.5a" && ArchKind < llvm::AArch64::ArchKind::ARMV8_5A)
   ArchKind = llvm::AArch64::ArchKind::ARMV8_5A;
-if (Feature == "+v8.6a")
+if (Feature == "+v8.6a" && ArchKind < llvm::AArch64::ArchKind::ARMV8_6A)
   ArchKind = llvm::AArch64::ArchKind::ARMV8_6A;
-if (Feature == "+v8.7a")
+if (Feature == "+v8.7a" && ArchKind < llvm::AArch64::ArchKind::ARMV8_7A)
   ArchKind = llvm::AArch64::ArchKind::ARMV8_7A;
-if (Feature == "+v8.8a")
+if (Feature == "+v8.8a" && ArchKind < llvm::AArch64::ArchKind::ARMV8_8A)
   ArchKind = llvm::AArch64::ArchKind::ARMV8_8A;
-if (Feature == "+v9a")
+if (Feature == "+v9a" && ArchKind < llvm::AArch64::ArchKind::ARMV9A)
   ArchKind = llvm::AArch64::ArchKind::ARMV9A;
-if (Feature == "+v9.1a")
+if (Feature == "+v9.1a" && ArchKind < llvm::AArch64::ArchKind::ARMV9_1A)
   ArchKind = llvm::AArch64::ArchKind::ARMV9_1A;
-if (Feature == "+v9.2a")
+if (Feature == "+v9.2a" && ArchKind < llvm::AArch64::ArchKind::ARMV9_2A)
   ArchKind = llvm::AArch64::ArchKind::ARMV9_2A;
-if (Feature == "+v9.3a")
+if (Feature == "+v9.3a" && ArchKind < llvm::AArch64::ArchKind::ARMV9_3A)
   ArchKind = llvm::AArch64::ArchKind::ARMV9_3A;
 if (Feature == "+v8r")
   ArchKind = llvm::AArch64::ArchKind::ARMV8R;

diff  --git a/clang/lib/Basic/Targets/AArch64.h 
b/clang/lib/Basic/Targets/AArch64.h
index 1930092c248b..302cab409745 100644
--- a/clang/lib/Basic/Targets/AArch64.h
+++ b/clang/lib/Basic/Targets/AArch64.h
@@ -114,6 +114,8 @@ class LLVM_LIBRARY_VISIBILITY AArch64TargetInfo : public 
TargetInfo {
   g

[PATCH] D134353: [AArch64] Add all predecessor archs in target info

2022-09-27 Thread Daniel Kiss 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 rG712de9d1716c: [AArch64] Add all predecessor archs in target 
info (authored by danielkiss).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D134353?vs=462842&id=463142#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134353

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/test/CodeGen/aarch64-subarch-compatbility.c
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/include/llvm/Support/AArch64TargetParser.h
  llvm/lib/Support/AArch64TargetParser.cpp
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -1584,6 +1584,27 @@
   }
 }
 
+TEST(TargetParserTest, AArch64ArchV9toV8Conversion) {
+  for (auto AK : AArch64::ArchKinds) {
+if (AK == AArch64::ArchKind::INVALID)
+  EXPECT_EQ(AK, AArch64::convertV9toV8(AK));
+else if (AK < AArch64::ArchKind::ARMV9A)
+  EXPECT_EQ(AK, AArch64::convertV9toV8(AK));
+else if (AK >= AArch64::ArchKind::ARMV8R)
+  EXPECT_EQ(AArch64::ArchKind::INVALID, AArch64::convertV9toV8(AK));
+else
+  EXPECT_TRUE(AArch64::convertV9toV8(AK) < AArch64::ArchKind::ARMV9A);
+  }
+  EXPECT_EQ(AArch64::ArchKind::ARMV8_5A,
+  AArch64::convertV9toV8(AArch64::ArchKind::ARMV9A));
+  EXPECT_EQ(AArch64::ArchKind::ARMV8_6A,
+  AArch64::convertV9toV8(AArch64::ArchKind::ARMV9_1A));
+  EXPECT_EQ(AArch64::ArchKind::ARMV8_7A,
+  AArch64::convertV9toV8(AArch64::ArchKind::ARMV9_2A));
+  EXPECT_EQ(AArch64::ArchKind::ARMV8_8A,
+  AArch64::convertV9toV8(AArch64::ArchKind::ARMV9_3A));
+}
+
 TEST(TargetParserTest, AArch64ArchExtFeature) {
   const char *ArchExt[][4] = {
   {"crc", "nocrc", "+crc", "-crc"},
Index: llvm/lib/Support/AArch64TargetParser.cpp
===
--- llvm/lib/Support/AArch64TargetParser.cpp
+++ llvm/lib/Support/AArch64TargetParser.cpp
@@ -59,6 +59,15 @@
   .Default(ArchKind::INVALID);
 }
 
+AArch64::ArchKind AArch64::getSubArchArchKind(StringRef SubArch) {
+  return StringSwitch(SubArch)
+#define AARCH64_ARCH(NAME, ID, CPU_ATTR, SUB_ARCH, ARCH_ATTR, ARCH_FPU,\
+ ARCH_BASE_EXT)\
+  .Case(SUB_ARCH, ArchKind::ID)
+#include "../../include/llvm/Support/AArch64TargetParser.def"
+  .Default(ArchKind::INVALID);
+}
+
 bool AArch64::getExtensionFeatures(uint64_t Extensions,
std::vector &Features) {
   if (Extensions == AArch64::AEK_INVALID)
@@ -123,6 +132,19 @@
   return StringRef();
 }
 
+AArch64::ArchKind AArch64::convertV9toV8(AArch64::ArchKind AK) {
+  if (AK == AArch64::ArchKind::INVALID)
+return AK;
+  if (AK < AArch64::ArchKind::ARMV9A)
+return AK;
+  if (AK >= AArch64::ArchKind::ARMV8R)
+return AArch64::ArchKind::INVALID;
+  unsigned AK_v8 = static_cast(AArch64::ArchKind::ARMV8_5A);
+  AK_v8 += static_cast(AK) -
+   static_cast(AArch64::ArchKind::ARMV9A);
+  return static_cast(AK_v8);
+}
+
 StringRef AArch64::getDefaultCPU(StringRef Arch) {
   ArchKind AK = parseArch(Arch);
   if (AK == ArchKind::INVALID)
Index: llvm/include/llvm/Support/AArch64TargetParser.h
===
--- llvm/include/llvm/Support/AArch64TargetParser.h
+++ llvm/include/llvm/Support/AArch64TargetParser.h
@@ -113,6 +113,17 @@
 #include "AArch64TargetParser.def"
 };
 
+inline ArchKind &operator--(ArchKind &Kind) {
+  if ((Kind == ArchKind::INVALID) || (Kind == ArchKind::ARMV8A) ||
+  (Kind == ArchKind::ARMV9A) || (Kind == ArchKind::ARMV8R))
+Kind = ArchKind::INVALID;
+  else {
+unsigned KindAsInteger = static_cast(Kind);
+Kind = static_cast(--KindAsInteger);
+  }
+  return Kind;
+}
+
 // FIXME: These should be moved to TargetTuple once it exists
 bool getExtensionFeatures(uint64_t Extensions,
   std::vector &Features);
@@ -124,12 +135,14 @@
 StringRef getSubArch(ArchKind AK);
 StringRef getArchExtName(unsigned ArchExtKind);
 StringRef getArchExtFeature(StringRef ArchExt);
+ArchKind convertV9toV8(ArchKind AK);
 
 // Information by Name
 unsigned getDefaultFPU(StringRef CPU, ArchKind AK);
 uint64_t getDefaultExtensions(StringRef CPU, ArchKind AK);
 StringRef getDefaultCPU(StringRef Arch);
 ArchKind getCPUArchKind(StringRef CPU);
+ArchKind getSubArchArchKind(StringRef SubArch);
 
 // Parser
 ArchKind parseArch(StringRef Arch);
Index: llvm/include/llvm/Support/AArch64TargetParser.def
=

[PATCH] D134717: [Clang][AArch64] Fix va_arg with -mgeneral-regs-only

2022-09-27 Thread Amanieu d'Antras via Phabricator via cfe-commits
Amanieu created this revision.
Amanieu added a reviewer: MaskRay.
Herald added subscribers: StephenFan, kristof.beyls.
Herald added a project: All.
Amanieu requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

With -mgeneral-regs-only, all arguments are passed in GPRs, so we should use 
__gr_top/__gr_offs in va_list even for floating-point types.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134717

Files:
  clang/lib/CodeGen/TargetInfo.cpp


Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -5988,7 +5988,8 @@
 BaseTy = ArrTy->getElementType();
 NumRegs = ArrTy->getNumElements();
   }
-  bool IsFPR = BaseTy->isFloatingPointTy() || BaseTy->isVectorTy();
+  bool IsFPR = CGF.getTarget().hasFeature("fp-armv8") &&
+  (BaseTy->isFloatingPointTy() || BaseTy->isVectorTy());
 
   // The AArch64 va_list type and handling is specified in the Procedure Call
   // Standard, section B.4:


Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -5988,7 +5988,8 @@
 BaseTy = ArrTy->getElementType();
 NumRegs = ArrTy->getNumElements();
   }
-  bool IsFPR = BaseTy->isFloatingPointTy() || BaseTy->isVectorTy();
+  bool IsFPR = CGF.getTarget().hasFeature("fp-armv8") &&
+  (BaseTy->isFloatingPointTy() || BaseTy->isVectorTy());
 
   // The AArch64 va_list type and handling is specified in the Procedure Call
   // Standard, section B.4:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D53847: [C++2a] P0634r3: Down with typename!

2022-09-27 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

It's great to see this make progress.
Can you update cxx_status.html and ReleaseNotes.txt?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D53847

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


[PATCH] D134454: [Driver][Distro] Fix ArchLinux triplet and sysroot detection

2022-09-27 Thread Adrian Ratiu via Phabricator via cfe-commits
10ne1 added inline comments.



Comment at: clang/lib/Driver/Distro.cpp:213
+  // that the Linux OS and distro are properly detected in this cases.
+  llvm::Triple NormTargetOrHost = 
llvm::Triple(Twine(TargetOrHost.normalize()));
+

nickdesaulniers wrote:
> 10ne1 wrote:
> > nickdesaulniers wrote:
> > > Twine has an intentionally non-explicit constructor that accepts a 
> > > StringRef, which also has an intentionally non-explicit constructor that 
> > > accepts a std::string, which is what Triple::normalize() returns.
> > > 
> > > Let's be consistent in the explicit construction of these temporary 
> > > objects by removing the explicit call to the Twine constructor.
> > > 
> > > Also, why is it necessary to normalize the Triple? Can you give an 
> > > example of the "bad" input and how this "fixes" it?
> > I do not claim to fully understand the LLVM toolchain & triplet 
> > auto-detection code, so maybe this normalization is more of a workaround 
> > than a real fix. Maybe we need to do the normalization earlier? I do not 
> > know, any suggestions are welcome.
> > 
> > The behavior I'm seeing is:
> > 
> > If TargetOrHost triplet is "aarch64-linux-gnu" then 
> > TargetOrHost.isOSLinux() == false and GetDistro returns 
> > Distro::UnknownDistro which causes failures like the following when 
> > building the kernel tools:
> > 
> > ```
> > make ARCH=arm64 CC=clang CROSS_COMPILE=aarch64-linux-gnu- bpf
> >   DESCEND bpf
> > 
> > Auto-detecting system features:
> > ...libbfd: [ OFF ]
> > ...disassembler-four-args: [ OFF ]
> > 
> > 
> >   DESCEND bpftool
> > 
> > Auto-detecting system features:
> > ...libbfd: [ on  ]
> > ...disassembler-four-args: [ on  ]
> > ...  zlib: [ OFF ]
> > ...libcap: [ OFF ]
> > ...   clang-bpf-co-re: [ on  ]
> > 
> > 
> > make[2]: *** No rule to make target 
> > '/home/adi/workspace/cola/GOO0021/chromiumos/src/third_party/kernel/v5.15/tools/include/linux/math.h',
> >  needed by 'btf.o'.  Stop.
> > make[1]: *** [Makefile:110: bpftool] Error 2
> > make: *** [Makefile:69: bpf] Error 2
> > ```
> > 
> > If we do the triple normalization step before detecting the distro, the 
> > triplet becomes `aarch64-unknown-linux-gnu` which results in 
> > TargetOrHost.isOSLinux() == true, the distro is properly detected, then the 
> > system features are ON and the build works.
> > If TargetOrHost triplet is "aarch64-linux-gnu" then 
> > TargetOrHost.isOSLinux() == false 
> 
> What?! That sounds like a bug. What does Triple::getOS() return in that case?
> 
> Otherwise it sounds like `GetDistro` is getting called to early, before 
> whatever sets the OS has been initialized correctly.
I've done some further debugging and turns out there was an error in my test 
environment due to the Linux kernel tools/ cleanup patch not being correctly 
applied.

After fixing that I can confirm the values for the triple are correct and this 
normalization is not required anymore:

```
llvm::dbgs() << "TargetOrHost.getOS() = " << TargetOrHost.getOS() << "\n";
llvm::dbgs() << "TargetOrHost.isOSLinux() = " << TargetOrHost.isOSLinux() << 
"\n";
```

produces:

```
TargetOrHost.isOSLinux() = 1
TargetOrHost.getOS() = 9
```

which is what we expect.

I will drop this specific triplet code and update the diff, the only remaining 
open issue is the sysroot detection change below. Thanks for your patience!



Comment at: clang/lib/Driver/ToolChains/Linux.cpp:377-394
+  if (Distro.IsArchLinux()) {
+std::string Path = (InstallDir + "/../../../../"  + TripleStr).str();
+if (getVFS().exists(Path))
+  return Path;
+  }
+
   if (!GCCInstallation.isValid() || !getTriple().isMIPS())

nickdesaulniers wrote:
> 10ne1 wrote:
> > nickdesaulniers wrote:
> > > Do we need the Arch-linux test before the call to 
> > > `GCCInstallation.isValid()`? Otherwise it seems like this duplicates a 
> > > fair amount of code computing the `Path`.  The initial parts of the Path 
> > > seem to match; there's only more to it if the Distro is not arch-linux.
> > In my testing on ArchLinux, `GCCInstallation.isValid()` is always `true`.
> > 
> > The problem is that if test condition doesn't just test for a valid GCC 
> > install, it also tests `getTriple().isMIPS()` which is always false on Arch 
> > Linux which does not support mips, so the sysroot will always be an empty 
> > string.
> > 
> > If you wish I can create a separate commit / review to untangle `if 
> > (!GCCInstallation.isValid() || !getTriple().isMIPS())` and try to reduce 
> > the code duplication, because really having a valid GCC install is 
> > independent from running on mips. What do you think?
> That doesn't make sense.
> 
> If `GCCInstallation.isValid()` is always `true` then we should not be 
> returning the empty string.
It does makes sense if you read the condition carefully:

```
if (!GCC

[PATCH] D134597: [CMake] install clang resource headers into `CLANG_RESOURCE_DIR/include` if `CLANG_RESOURCE_DIR` is not empty

2022-09-27 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134597

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


[PATCH] D134454: [Driver][Distro] Fix ArchLinux triplet and sysroot detection

2022-09-27 Thread Adrian Ratiu via Phabricator via cfe-commits
10ne1 added a comment.

In D134454#3816460 , @MaskRay wrote:

> I am nervous as well as Arch Linux has many derivatives. They likely don't 
> use `ID=arch` in `/etc/os-release`. The patch won't work for them.
> In general, I don't think our current approach adding new `Distro::*` flavors 
> scale or really meet the needs of numerous less-popular distributions.
>
> The last few comments of 
> https://discourse.llvm.org/t/rfc-adding-a-default-file-location-to-config-file-support/63606
>  discuss a generic mechanism solving the distribution difference problem with 
> configuration files.
> Also, the new driver option `--gcc-install-dir` 
> (https://discourse.llvm.org/t/add-gcc-install-dir-deprecate-gcc-toolchain-and-remove-gcc-install-prefix/65091
>  ; milestone: 16.0.0) can be useful for some tasks.

@MaskRay I agree the current /etc/os-release and Distro::* based OS detection 
is not scalable and will require adding more and more per-distro exceptions, 
which is ugly.

However what other option do we currently have other than waiting for the 
generic distro mechanism to be implemented and continue doing workarounds in 
projects depending on LLVM/Clang like the kernel?

My suggestion is to add a Distro::* exception to fix Arch Linux now which will 
also allow to clean up the kernel code and **afterwards**, when the generic 
mechanism is finally implemented, this along with all the other Distro:* 
ugliness can be dropped. Basically I try to avoid blocking for an indefinite 
amount of time for a proper solution, which when it will finally come, will 
drop this code anyway.

What do you think? If you say we should wait, that is fine with me as well.


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

https://reviews.llvm.org/D134454

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


[PATCH] D126481: [analyzer] Handle SymbolCast in SValBuilder

2022-09-27 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

> Assume we have `(int)(short)(int x)`. `VisitSymbolCast` will try to get the 
> constant recursively in the next order:
>
> - `(short)(int x)`
> - `(int x)`
>
> And here is my concern. Whether it is correct to get the range for `int x` 
> and consider it as a correct simplification of `(int)(short)(int x)`. IMO it 
> can't be simplified like that. It should go through the set of conventions 
> and intersections.

I agree that it is not correct to do that if there is a **range** associated 
for the castee symbol, in those cases we should consult with the range based 
solver. However, this patch handles the case when a **constant** value is 
associated to the castee. And in that case, this ought to be correct, the cast 
is handled properly via these functions:  `SValBuilder::evalCast` -> 
`EvalCastVisitor::VisitNonLocConcreteInt` -> `APSIntType::apply`.

Generally, the `Simplifier::Visit` functions should return a simplified symbol 
only if during the visitation we could find a constant value associated to any 
of the visited nodes, it does constant folding. If we simplify with a symbol 
that is constrained into a range and not into a simple value, then there is a 
bug, we should fix that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126481

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


[PATCH] D134597: [CMake] install clang resource headers into `CLANG_RESOURCE_DIR/include` if `CLANG_RESOURCE_DIR` is not empty

2022-09-27 Thread LJC via Phabricator via cfe-commits
paperchalice added a comment.

If it is ready to land, could you commit this change? I don't have commit 
right, thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134597

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


[PATCH] D133683: [c++] implements tentative DR1432 for partial ordering of function template

2022-09-27 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov accepted this revision.
mizvekov added a comment.
This revision is now accepted and ready to land.

Looks good, aside some points:

- Please add test for the conditioning on `ClangABICompat15`.
- Missing release notes.
- FWIW GCC treats the `g(42)` case as not ambiguous, as I expected, so it might 
be worth pointing that out with a FIXME regardless.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133683

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


[PATCH] D134337: [clang] [Driver] More flexible rules for loading default configs (WIP)

2022-09-27 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

In D134337#3817133 , @sepavloff wrote:

> It make sense but the algorithm looks overcomplicated. The current 
> implementation is already too complex and documenting the new algorithm is a 
> challenge.
>
> What about making minimal changes to the current algorithm so that the task 
> of @mgorny can be done, without reasoning about possible profit for someone 
> else? Our customers don't use target overloading and prefixes longer than 
> target, so any change that preserve existing functionality is OK.

Do your customers need all of the current functions? Could you perhaps specify 
the absolutely minimal algorithm you'd need to work, and I'll try to make the 
implementation as simple as possible.

> In D134337#3805368 , @mgorny wrote:
>
>> For driver, it will try:
>>
>> 1. `clang++.cfg` (effective mode)
>> 2. `clang.cfg` (suffix)
>
> It must not break compatibility with existing implementation and allows 
> further extension in future. For more complex use cases driver configuration 
> may implement mode complex syntax as proposed in 
> https://discourse.llvm.org/t/rfc-adding-a-default-file-location-to-config-file-support/63606/41.
>
> @mgorny what modifications to target mode file search are necessary for your 
> task?

For my immediate task, I'm perfectly happy with leaving it as-is, as long as it 
won't get in the way of getting effective driver mode config in. I'm a bit 
worried that better target support may be useful in the future but I suppose 
that ship has sailed already.


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

https://reviews.llvm.org/D134337

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


[PATCH] D134329: [clang-format][NFC] Reformat clang/lib/Format using 6257832bf94f

2022-09-27 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Unfortunately this is failing the "premerge checks"

F24716144: image.png 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134329

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


[PATCH] D134454: [Driver][Distro] Fix ArchLinux sysroot detection

2022-09-27 Thread Adrian Ratiu via Phabricator via cfe-commits
10ne1 updated this revision to Diff 463177.
10ne1 retitled this revision from "[Driver][Distro] Fix ArchLinux triplet and 
sysroot detection" to "[Driver][Distro] Fix ArchLinux sysroot detection".
10ne1 edited the summary of this revision.

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

https://reviews.llvm.org/D134454

Files:
  clang/include/clang/Driver/Distro.h
  clang/lib/Driver/ToolChains/Linux.cpp


Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -370,28 +370,30 @@
 return std::string();
   }
 
-  if (!GCCInstallation.isValid() || !getTriple().isMIPS())
+  if (!GCCInstallation.isValid())
 return std::string();
 
-  // Standalone MIPS toolchains use different names for sysroot folder
-  // and put it into different places. Here we try to check some known
-  // variants.
-
+  const Distro Distro(getDriver().getVFS(), getTriple());
   const StringRef InstallDir = GCCInstallation.getInstallPath();
   const StringRef TripleStr = GCCInstallation.getTriple().str();
   const Multilib &Multilib = GCCInstallation.getMultilib();
+  std::string BasePath = (InstallDir + "/../../../../"  + TripleStr).str();
 
-  std::string Path =
-  (InstallDir + "/../../../../" + TripleStr + "/libc" + 
Multilib.osSuffix())
-  .str();
-
-  if (getVFS().exists(Path))
-return Path;
+  if (Distro.IsArchLinux() && getVFS().exists(BasePath))
+  return BasePath;
 
-  Path = (InstallDir + "/../../../../sysroot" + Multilib.osSuffix()).str();
+  // Standalone MIPS toolchains use different names for sysroot folder
+  // and put it into different places. Here we try to check some known
+  // variants.
+  if (getTriple().isMIPS()) {
+std::string Path = BasePath + "/libc" + Multilib.osSuffix();
+if (getVFS().exists(Path))
+  return Path;
 
-  if (getVFS().exists(Path))
-return Path;
+Path = (InstallDir + "/../../../../sysroot" + Multilib.osSuffix()).str();
+if (getVFS().exists(Path))
+  return Path;
+  }
 
   return std::string();
 }
Index: clang/include/clang/Driver/Distro.h
===
--- clang/include/clang/Driver/Distro.h
+++ clang/include/clang/Driver/Distro.h
@@ -134,6 +134,8 @@
 
   bool IsGentoo() const { return DistroVal == Gentoo; }
 
+  bool IsArchLinux() const { return DistroVal == ArchLinux; }
+
   /// @}
 };
 


Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -370,28 +370,30 @@
 return std::string();
   }
 
-  if (!GCCInstallation.isValid() || !getTriple().isMIPS())
+  if (!GCCInstallation.isValid())
 return std::string();
 
-  // Standalone MIPS toolchains use different names for sysroot folder
-  // and put it into different places. Here we try to check some known
-  // variants.
-
+  const Distro Distro(getDriver().getVFS(), getTriple());
   const StringRef InstallDir = GCCInstallation.getInstallPath();
   const StringRef TripleStr = GCCInstallation.getTriple().str();
   const Multilib &Multilib = GCCInstallation.getMultilib();
+  std::string BasePath = (InstallDir + "/../../../../"  + TripleStr).str();
 
-  std::string Path =
-  (InstallDir + "/../../../../" + TripleStr + "/libc" + Multilib.osSuffix())
-  .str();
-
-  if (getVFS().exists(Path))
-return Path;
+  if (Distro.IsArchLinux() && getVFS().exists(BasePath))
+  return BasePath;
 
-  Path = (InstallDir + "/../../../../sysroot" + Multilib.osSuffix()).str();
+  // Standalone MIPS toolchains use different names for sysroot folder
+  // and put it into different places. Here we try to check some known
+  // variants.
+  if (getTriple().isMIPS()) {
+std::string Path = BasePath + "/libc" + Multilib.osSuffix();
+if (getVFS().exists(Path))
+  return Path;
 
-  if (getVFS().exists(Path))
-return Path;
+Path = (InstallDir + "/../../../../sysroot" + Multilib.osSuffix()).str();
+if (getVFS().exists(Path))
+  return Path;
+  }
 
   return std::string();
 }
Index: clang/include/clang/Driver/Distro.h
===
--- clang/include/clang/Driver/Distro.h
+++ clang/include/clang/Driver/Distro.h
@@ -134,6 +134,8 @@
 
   bool IsGentoo() const { return DistroVal == Gentoo; }
 
+  bool IsArchLinux() const { return DistroVal == ArchLinux; }
+
   /// @}
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D131858: [clang] Track the templated entity in type substitution.

2022-09-27 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

In D131858#3815057 , @davrec wrote:

>> So this patch at least puts that into consistency.
>
> Is there already an analogous breakage for classes then?

I am not sure I follow the question, but I meant that classes were already 
deserealizing templates first, so no need to fix them.

> Given @mizvekov's approaching deadline and @ChuanqiXu's limited availability, 
> I'm inclined to think if @mizvekov can hack together a reasonable fix for 
> this breakage, leaving a more rigorous/general solution for later as 
> @ChuanqiXu suggests he would like to pursue, that would be sufficient to land 
> this.  Does anyone disagree?

Well I wouldn't say this fix is a hack any more than the whole code is, as it's 
already playing by the rules of the existing implementation.

We already have to deal with objects being accessed before they are fully 
deserialized, this is part of the design of the current solution.
The present patch just adds a, presumably new, case where the order is 
important.

Any changes in order to have a more strict, atomic deserialization are out of 
scope here.

By the way, I will let this patch sit for another week, as it will need some 
significant rebasing against a recent change that was merged, which could also 
possibly be reverted.




Comment at: clang/include/clang/AST/Type.h:5060
+  /// Gets the template parameter declaration that was substituted for.
+  const TemplateTypeParmDecl *getReplacedParameter() const;
+

davrec wrote:
> @sammccall , drafting you as a representative for downstream AST users, do 
> you have any objection to changing this return type to a 
> `TemplateTypeParmDecl` from a `TemplateTypeParmType`?  IIUC the change is not 
> strictly necessary but is more for convenience, correct me if I'm wrong 
> @mizvekov.  But I'm inclined to think STTPT is not much used downstream so 
> the churn will be minimal/acceptable, am I wrong?
I don't think this is strictly true.

We don't need to store the type, as that would increase storage for no benefit. 
The type won't have more usable information than the associated parameter 
declaration. The type can support a canonical representation, which we don't 
need.

We will store the template-like declaration + index, and simply access the 
parameter decl from there.
Otherwise creating a type from that requires the ASTContext and would possibly 
involve allocation.



Comment at: clang/include/clang/Sema/Template.h:80
+struct ArgumentListLevel {
+  Decl *AssociatedDecl;
+  ArgList Args;

davrec wrote:
> Actually I think this one should be changed back to `ReplacedDecl` :)
> ReplacedDecl makes perfect sense in MLTAL, AssociatedDecl seems to make 
> better sense in STTPT.
I would be against introducing another term to refer to the same thing...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131858

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


[PATCH] D134454: [Driver][Distro] Fix ArchLinux sysroot detection

2022-09-27 Thread Adrian Ratiu via Phabricator via cfe-commits
10ne1 marked 2 inline comments as done.
10ne1 added a comment.

@nickdesaulniers @MaskRay I've updated the diff & summary based on the review 
comments which I've marked as done. Please tell me what you think. Thank you!


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

https://reviews.llvm.org/D134454

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


[PATCH] D133119: [clang-tidy] Add checker 'bugprone-suspicious-realloc-usage'.

2022-09-27 Thread Whisperity via Phabricator via cfe-commits
whisperity added a comment.

I agree with @martong that `$ = realloc($, ...)` is indicative of something 
going wrong, even if the developer has saved the original value somewhere. Are 
we trying to catch this with Tidy specifically for this reason (instead of 
CSA's stdlib checker, or some taint-related mechanism?). However, @steakhal has 
some merit in saying that developers might prioritise the original over the 
copy, even if they made a copy. I think an easy solution from a documentation 
perspective is to have a test for this at the bottom of the test file. And 
document that we cannot (for one reason or the other) catch this supposed 
solution, **but** //if// you have made a copy already(!), then you might as 
well could have done `void* q = realloc(p, ...)` anyway! Having this documented 
leaves at least //some// paths open for us to fix false positives later, if 
they become a tremendous problem. (I have a gut feeling that they will not, 
that much.)




Comment at: 
clang-tools-extra/clang-tidy/bugprone/SuspiciousReallocUsageCheck.cpp:20-21
+namespace {
+class IsSamePtrExpr : public clang::StmtVisitor /*,
+ public clang::DeclVisitor*/
+{

steakhal wrote:
> Commented code?
(Nit: `using namespace clang` -> The `clang::` should be redundant here.)



Comment at: 
clang-tools-extra/clang-tidy/bugprone/SuspiciousReallocUsageCheck.cpp:87
+return;
+  if (!IsSamePtrExpr().check(PtrInputExpr, PtrResultExpr))
+return;

(We're creating a temporary here, right?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133119

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


[PATCH] D134728: [clangd] Add highlighting modifiers "constructor" and "destructor"

2022-09-27 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler created this revision.
ckandeler added a reviewer: sammccall.
Herald added subscribers: kadircet, arphaman.
Herald added a project: All.
ckandeler requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

This is useful for clients that want to highlight constructors and/or
destructors different from classes, e.g. like functions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134728

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/test/initialize-params.test
  clang-tools-extra/clangd/test/semantic-tokens.test
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -133,16 +133,16 @@
   $Namespace[[abc]]::$Class[[A]] $Variable_decl[[AA]];
   typedef $Namespace[[abc]]::$Class[[A]] $Class_decl[[AAA]];
   struct $Class_decl[[B]] {
-$Class_decl[[B]]();
-~$Class[[B]](); // FIXME: inconsistent with constructor
+$Class_decl_constructor[[B]]();
+~$Class_decl_destructor[[B]]();
 void operator<<($Class[[B]]);
 $Class[[AAA]] $Field_decl[[AA]];
   };
-  $Class[[B]]::$Class_decl[[B]]() {}
-  $Class[[B]]::~$Class[[B]]() {} // FIXME: inconsistent with constructor
+  $Class[[B]]::$Class_decl_constructor[[B]]() {}
+  $Class[[B]]::~$Class_decl_destructor[[B]]() {}
   void $Function_decl[[f]] () {
 $Class[[B]] $LocalVariable_decl[[BB]] = $Class[[B]]();
-$LocalVariable[[BB]].~$Class[[B]]();
+$LocalVariable[[BB]].~$Class_destructor[[B]]();
 $Class[[B]]();
   }
 )cpp",
@@ -301,13 +301,13 @@
 $Class[[Foo]] $Field_decl[[Fo]];
 $Enum[[En]] $Field_decl[[E]];
 int $Field_decl[[I]];
-$Class_decl[[Bar]] ($Class[[Foo]] $Parameter_decl[[F]],
+$Class_decl_constructor[[Bar]] ($Class[[Foo]] $Parameter_decl[[F]],
 $Enum[[En]] $Parameter_decl[[E]])
 : $Field[[Fo]] ($Parameter[[F]]), $Field[[E]] ($Parameter[[E]]),
   $Field[[I]] (123) {}
   };
   class $Class_decl[[Bar2]] : public $Class[[Bar]] {
-$Class_decl[[Bar2]]() : $Class[[Bar]]($Class[[Foo]](), $EnumConstant_readonly[[EC]]) {}
+$Class_decl_constructor[[Bar2]]() : $Class[[Bar]]($Class[[Foo]](), $EnumConstant_readonly[[EC]]) {}
   };
 )cpp",
   R"cpp(
@@ -748,7 +748,7 @@
 static inline int $StaticField_decl_static[[j]] = 0;
 };
 struct $Class_decl[[ClassWithRefMembers]] {
-  $Class_decl[[ClassWithRefMembers]](int $Parameter_decl[[i]])
+  $Class_decl_constructor[[ClassWithRefMembers]](int $Parameter_decl[[i]])
 : $Field[[i1]]($Parameter[[i]]),
   $Field_readonly[[i2]]($Parameter[[i]]),
   $Field[[i3]]($Parameter_usedAsMutableReference[[i]]),
@@ -794,7 +794,7 @@
   $LocalVariable_readonly[[c2]][$LocalVariable[[val]]];
 }
 struct $Class_decl[[S]] {
-  $Class_decl[[S]](int&) {
+  $Class_decl_constructor[[S]](int&) {
 $Class[[S]] $LocalVariable_decl[[s1]]($Field_usedAsMutableReference[[field]]);
 $Class[[S]] $LocalVariable_decl[[s2]]($LocalVariable[[s1]].$Field_usedAsMutableReference[[field]]);
 
Index: clang-tools-extra/clangd/test/semantic-tokens.test
===
--- clang-tools-extra/clangd/test/semantic-tokens.test
+++ clang-tools-extra/clangd/test/semantic-tokens.test
@@ -23,7 +23,7 @@
 # CHECK-NEXT:  4,
 # CHECK-NEXT:  1,
 # CHECK-NEXT:  0,
-# CHECK-NEXT:  8193
+# CHECK-NEXT:  32769
 # CHECK-NEXT:],
 # CHECK-NEXT:"resultId": "1"
 # CHECK-NEXT:  }
@@ -49,7 +49,7 @@
 # CHECK-NEXT:  4,
 # CHECK-NEXT:  1,
 # CHECK-NEXT:  0,
-# CHECK-NEXT:  8193
+# CHECK-NEXT:  32769
 # CHECK-NEXT:],
 #Inserted at position 1
 # CHECK-NEXT:"deleteCount": 0,
@@ -72,12 +72,12 @@
 # CHECK-NEXT:  4,
 # CHECK-NEXT:  1,
 # CHECK-NEXT:  0,
-# CHECK-NEXT:  8193,
+# CHECK-NEXT:  32769,
 # CHECK-NEXT:  1,
 # CHECK-NEXT:  4,
 # CHECK-NEXT:  1,
 # CHECK-NEXT:  0,
-# CHECK-NEXT:  8193
+# CHECK-NEXT:  32769
 # CHECK-NEXT:],
 # CHECK-NEXT:"resultId": "3"
 # CHECK-NEXT:  }
Index: clang-tools-extra/clangd/test/initialize-params.test
===
--- clang-tools-extra/clangd/test/initialize-params.test
+++ clang-tools-extra/clangd/test/initialize-params.test
@@ -67,6 +67,8 @@
 # CHECK-NEXT:"dependen

[PATCH] D133119: [clang-tidy] Add checker 'bugprone-suspicious-realloc-usage'.

2022-09-27 Thread Whisperity via Phabricator via cfe-commits
whisperity added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/SuspiciousReallocUsageCheck.cpp:89-90
+return;
+  diag(Call->getBeginLoc(),
+   "memory block passed to 'realloc' may leak if 'realloc' fails");
+}

I have some reservations about this message, though. It only indirectly states 
the problem: first, the user needs to know what a memory leak is, and then 
needs to know how realloc could fail, and then make the mental connection about 
the overwriting of the pointer. (Also, you're passing a pointer... "memory 
block" is a more abstract term, requiring more knowledge.)

I think for the sake of clarity, we should be more explicit about this.

> taking the returned pointer from 'realloc' overwrites 'XXXPtr' with null
> if allocation fails,
> which may result in a leak of the original buffer

1st line explains how the issue manifests (explicitly saying that you'll get a 
nullpointer in a bad place)
2nd line gives the condition, which is a bit more explicit
3rd line explains the real underlying issue

(Getting the null pointer is the "only" bad path here.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133119

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


[PATCH] D133119: [clang-tidy] Add checker 'bugprone-suspicious-realloc-usage'.

2022-09-27 Thread Whisperity via Phabricator via cfe-commits
whisperity added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/SuspiciousReallocUsageCheck.cpp:89-90
+return;
+  diag(Call->getBeginLoc(),
+   "memory block passed to 'realloc' may leak if 'realloc' fails");
+}

whisperity wrote:
> I have some reservations about this message, though. It only indirectly 
> states the problem: first, the user needs to know what a memory leak is, and 
> then needs to know how realloc could fail, and then make the mental 
> connection about the overwriting of the pointer. (Also, you're passing a 
> pointer... "memory block" is a more abstract term, requiring more knowledge.)
> 
> I think for the sake of clarity, we should be more explicit about this.
> 
> > taking the returned pointer from 'realloc' overwrites 'XXXPtr' with null
> > if allocation fails,
> > which may result in a leak of the original buffer
> 
> 1st line explains how the issue manifests (explicitly saying that you'll get 
> a nullpointer in a bad place)
> 2nd line gives the condition, which is a bit more explicit
> 3rd line explains the real underlying issue
> 
> (Getting the null pointer is the "only" bad path here.)
Also:

```lang=cpp
diag(...) << PtrInputExpr.getSourceRange() << PtrResultExpr.getSourceRange();
```

So the connection that the recipient of the assignment and the 1st parameter is 
the same is more obvious.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133119

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


[PATCH] D133574: [C2x] reject type definitions in offsetof

2022-09-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D133574#3816688 , @inclyc wrote:

> This revision fixes:
>
> **anonymous struct**
>
>> You should be able to pass in the TagDecl directly because the diagnostics
>> engine knows how to print a NamedDecl.
>
> I've switch back to using `Context.getTagDeclType(New)` because this can print
> anonymous pretty.
>
>   clang/test/C/C2x/n2350.c:23:29: error: 'struct (unnamed at 
> clang/test/C/C2x/n2350.c:23:29)' cannot be defined in '__builtin_offsetof'
> return __builtin_offsetof(struct // expected-error-re{{'struct (unnamed 
> at {{.*}})' cannot be defined in '__builtin_offsetof'}}

Thanks! I was very surprised we didn't print the anonymous decl properly from 
the decl itself, so it looks like we have the same bug in other places as well: 
https://godbolt.org/z/16vP3voTW

> **definitions within the second parameter**
>
> I've add a new test case for this. This bug is caused by the RAIIObject having
> incorrect scope.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133574

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


[PATCH] D127484: [clang-format] Use tabs on GNU style

2022-09-27 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

@a4lg If we have decided NOT to do this can we Abandon the review so as to 
remove it from the reviewers "clang-format" lists?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127484

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


[PATCH] D131858: [clang] Track the templated entity in type substitution.

2022-09-27 Thread David Rector via Phabricator via cfe-commits
davrec added a comment.

In D131858#3817646 , @mizvekov wrote:

> In D131858#3815057 , @davrec wrote:
>
>>> So this patch at least puts that into consistency.
>>
>> Is there already an analogous breakage for classes then?
>
> I am not sure I follow the question, but I meant that classes were already 
> deserealizing templates first, so no need to fix them.

Question was referring to @ChuanqiXu 's comment about this patch breaking 
modules for function importing, see his repro (which I haven't looked at 
closely).  I was asking if this meant that classes were already broken in a 
similar way, since you said this patch brings them into consistency.

>> Given @mizvekov's approaching deadline and @ChuanqiXu's limited 
>> availability, I'm inclined to think if @mizvekov can hack together a 
>> reasonable fix for this breakage, leaving a more rigorous/general solution 
>> for later as @ChuanqiXu suggests he would like to pursue, that would be 
>> sufficient to land this.  Does anyone disagree?
>
> Well I wouldn't say this fix is a hack any more than the whole code is, as 
> it's already playing by the rules of the existing implementation.
>
> We already have to deal with objects being accessed before they are fully 
> deserialized, this is part of the design of the current solution.
> The present patch just adds a, presumably new, case where the order is 
> important.
>
> Any changes in order to have a more strict, atomic deserialization are out of 
> scope here.

I think we misunderstand each other again, but are you saying the breakage 
found by @ChuanqiXu does not need to be fixed because it is out of scope?  (If 
classes are already broken due to this issue, the argument might have some 
validity.)

I wouldn't feel comfortable accepting this without either a) a hack to fix the 
breakage or b) @ChuanqiXu saying it is okay.  Maybe best to punt until 
@ChuanqiXu gets back from vacation in a couple weeks IIUC?




Comment at: clang/include/clang/AST/Type.h:5060
+  /// Gets the template parameter declaration that was substituted for.
+  const TemplateTypeParmDecl *getReplacedParameter() const;
+

mizvekov wrote:
> davrec wrote:
> > @sammccall , drafting you as a representative for downstream AST users, do 
> > you have any objection to changing this return type to a 
> > `TemplateTypeParmDecl` from a `TemplateTypeParmType`?  IIUC the change is 
> > not strictly necessary but is more for convenience, correct me if I'm wrong 
> > @mizvekov.  But I'm inclined to think STTPT is not much used downstream so 
> > the churn will be minimal/acceptable, am I wrong?
> I don't think this is strictly true.
> 
> We don't need to store the type, as that would increase storage for no 
> benefit. The type won't have more usable information than the associated 
> parameter declaration. The type can support a canonical representation, which 
> we don't need.
> 
> We will store the template-like declaration + index, and simply access the 
> parameter decl from there.
> Otherwise creating a type from that requires the ASTContext and would 
> possibly involve allocation.
I see, so it is a necessary change, and anyone who really depends on this 
returning the TTPT will need to convert it via 
`Context.getTemplateTypeParmType(...)`.  But any code written 
getReplacementParameter()->getDecl() would just lose the getDecl() and be fine. 
 And since all the info is in decl most people will only need to do the latter. 
 Given the necessity I think that's okay.



Comment at: clang/include/clang/Sema/Template.h:80
+struct ArgumentListLevel {
+  Decl *AssociatedDecl;
+  ArgList Args;

mizvekov wrote:
> davrec wrote:
> > Actually I think this one should be changed back to `ReplacedDecl` :)
> > ReplacedDecl makes perfect sense in MLTAL, AssociatedDecl seems to make 
> > better sense in STTPT.
> I would be against introducing another term to refer to the same thing...
The reason we need this unfortunately vague term "AssociatedDecl" in STTPT is 
because it can either be a template/template-like declaration *or* a 
TemplateTypeParmDecl.  But here in MLTAL, it won't be a TTPD, will it?  It will 
always be the parent template/template-like declaration, right?  So there is no 
need for vagueness.  `ReplacedDecl` or `ParentTemplate` or something like that 
seems more appropriate.  


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131858

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


[PATCH] D121370: [clang-format] SortIncludes should support "@import" lines in Objective-C

2022-09-27 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

@kwk have we bottomed out on this issue? its been stale for a bit. If we are 
not going to work on it further can be "Abandon" the review to get it off our 
lists?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121370

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


[PATCH] D131141: [RISCV] Add MC support of RISCV Zcb Extension

2022-09-27 Thread Xinlong Wu via Phabricator via cfe-commits
VincentWu updated this revision to Diff 463187.
VincentWu marked 9 inline comments as done.
VincentWu added a comment.

address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131141

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfo.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZc.td
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/rv32zcb-invalid.s
  llvm/test/MC/RISCV/rv32zcb-valid.s
  llvm/test/MC/RISCV/rv64zcb-valid.s

Index: llvm/test/MC/RISCV/rv64zcb-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv64zcb-valid.s
@@ -0,0 +1,22 @@
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+m,+zbb,+zba,+experimental-zcb -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+m,+zbb,+zba,+experimental-zcb < %s \
+# RUN: | llvm-objdump --mattr=+m,+zbb,+zba,experimental-zcb -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefixes=CHECK-ASM-AND-OBJ %s
+#
+# RUN: not llvm-mc -triple riscv64 \
+# RUN: -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
+# RUN: not llvm-mc -triple riscv32 -mattr=+m,+zbb,+zba,+experimental-zcb \
+# RUN: -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-NO-RV64 %s
+
+# CHECK-ASM-AND-OBJ: c.zext.w s0
+# CHECK-ASM: encoding: [0x71,0x9c]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zba' (Address Generation Instructions), 'Zcb' (Shortened format for basic bit manipulation instructions){{$}}
+# CHECK-NO-RV64: error: instruction requires the following: RV64I Base Instruction Set{{$}}
+c.zext.w s0
+
+# CHECK-ASM-AND-OBJ: c.zext.w s0
+# CHECK-ASM: encoding: [0x71,0x9c]
+add.uw s0, s0, zero
Index: llvm/test/MC/RISCV/rv32zcb-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv32zcb-valid.s
@@ -0,0 +1,140 @@
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+m,+zbb,+zba,+experimental-zcb -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+m,+zbb,+zba,+experimental-zcb < %s \
+# RUN: | llvm-objdump --mattr=+m,+zbb,+zba,+experimental-zcb -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefixes=CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+m,+zbb,+zba,+experimental-zcb -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+m,+zbb,+zba,+experimental-zcb < %s \
+# RUN: | llvm-objdump --mattr=+m,+zbb,+zba,experimental-zcb -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefixes=CHECK-ASM-AND-OBJ %s
+#
+# RUN: not llvm-mc -triple riscv64 \
+# RUN: -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
+# RUN: not llvm-mc -triple riscv64 \
+# RUN: -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
+
+# CHECK-ASM-AND-OBJ: c.zext.b s0
+# CHECK-ASM: encoding: [0x61,0x9c]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zcb' (Shortened format for basic bit manipulation instructions){{$}}
+c.zext.b s0
+
+# CHECK-ASM-AND-OBJ: c.sext.b s0
+# CHECK-ASM: encoding: [0x65,0x9c]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zbb' (Basic Bit-Manipulation), 'Zcb' (Shortened format for basic bit manipulation instructions){{$}}
+c.sext.b s0
+
+# CHECK-ASM-AND-OBJ: c.zext.h s0
+# CHECK-ASM: encoding: [0x69,0x9c]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zbb' (Basic Bit-Manipulation), 'Zcb' (Shortened format for basic bit manipulation instructions){{$}}
+c.zext.h s0
+
+# CHECK-ASM-AND-OBJ: c.sext.h s0
+# CHECK-ASM: encoding: [0x6d,0x9c]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zbb' (Basic Bit-Manipulation), 'Zcb' (Shortened format for basic bit manipulation instructions){{$}}
+c.sext.h s0
+
+# CHECK-ASM-AND-OBJ: c.not s0
+# CHECK-ASM: encoding: [0x75,0x9c]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zcb' (Shortened format for basic bit manipulation instructions){{$}}
+c.not s0
+
+# CHECK-ASM-AND-OBJ: c.mul s0, s1
+# CHECK-ASM: encoding: [0x45,0x9c]
+# CHECK-NO-EXT: error: instruction requires the following: 'M' (Integer Multiplication and Division) or 'Zmmul' (Integer Multiplication), 'Zcb' (Shortened format for basic bit manipulation instructions){{$}}
+c.mul s0, s1
+
+# CHECK-ASM-AND-OBJ: c.lbu a5, 2(a4)
+# CH

[PATCH] D134454: [Driver][Distro] Fix ArchLinux sysroot detection

2022-09-27 Thread Adrian Ratiu via Phabricator via cfe-commits
10ne1 updated this revision to Diff 463189.
10ne1 added a comment.

Fixed some clang-format problems.


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

https://reviews.llvm.org/D134454

Files:
  clang/include/clang/Driver/Distro.h
  clang/lib/Driver/ToolChains/Linux.cpp


Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -370,28 +370,30 @@
 return std::string();
   }
 
-  if (!GCCInstallation.isValid() || !getTriple().isMIPS())
+  if (!GCCInstallation.isValid())
 return std::string();
 
-  // Standalone MIPS toolchains use different names for sysroot folder
-  // and put it into different places. Here we try to check some known
-  // variants.
-
+  const Distro Distro(getDriver().getVFS(), getTriple());
   const StringRef InstallDir = GCCInstallation.getInstallPath();
   const StringRef TripleStr = GCCInstallation.getTriple().str();
   const Multilib &Multilib = GCCInstallation.getMultilib();
+  std::string BasePath = (InstallDir + "/../../../../" + TripleStr).str();
 
-  std::string Path =
-  (InstallDir + "/../../../../" + TripleStr + "/libc" + 
Multilib.osSuffix())
-  .str();
-
-  if (getVFS().exists(Path))
-return Path;
+  if (Distro.IsArchLinux() && getVFS().exists(BasePath))
+return BasePath;
 
-  Path = (InstallDir + "/../../../../sysroot" + Multilib.osSuffix()).str();
+  // Standalone MIPS toolchains use different names for sysroot folder
+  // and put it into different places. Here we try to check some known
+  // variants.
+  if (getTriple().isMIPS()) {
+std::string Path = BasePath + "/libc" + Multilib.osSuffix();
+if (getVFS().exists(Path))
+  return Path;
 
-  if (getVFS().exists(Path))
-return Path;
+Path = (InstallDir + "/../../../../sysroot" + Multilib.osSuffix()).str();
+if (getVFS().exists(Path))
+  return Path;
+  }
 
   return std::string();
 }
Index: clang/include/clang/Driver/Distro.h
===
--- clang/include/clang/Driver/Distro.h
+++ clang/include/clang/Driver/Distro.h
@@ -134,6 +134,8 @@
 
   bool IsGentoo() const { return DistroVal == Gentoo; }
 
+  bool IsArchLinux() const { return DistroVal == ArchLinux; }
+
   /// @}
 };
 


Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -370,28 +370,30 @@
 return std::string();
   }
 
-  if (!GCCInstallation.isValid() || !getTriple().isMIPS())
+  if (!GCCInstallation.isValid())
 return std::string();
 
-  // Standalone MIPS toolchains use different names for sysroot folder
-  // and put it into different places. Here we try to check some known
-  // variants.
-
+  const Distro Distro(getDriver().getVFS(), getTriple());
   const StringRef InstallDir = GCCInstallation.getInstallPath();
   const StringRef TripleStr = GCCInstallation.getTriple().str();
   const Multilib &Multilib = GCCInstallation.getMultilib();
+  std::string BasePath = (InstallDir + "/../../../../" + TripleStr).str();
 
-  std::string Path =
-  (InstallDir + "/../../../../" + TripleStr + "/libc" + Multilib.osSuffix())
-  .str();
-
-  if (getVFS().exists(Path))
-return Path;
+  if (Distro.IsArchLinux() && getVFS().exists(BasePath))
+return BasePath;
 
-  Path = (InstallDir + "/../../../../sysroot" + Multilib.osSuffix()).str();
+  // Standalone MIPS toolchains use different names for sysroot folder
+  // and put it into different places. Here we try to check some known
+  // variants.
+  if (getTriple().isMIPS()) {
+std::string Path = BasePath + "/libc" + Multilib.osSuffix();
+if (getVFS().exists(Path))
+  return Path;
 
-  if (getVFS().exists(Path))
-return Path;
+Path = (InstallDir + "/../../../../sysroot" + Multilib.osSuffix()).str();
+if (getVFS().exists(Path))
+  return Path;
+  }
 
   return std::string();
 }
Index: clang/include/clang/Driver/Distro.h
===
--- clang/include/clang/Driver/Distro.h
+++ clang/include/clang/Driver/Distro.h
@@ -134,6 +134,8 @@
 
   bool IsGentoo() const { return DistroVal == Gentoo; }
 
+  bool IsArchLinux() const { return DistroVal == ArchLinux; }
+
   /// @}
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D134177: Add MC support of RISCV Zcd Extension

2022-09-27 Thread Xinlong Wu via Phabricator via cfe-commits
VincentWu updated this revision to Diff 463202.
VincentWu added a comment.

address comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134177

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfoC.td
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/MC/RISCV/compress-rv32d.s
  llvm/test/MC/RISCV/rv32dc-valid.s
  llvm/test/MC/RISCV/rv64dc-valid.s

Index: llvm/test/MC/RISCV/rv64dc-valid.s
===
--- llvm/test/MC/RISCV/rv64dc-valid.s
+++ llvm/test/MC/RISCV/rv64dc-valid.s
@@ -3,31 +3,39 @@
 # RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+c,+d < %s \
 # RUN: | llvm-objdump --mattr=+c,+d -M no-aliases -d -r - \
 # RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zcd,+d -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+experimental-zcd,+d < %s \
+# RUN: | llvm-objdump --mattr=+experimental-zcd,+d -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
 #
 # RUN: not llvm-mc -triple riscv64 -mattr=+c \
 # RUN: -riscv-no-aliases -show-encoding < %s 2>&1 \
 # RUN: | FileCheck -check-prefixes=CHECK-NO-EXT-D %s
+# RUN: not llvm-mc -triple riscv64 -mattr=+experimental-zcd \
+# RUN: -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-NO-EXT-D %s
 # RUN: not llvm-mc -triple riscv64 -riscv-no-aliases -show-encoding < %s 2>&1 \
 # RUN: | FileCheck -check-prefixes=CHECK-NO-EXT-DC %s
 
 # CHECK-ASM-AND-OBJ: c.fldsp  fs0, 504(sp)
 # CHECK-ASM: encoding: [0x7e,0x34]
 # CHECK-NO-EXT-D:  error: instruction requires the following: 'D' (Double-Precision Floating-Point){{$}}
-# CHECK-NO-EXT-DC:  error: instruction requires the following: 'C' (Compressed Instructions), 'D' (Double-Precision Floating-Point){{$}}
+# CHECK-NO-EXT-DC:  error: instruction requires the following: 'C' (Compressed Instructions) or 'Zcd' (Compressed Double-Precision Floating-Point Instructions), 'D' (Double-Precision Floating-Point){{$}}
 c.fldsp  fs0, 504(sp)
 # CHECK-ASM-AND-OBJ: c.fsdsp  fa7, 504(sp)
 # CHECK-ASM: encoding: [0xc6,0xbf]
 # CHECK-NO-EXT-D:  error: instruction requires the following: 'D' (Double-Precision Floating-Point){{$}}
-# CHECK-NO-EXT-DC:  error: instruction requires the following: 'C' (Compressed Instructions), 'D' (Double-Precision Floating-Point){{$}}
+# CHECK-NO-EXT-DC:  error: instruction requires the following: 'C' (Compressed Instructions) or 'Zcd' (Compressed Double-Precision Floating-Point Instructions), 'D' (Double-Precision Floating-Point){{$}}
 c.fsdsp  fa7, 504(sp)
 
 # CHECK-ASM-AND-OBJ: c.fld  fa3, 248(a5)
 # CHECK-ASM: encoding: [0xf4,0x3f]
 # CHECK-NO-EXT-D:  error: instruction requires the following: 'D' (Double-Precision Floating-Point){{$}}
-# CHECK-NO-EXT-DC:  error: instruction requires the following: 'C' (Compressed Instructions), 'D' (Double-Precision Floating-Point){{$}}
+# CHECK-NO-EXT-DC:  error: instruction requires the following: 'C' (Compressed Instructions) or 'Zcd' (Compressed Double-Precision Floating-Point Instructions), 'D' (Double-Precision Floating-Point){{$}}
 c.fld  fa3, 248(a5)
 # CHECK-ASM-AND-OBJ: c.fsd  fa2, 248(a1)
 # CHECK-ASM: encoding: [0xf0,0xbd]
 # CHECK-NO-EXT-D:  error: instruction requires the following: 'D' (Double-Precision Floating-Point){{$}}
-# CHECK-NO-EXT-DC:  error: instruction requires the following: 'C' (Compressed Instructions), 'D' (Double-Precision Floating-Point){{$}}
+# CHECK-NO-EXT-DC:  error: instruction requires the following: 'C' (Compressed Instructions) or 'Zcd' (Compressed Double-Precision Floating-Point Instructions), 'D' (Double-Precision Floating-Point){{$}}
 c.fsd  fa2, 248(a1)
Index: llvm/test/MC/RISCV/rv32dc-valid.s
===
--- llvm/test/MC/RISCV/rv32dc-valid.s
+++ llvm/test/MC/RISCV/rv32dc-valid.s
@@ -3,31 +3,39 @@
 # RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+c,+d < %s \
 # RUN: | llvm-objdump --mattr=+c,+d -M no-aliases -d -r - \
 # RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zcd,+d -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+experimental-zcd,+d < %s \
+# RUN: | llvm-objdump --mattr=+experimental-zcd,+d -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
 #
 # RUN: not llvm-mc -triple riscv32 -mattr=+c \
 # RUN: -riscv-no-aliases -show-encoding < %s 2>&1 \
 # RUN: | FileCheck -check-prefixes=CHECK-NO-EXT-D %s
+# RUN: not llvm-mc -t

[PATCH] D134176: Add MC support of RISCV Zcf Extension

2022-09-27 Thread Xinlong Wu via Phabricator via cfe-commits
VincentWu updated this revision to Diff 463203.
VincentWu added a comment.

add testcase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134176

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfoC.td
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/MC/RISCV/compress-rv32f.s
  llvm/test/MC/RISCV/rv32fc-valid.s

Index: llvm/test/MC/RISCV/rv32fc-valid.s
===
--- llvm/test/MC/RISCV/rv32fc-valid.s
+++ llvm/test/MC/RISCV/rv32fc-valid.s
@@ -3,41 +3,52 @@
 # RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+c,+f < %s \
 # RUN: | llvm-objdump --mattr=+c,+f -M no-aliases -d -r - \
 # RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zcf,+f -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+experimental-zcf,+f < %s \
+# RUN: | llvm-objdump --mattr=+experimental-zcf,+f -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
 #
 # RUN: not llvm-mc -triple riscv32 -mattr=+c \
 # RUN: -riscv-no-aliases -show-encoding < %s 2>&1 \
 # RUN: | FileCheck -check-prefixes=CHECK-NO-EXT-F %s
+# RUN: not llvm-mc -triple riscv32 -mattr=+experimental-zcf \
+# RUN: -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-NO-EXT-F %s
 # RUN: not llvm-mc -triple riscv32 \
 # RUN: -riscv-no-aliases -show-encoding < %s 2>&1 \
 # RUN: | FileCheck -check-prefixes=CHECK-NO-EXT-FC %s
 # RUN: not llvm-mc -triple riscv64 -mattr=+c,+f \
 # RUN: -riscv-no-aliases -show-encoding < %s 2>&1 \
 # RUN: | FileCheck -check-prefixes=CHECK-NO-RV32 %s
+# RUN: not llvm-mc -triple riscv64 -mattr=+experimental-zcf,+f \
+# RUN: -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-NO-RV32 %s
 
 # FIXME: error messages for rv64fc are misleading
 
 # CHECK-ASM-AND-OBJ: c.flwsp  fs0, 252(sp)
 # CHECK-ASM: encoding: [0x7e,0x74]
 # CHECK-NO-EXT-F:  error: instruction requires the following: 'F' (Single-Precision Floating-Point){{$}}
-# CHECK-NO-EXT-FC:  error: instruction requires the following: 'C' (Compressed Instructions), 'F' (Single-Precision Floating-Point){{$}}
+# CHECK-NO-EXT-FC:  error: instruction requires the following: 'C' (Compressed Instructions) or 'Zcf' (Compressed Single-Precision Floating-Point Instructions), 'F' (Single-Precision Floating-Point){{$}}
 # CHECK-NO-RV32:  error: instruction requires the following: RV32I Base Instruction Set{{$}}
 c.flwsp  fs0, 252(sp)
 # CHECK-ASM-AND-OBJ: c.fswsp  fa7, 252(sp)
 # CHECK-ASM: encoding: [0xc6,0xff]
 # CHECK-NO-EXT-F:  error: instruction requires the following: 'F' (Single-Precision Floating-Point){{$}}
-# CHECK-NO-EXT-FC:  error: instruction requires the following: 'C' (Compressed Instructions), 'F' (Single-Precision Floating-Point){{$}}
+# CHECK-NO-EXT-FC:  error: instruction requires the following: 'C' (Compressed Instructions) or 'Zcf' (Compressed Single-Precision Floating-Point Instructions), 'F' (Single-Precision Floating-Point){{$}}
 # CHECK-NO-RV32:  error: instruction requires the following: RV32I Base Instruction Set{{$}}
 c.fswsp  fa7, 252(sp)
 
 # CHECK-ASM-AND-OBJ: c.flw  fa3, 124(a5)
 # CHECK-ASM: encoding: [0xf4,0x7f]
 # CHECK-NO-EXT-F:  error: instruction requires the following: 'F' (Single-Precision Floating-Point){{$}}
-# CHECK-NO-EXT-FC:  error: instruction requires the following: 'C' (Compressed Instructions), 'F' (Single-Precision Floating-Point){{$}}
+# CHECK-NO-EXT-FC:  error: instruction requires the following: 'C' (Compressed Instructions) or 'Zcf' (Compressed Single-Precision Floating-Point Instructions), 'F' (Single-Precision Floating-Point){{$}}
 # CHECK-NO-RV32:  error: instruction requires the following: RV32I Base Instruction Set{{$}}
 c.flw  fa3, 124(a5)
 # CHECK-ASM-AND-OBJ: c.fsw  fa2, 124(a1)
 # CHECK-ASM: encoding: [0xf0,0xfd]
 # CHECK-NO-EXT-F:  error: instruction requires the following: 'F' (Single-Precision Floating-Point){{$}}
-# CHECK-NO-EXT-FC:  error: instruction requires the following: 'C' (Compressed Instructions), 'F' (Single-Precision Floating-Point){{$}}
+# CHECK-NO-EXT-FC:  error: instruction requires the following: 'C' (Compressed Instructions) or 'Zcf' (Compressed Single-Precision Floating-Point Instructions), 'F' (Single-Precision Floating-Point){{$}}
 # CHECK-NO-RV32:  error: instruction requires the following: RV32I Base Instruction Set{{$}}
 c.fsw  fa2, 124(a1)
Index: llvm/test/MC/RISCV/compress-rv32f.s
===
--- llvm/test/MC/RISCV/compress-rv32f.s
+++ llvm/test/MC/RISCV/compress-rv32f.s
@@ -8,6 +8,16 @@
 # RUN: llvm-mc

[PATCH] D134337: [clang] [Driver] More flexible rules for loading default configs (WIP)

2022-09-27 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 463201.
mgorny edited the summary of this revision.
mgorny added a comment.

Ok, how about this variant? I think it's the simplest I can come up with that 
roughly matches the old behavior and adds what's necessary for the new.

The algorithm is to use:

1. `-.cfg` if available, using the real ``,
2. `-.cfg` if available, using `` inferred from executable 
name,
3. `.cfg` + `.cfg` if either is available, using the real 
``,
4. `.cfg` + `.cfg` if either is available, using the `` 
inferred from executable.

The important features of this are:

1. Triple accounts for `-m32` and other options changing mode, so 
x86_64-specific configs won't be used when building 32-bit executables.
2. Triple accounts for executable prefix, so the existing configs will continue 
to work (presuming that your customers do not use `--target`, as you noted).
3. It accounts both for real mode and mode inferred from executable, so it will 
prefer the correct config when `--driver-mode=` is used but it will also work 
with existing configs that used different executable names.

Unlike the previous mode, there's no potential confusion between 32-bit and 
64-bit configs, and the logic is definitely less confusing.


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

https://reviews.llvm.org/D134337

Files:
  clang/include/clang/Driver/Driver.h
  clang/lib/Driver/Driver.cpp

Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1064,79 +1064,55 @@
 bool Driver::loadDefaultConfigFiles(ArrayRef CfgFileSearchDirs) {
   if (CLOptions && CLOptions->hasArg(options::OPT_no_default_config))
 return false;
-  if (ClangNameParts.TargetPrefix.empty())
-return false;
 
-  // If config file is not specified explicitly, try to deduce configuration
-  // from executable name. For instance, an executable 'armv7l-clang' will
-  // search for config file 'armv7l-clang.cfg'.
-  std::string CfgFileName =
-ClangNameParts.TargetPrefix + '-' + ClangNameParts.ModeSuffix;
-
-  // Determine architecture part of the file name, if it is present.
-  StringRef CfgFileArch = CfgFileName;
-  size_t ArchPrefixLen = CfgFileArch.find('-');
-  if (ArchPrefixLen == StringRef::npos)
-ArchPrefixLen = CfgFileArch.size();
-  llvm::Triple CfgTriple;
-  CfgFileArch = CfgFileArch.take_front(ArchPrefixLen);
-  CfgTriple = llvm::Triple(llvm::Triple::normalize(CfgFileArch));
-  if (CfgTriple.getArch() == llvm::Triple::ArchType::UnknownArch)
-ArchPrefixLen = 0;
-
-  if (!StringRef(CfgFileName).endswith(".cfg"))
-CfgFileName += ".cfg";
-
-  // If config file starts with architecture name and command line options
-  // redefine architecture (with options like -m32 -LE etc), try finding new
-  // config file with that architecture.
-  SmallString<128> FixedConfigFile;
-  size_t FixedArchPrefixLen = 0;
-  if (ArchPrefixLen) {
-// Get architecture name from config file name like 'i386.cfg' or
-// 'armv7l-clang.cfg'.
-// Check if command line options changes effective triple.
-llvm::Triple EffectiveTriple =
-computeTargetTriple(*this, CfgTriple.getTriple(), *CLOptions);
-if (CfgTriple.getArch() != EffectiveTriple.getArch()) {
-  FixedConfigFile = EffectiveTriple.getArchName();
-  FixedArchPrefixLen = FixedConfigFile.size();
-  // Append the rest of original file name so that file name transforms
-  // like: i386-clang.cfg -> x86_64-clang.cfg.
-  if (ArchPrefixLen < CfgFileName.size())
-FixedConfigFile += CfgFileName.substr(ArchPrefixLen);
-}
-  }
-
-  // Try to find config file. First try file with corrected architecture.
+  llvm::Triple RealTriple =
+  computeTargetTriple(*this, TargetTriple, *CLOptions);
+  assert(!RealTriple.str().empty());
+  StringRef RealMode = getExecutableForDriverMode(Mode);
+
+  // Search for config files in the following order:
+  // 1. -.cfg using real driver mode
+  //(e.g. i386-pc-linux-gnu-clang++.cfg).
+  // 2. -.cfg using executable suffix
+  //(e.g. i386-pc-linux-gnu-clang-g++.cfg).
+  // 3. .cfg + .cfg using real driver mode
+  //(e.g. i386-pc-linux-gnu.cfg + clang++.cfg).
+  // 4. .cfg + .cfg using executable suffix
+  //(e.g. i386-pc-linux-gnu.cfg + clang-g++.cfg).
+
+  // Try loading full config (variants 1. and 2.)
   llvm::SmallString<128> CfgFilePath;
-  if (!FixedConfigFile.empty()) {
-if (searchForFile(CfgFilePath, CfgFileSearchDirs, FixedConfigFile,
-  getVFS()))
-  return readConfigFile(CfgFilePath);
-// If 'x86_64-clang.cfg' was not found, try 'x86_64.cfg'.
-FixedConfigFile.resize(FixedArchPrefixLen);
-FixedConfigFile.append(".cfg");
-if (searchForFile(CfgFilePath, CfgFileSearchDirs, FixedConfigFile,
-  getVFS()))
+  std::string CfgFileName = RealTriple.str() + '-' + RealMode.str() + ".cfg";
+  if (searchFor

[PATCH] D134733: [clang-format][chore] transparent #include name regex

2022-09-27 Thread Konrad Wilhelm Kleine via Phabricator via cfe-commits
kwk created this revision.
kwk added a reviewer: MyDeveloperDay.
Herald added a project: All.
kwk requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The foundation for this patch was done in:
https://reviews.llvm.org/D121370. I wanted to "rescue" some pieces from
it.

Unlike D121370 , this patch doesn't modify 
the regular expression itself.
It simply provides three functions to have a cleaner and more
transparent way how the include name is processed from an `#include`
line.

Here's how I've tested this patch:

  $ cd llvm-project
  $ mkdir build && cd build
  $ cmake ../llvm/ -DCMAKE_BUILD_TYPE=Release -DCLANG_BUILD_TOOLS=On 
-DLLVM_ENABLE_PROJECTS=clang -DCLANG_INCLUDE_TESTS=ON -DLLVM_BUILD_UTILS=ON -G 
Ninja
  $ ninja clangFormat
  $ ninja FormatTests
  $ ./tools/clang/unittests/Format/FormatTests --gtest_filter=SortIncludesTest*

And if that worked I doubled checked that nothing else broke by running
all format checks:

  $ ./tools/clang/unittests/Format/FormatTests


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134733

Files:
  clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
  clang/lib/Format/Format.cpp
  clang/lib/Tooling/Inclusions/HeaderIncludes.cpp

Index: clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
===
--- clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
+++ clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
@@ -169,13 +169,6 @@
   });
 }
 
-inline StringRef trimInclude(StringRef IncludeName) {
-  return IncludeName.trim("\"<>");
-}
-
-const char IncludeRegexPattern[] =
-R"(^[\t\ ]*#[\t\ ]*(import|include)[^"<]*(["<][^">]*[">]))";
-
 // The filename of Path excluding extension.
 // Used to match implementation with headers, this differs from sys::path::stem:
 //  - in names with multiple dots (foo.cu.cc) it terminates at the *first*
@@ -274,8 +267,7 @@
   MaxInsertOffset(MinInsertOffset +
   getMaxHeaderInsertionOffset(
   FileName, Code.drop_front(MinInsertOffset), Style)),
-  Categories(Style, FileName),
-  IncludeRegex(llvm::Regex(IncludeRegexPattern)) {
+  Categories(Style, FileName), IncludeRegex(getCppIncludeRegex()) {
   // Add 0 for main header and INT_MAX for headers that are not in any
   // category.
   Priorities = {0, INT_MAX};
@@ -290,10 +282,11 @@
   for (auto Line : Lines) {
 NextLineOffset = std::min(Code.size(), Offset + Line.size() + 1);
 if (IncludeRegex.match(Line, &Matches)) {
+  StringRef IncludeName = tooling::getIncludeNameFromMatches(Matches);
   // If this is the last line without trailing newline, we need to make
   // sure we don't delete across the file boundary.
   addExistingInclude(
-  Include(Matches[2],
+  Include(IncludeName,
   tooling::Range(
   Offset, std::min(Line.size() + 1, Code.size() - Offset))),
   NextLineOffset);
@@ -403,5 +396,24 @@
   return Result;
 }
 
+llvm::Regex getCppIncludeRegex() {
+  static const char CppIncludeRegexPattern[] =
+  R"(^[\t\ ]*#[\t\ ]*(import|include)[^"<]*(["<][^">]*[">]))";
+  return llvm::Regex(CppIncludeRegexPattern);
+}
+
+llvm::StringRef getIncludeNameFromMatches(
+const llvm::SmallVectorImpl &Matches) {
+  if (Matches.size() >= 3) {
+return Matches[2];
+  }
+  llvm_unreachable("Matches is too small");
+  return llvm::StringRef();
+}
+
+llvm::StringRef trimInclude(llvm::StringRef IncludeName) {
+  return IncludeName.trim("\"<>;");
+}
+
 } // namespace tooling
 } // namespace clang
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -44,6 +44,7 @@
 #include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/YAMLTraits.h"
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -2769,13 +2770,6 @@
   }
 }
 
-namespace {
-
-const char CppIncludeRegexPattern[] =
-R"(^[\t\ ]*#[\t\ ]*(import|include)[^"<]*(["<][^">]*[">]))";
-
-} // anonymous namespace
-
 tooling::Replacements sortCppIncludes(const FormatStyle &Style, StringRef Code,
   ArrayRef Ranges,
   StringRef FileName,
@@ -2785,7 +2779,7 @@
   .StartsWith("\xEF\xBB\xBF", 3) // UTF-8 BOM
   .Default(0);
   unsigned SearchFrom = 0;
-  llvm::Regex IncludeRegex(CppIncludeRegexPattern);
+  llvm::Regex IncludeRegex(tooling::getCppIncludeRegex());
   SmallVector Matches;
   SmallVector IncludesInBlock;
 
@@ -2843,7 +2837,8 @@
 bool MergeWithNextLine = Trimmed.endswith("\\");
 if (!FormattingOff && !MergeWithNextLine) {
   if (IncludeRegex.match(Line, &Matches)) {
-StringRef IncludeName = Matches[2];
+StringRef IncludeName = tooling::getIncludeNameFromMatches(Matches)

[PATCH] D121370: [clang-format] SortIncludes should support "@import" lines in Objective-C

2022-09-27 Thread Konrad Wilhelm Kleine via Phabricator via cfe-commits
kwk abandoned this revision.
kwk added a comment.

In D121370#3817753 , @MyDeveloperDay 
wrote:

> @kwk have we bottomed out on this issue? its been stale for a bit. If we are 
> not going to work on it further can be "Abandon" the review to get it off our 
> lists?

We can abandon this patch and I might look into it some other time. But I 
wanted to rescue bits from this patch that don't change the current behavior. 
That's why I've created: https://reviews.llvm.org/D134733 . I hope we can 
approve it to get the transparency in and make a patch like D121370 
 a bit smaller in the future.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121370

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


[PATCH] D133683: [c++] implements tentative DR1432 for partial ordering of function template

2022-09-27 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.

Just fix @mizvekov 's nits (the fixme, release notes, and ABI test), and LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133683

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


[PATCH] D134507: [Clang] add missing ClangABICompat check

2022-09-27 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a subscriber: rjmccall.
probinson added a comment.

It feels odd to use a ClangABI check for something that is affecting what 
source is accepted, but this is not my area of expertise.
@aaron.ballman or @rjmccall would probably be the right people to weigh in on 
this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134507

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


[PATCH] D134673: [Driver][PS4] pass -fcrash-diagnostics-dir to LTO

2022-09-27 Thread Paul Robinson via Phabricator via cfe-commits
probinson accepted this revision.
probinson 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/D134673/new/

https://reviews.llvm.org/D134673

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


[PATCH] D134175: [clang][Interp] Implement record instance functions and returning struct types

2022-09-27 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


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

https://reviews.llvm.org/D134175

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


[clang] 6b0b306 - Fix regression from Deferred Concepts with lambda in var init

2022-09-27 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2022-09-27T06:32:39-07:00
New Revision: 6b0b306e6221ba3f8f02944b8e5a8140f4d52324

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

LOG: Fix regression from Deferred Concepts with lambda in var init

As reported in GH #57945, this would crash because the decl context for
the lambda was being loaded via 'getNonClosureContext', which only gets
CODE contexts, so a global lambda was getting 'nullptr' here instead.
This patch does some work to make sure we get a valid/valuable
declcontext here instead.

Added: 
clang/test/SemaTemplate/concepts-lambda.cpp

Modified: 
clang/lib/Sema/SemaConcept.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index 7426b553fcfb8..6ad418599d368 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -529,9 +529,16 @@ bool Sema::CheckFunctionConstraints(const FunctionDecl *FD,
 return false;
   }
 
-  ContextRAII SavedContext{
-  *this, cast(
- const_cast(FD)->getNonClosureContext())};
+  DeclContext *CtxToSave = const_cast(FD);
+
+  while (isLambdaCallOperator(CtxToSave) || FD->isTransparentContext()) {
+if (isLambdaCallOperator(CtxToSave))
+  CtxToSave = CtxToSave->getParent()->getParent();
+else
+  CtxToSave = CtxToSave->getNonTransparentContext();
+  }
+
+  ContextRAII SavedContext{*this, CtxToSave};
   LocalInstantiationScope Scope(*this, !ForOverloadResolution ||
isLambdaCallOperator(FD));
   llvm::Optional MLTAL =

diff  --git a/clang/test/SemaTemplate/concepts-lambda.cpp 
b/clang/test/SemaTemplate/concepts-lambda.cpp
new file mode 100644
index 0..5309a6009893c
--- /dev/null
+++ b/clang/test/SemaTemplate/concepts-lambda.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -std=c++20 -verify %s
+// expected-no-diagnostics
+
+namespace GH57945 {
+  template
+concept c = true;
+
+  template
+auto f = []() requires c {
+};
+
+  void g() {
+  f();
+  };
+}



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


[PATCH] D134737: [pseudo][wip] Recovery for statements.

2022-09-27 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added a project: All.
hokein requested review of this revision.
Herald added a subscriber: alextsao1999.
Herald added a project: clang-tools-extra.

The main idea is to reuse the existing declaration recovery strategy --
extending it to cover some statement-specific bits.

Base on https://reviews.llvm.org/D130460


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134737

Files:
  clang-tools-extra/pseudo/lib/cxx/CXX.cpp
  clang-tools-extra/pseudo/lib/cxx/Recovery.cpp
  clang-tools-extra/pseudo/lib/cxx/cxx.bnf


Index: clang-tools-extra/pseudo/lib/cxx/cxx.bnf
===
--- clang-tools-extra/pseudo/lib/cxx/cxx.bnf
+++ clang-tools-extra/pseudo/lib/cxx/cxx.bnf
@@ -283,8 +283,8 @@
 labeled-statement := DEFAULT : statement
 expression-statement := expression_opt ;
 compound-statement := { statement-seq_opt [recover=Brackets] }
-statement-seq := statement
-statement-seq := statement-seq statement
+statement-seq := statement [recover=NextStatement]
+statement-seq := statement-seq statement [recover=NextStatement]
 selection-statement := IF CONSTEXPR_opt ( init-statement_opt condition ) 
statement [guard]
 selection-statement := IF CONSTEXPR_opt ( init-statement_opt condition ) 
statement ELSE statement
 selection-statement := SWITCH ( init-statement_opt condition ) statement
Index: clang-tools-extra/pseudo/lib/cxx/Recovery.cpp
===
--- clang-tools-extra/pseudo/lib/cxx/Recovery.cpp
+++ clang-tools-extra/pseudo/lib/cxx/Recovery.cpp
@@ -31,6 +31,11 @@
   auto ConsiderForBraces = [&](tok::TokenKind K) {
 if (K == tok::kw_export || K == tok::kw_extern || K == tok::kw_namespace)
   AcceptBraces = true;
+// Statements that don't end in semicolons:
+//   while/switch/if/for (...) {}
+if (K == tok::kw_for || K == tok::kw_while || K == tok::kw_if ||
+K == tok::kw_switch)
+  AcceptBraces = true;
   };
 
   // Some tokens are pretty good indicators of a declaration starting, when
@@ -71,6 +76,15 @@
 case tok::kw_public:
 case tok::kw_private:
 case tok::kw_protected:
+// Typical keywords for statements
+case tok::kw_for:
+case tok::kw_while:
+case tok::kw_if:
+case tok::kw_goto:
+case tok::kw_switch:
+case tok::kw_return:
+case tok::kw_break:
+case tok::kw_continue:
   return true;
 default:
   return false;
Index: clang-tools-extra/pseudo/lib/cxx/CXX.cpp
===
--- clang-tools-extra/pseudo/lib/cxx/CXX.cpp
+++ clang-tools-extra/pseudo/lib/cxx/CXX.cpp
@@ -427,6 +427,7 @@
   return {
   {Extension::Brackets, recoverBrackets},
   {Extension::NextDeclaration, recoverNextDeclaration},
+  {Extension::NextStatement, recoverNextDeclaration},
   };
 }
 


Index: clang-tools-extra/pseudo/lib/cxx/cxx.bnf
===
--- clang-tools-extra/pseudo/lib/cxx/cxx.bnf
+++ clang-tools-extra/pseudo/lib/cxx/cxx.bnf
@@ -283,8 +283,8 @@
 labeled-statement := DEFAULT : statement
 expression-statement := expression_opt ;
 compound-statement := { statement-seq_opt [recover=Brackets] }
-statement-seq := statement
-statement-seq := statement-seq statement
+statement-seq := statement [recover=NextStatement]
+statement-seq := statement-seq statement [recover=NextStatement]
 selection-statement := IF CONSTEXPR_opt ( init-statement_opt condition ) statement [guard]
 selection-statement := IF CONSTEXPR_opt ( init-statement_opt condition ) statement ELSE statement
 selection-statement := SWITCH ( init-statement_opt condition ) statement
Index: clang-tools-extra/pseudo/lib/cxx/Recovery.cpp
===
--- clang-tools-extra/pseudo/lib/cxx/Recovery.cpp
+++ clang-tools-extra/pseudo/lib/cxx/Recovery.cpp
@@ -31,6 +31,11 @@
   auto ConsiderForBraces = [&](tok::TokenKind K) {
 if (K == tok::kw_export || K == tok::kw_extern || K == tok::kw_namespace)
   AcceptBraces = true;
+// Statements that don't end in semicolons:
+//   while/switch/if/for (...) {}
+if (K == tok::kw_for || K == tok::kw_while || K == tok::kw_if ||
+K == tok::kw_switch)
+  AcceptBraces = true;
   };
 
   // Some tokens are pretty good indicators of a declaration starting, when
@@ -71,6 +76,15 @@
 case tok::kw_public:
 case tok::kw_private:
 case tok::kw_protected:
+// Typical keywords for statements
+case tok::kw_for:
+case tok::kw_while:
+case tok::kw_if:
+case tok::kw_goto:
+case tok::kw_switch:
+case tok::kw_return:
+case tok::kw_break:
+case tok::kw_continue:
   return true;
 default:
   return false;
Index: clang-tools-extra/pseudo/lib/cxx/CXX.cpp
===
--- clang-too

[PATCH] D134737: [pseudo][wip] Recovery for statements.

2022-09-27 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

it should demonstrate the main idea. I will do some more tweaks (rename etc), 
and add tests once we agree on the direction.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134737

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


[PATCH] D134660: [LinkerWrapper] Fix optimized debugging builds for NVPTX LTO

2022-09-27 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

Better than before. Thx


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134660

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


[PATCH] D134529: [C++20][Clang] P2468R2 The Equality Operator You Are Looking For

2022-09-27 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 463237.
usaxena95 added a comment.

Added better diagnostic for non-const symmetric operator==.
Added release notes.
Updated tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134529

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Overload.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CXX/over/over.match/over.match.funcs/over.match.oper/p3-2a.cpp

Index: clang/test/CXX/over/over.match/over.match.funcs/over.match.oper/p3-2a.cpp
===
--- clang/test/CXX/over/over.match/over.match.funcs/over.match.oper/p3-2a.cpp
+++ clang/test/CXX/over/over.match/over.match.funcs/over.match.oper/p3-2a.cpp
@@ -125,46 +125,124 @@
   bool b2 = 0 == ADL::type();
 }
 
-// Various C++17 cases that are known to be broken by the C++20 rules.
-namespace problem_cases {
-  // We can have an ambiguity between an operator and its reversed form. This
-  // wasn't intended by the original "consistent comparison" proposal, and we
-  // allow it as extension, picking the non-reversed form.
-  struct A {
-bool operator==(const A&); // expected-note {{ambiguity is between a regular call to this operator and a call with the argument order reversed}}
-  };
-  bool cmp_non_const = A() == A(); // expected-warning {{ambiguous}}
+namespace P2468R2 {
+//=Problem cases prior to P2468R2 but now intentionally rejected=
+struct SymmetricNonConst {
+  bool operator==(const SymmetricNonConst&); // expected-note {{ambiguity is between a regular call to this operator and a call with the argument order reversed}}
+  // expected-note@-1 {{mark operator== as const or add a matching operator!= to resolve the ambiguity}}
+};
+bool cmp_non_const = SymmetricNonConst() == SymmetricNonConst(); // expected-warning {{ambiguous}}
 
-  struct B {
-virtual bool operator==(const B&) const;
-  };
-  struct D : B {
-bool operator==(const B&) const override; // expected-note {{operator}}
-  };
-  bool cmp_base_derived = D() == D(); // expected-warning {{ambiguous}}
+struct SymmetricConst {
+  bool operator==(const SymmetricConst&) const;
+};
+bool cmp_const = SymmetricConst() == SymmetricConst();
 
-  template struct CRTPBase {
-bool operator==(const T&) const; // expected-note {{operator}} expected-note {{reversed}}
-bool operator!=(const T&) const; // expected-note {{non-reversed}}
-  };
-  struct CRTP : CRTPBase {};
-  bool cmp_crtp = CRTP() == CRTP(); // expected-warning-re {{ambiguous despite there being a unique best viable function{{$}}
-  bool cmp_crtp2 = CRTP() != CRTP(); // expected-warning {{ambiguous despite there being a unique best viable function with non-reversed arguments}}
-
-  // Given a choice between a rewritten and non-rewritten function with the
-  // same parameter types, where the rewritten function is reversed and each
-  // has a better conversion for one of the two arguments, prefer the
-  // non-rewritten one.
-  using UBool = signed char; // ICU uses this.
-  struct ICUBase {
-virtual UBool operator==(const ICUBase&) const;
-UBool operator!=(const ICUBase &arg) const { return !operator==(arg); }
-  };
-  struct ICUDerived : ICUBase {
-UBool operator==(const ICUBase&) const override; // expected-note {{declared here}} expected-note {{ambiguity is between}}
-  };
-  bool cmp_icu = ICUDerived() != ICUDerived(); // expected-warning {{ambiguous}} expected-warning {{'bool', not 'UBool'}}
+struct B {
+  virtual bool operator==(const B&) const;
+};
+struct D : B {
+  bool operator==(const B&) const override; // expected-note {{operator}}
+};
+bool cmp_base_derived = D() == D(); // expected-warning {{ambiguous}}
+
+// Reversed "3" not used because we find "2".
+// Rewrite != from "3" but warn that "chosen rewritten candidate must return cv-bool".
+using UBool = signed char;
+struct ICUBase {
+  virtual UBool operator==(const ICUBase&) const; // 1.
+  UBool operator!=(const ICUBase &arg) const { return !operator==(arg); } // 2.
+};
+struct ICUDerived : ICUBase {
+  // 3.
+  UBool operator==(const ICUBase&) const override; // expected-note {{declared here}}
+};
+bool cmp_icu = ICUDerived() != ICUDerived(); // expected-warning {{ISO C++20 requires return type of selected 'operator==' function for rewritten '!=' comparison to be 'bool', not 'UBool' (aka 'signed char')}}
+//=Accepted by P2468R2=
+// 1
+struct S {
+  bool operator==(const S&) { return true; }
+  bool operator!=(const S&) { return false; }
+};
+bool ts = S{} != S{};
+// 2
+template struct CRTPBase {
+  bool operator==(const T&) const;
+  bool operator!=(const T&) const;
+};
+struct CRTP : CRTPBase {};
+bool cmp_crtp = CRTP() == CRTP();
+bool cmp_crtp2 = CRTP() != CRTP();
+// https://github.com/llvm/llvm-project/issues/577

[PATCH] D133574: [C2x] reject type definitions in offsetof

2022-09-27 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance added a comment.

Diff 463063 looks good against the Linux kernel with 
https://lore.kernel.org/20220925153151.2467884-1...@inclyc.cn/ applied. I see 
no additional errors/warnings and the 
`drivers/media/platform/nvidia/tegra-vde/v4l2.c` did disappear. Once that patch 
has been fully chased and accepted, this change should be able to be merged 
without any problems. Thank you again for taking a look at the kernel ahead of 
time, it is very much appreciated!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133574

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


[PATCH] D134702: [Clang] Don't warn if deferencing void pointers in unevaluated context

2022-09-27 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance added a comment.

Thanks a lot for fixing this! I took it for a spin against the Linux kernel and 
all instances of `-Wvoid-ptr-dereference` disappeared :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134702

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


[PATCH] D134337: [clang] [Driver] More flexible rules for loading default configs (WIP)

2022-09-27 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

In D134337#3817878 , @mgorny wrote:

> Ok, how about this variant? I think it's the simplest I can come up with that 
> roughly matches the old behavior and adds what's necessary for the new.
>
> The algorithm is to use:
>
> 1. `-.cfg` if available, using the real ``,
> 2. `-.cfg` if available, using `` inferred from 
> executable name,
> 3. `.cfg` + `.cfg` if either is available, using the real 
> ``,
> 4. `.cfg` + `.cfg` if either is available, using the `` 
> inferred from executable.

This algorithm looks good. It is compatible with the existing algorithm if 
target is not overridden. In the case of overridden target behavior is 
different, but you a right, using `x86_64.cfg` in compilation for 32-bit target 
is not natural. Probably we should document the difference in 
`ReleaseNotes.rst`. Also documentation in `UserManual.rst` should be updated.


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

https://reviews.llvm.org/D134337

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


[PATCH] D134702: [Clang] Don't warn if deferencing void pointers in unevaluated context

2022-09-27 Thread Jun Zhang via Phabricator via cfe-commits
junaire added a comment.

In D134702#3818274 , @nathanchance 
wrote:

> Thanks a lot for fixing this! I took it for a spin against the Linux kernel 
> and all instances of `-Wvoid-ptr-dereference` disappeared :)

Awesome! Glad to hear this fixed your problem!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134702

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


[PATCH] D134744: [clang][Interp] Implement rem opcode

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

Something easier to review I hope :)

Implement an opcode to get the remainder of the divison between LHS and RHS.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134744

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/Integral.h
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/Opcodes.td
  clang/test/AST/Interp/literals.cpp

Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -145,3 +145,25 @@
 
 #endif
 };
+
+namespace rem {
+  static_assert(2 % 2 == 0, "");
+  static_assert(2 % 1 == 0, "");
+  static_assert(-3 % 4 == -3, "");
+  static_assert(4 % -2 == 0, "");
+  static_assert(-3 % -4 == -3, "");
+
+  constexpr int zero() { return 0; }
+  static_assert(10 % zero() == 20, ""); // ref-error {{not an integral constant expression}} \
+// ref-note {{division by zero}} \
+// expected-error {{not an integral constant expression}} \
+// expected-note {{division by zero}}
+
+
+  static_assert(true % true == 0, "");
+  static_assert(false % true == 0, "");
+  static_assert(true % false == 10, ""); // ref-error {{not an integral constant expression}} \
+ // ref-note {{division by zero}} \
+ // expected-error {{not an integral constant expression}} \
+ // expected-note {{division by zero}}
+};
Index: clang/lib/AST/Interp/Opcodes.td
===
--- clang/lib/AST/Interp/Opcodes.td
+++ clang/lib/AST/Interp/Opcodes.td
@@ -54,9 +54,13 @@
   list Types;
 }
 
-def AluTypeClass : TypeClass {
+def NumberTypeClass : TypeClass {
   let Types = [Sint8, Uint8, Sint16, Uint16, Sint32,
-   Uint32, Sint64, Uint64, Bool];
+   Uint32, Sint64, Uint64];
+}
+
+def AluTypeClass : TypeClass {
+  let Types = !listconcat(NumberTypeClass.Types, [Bool]);
 }
 
 def PtrTypeClass : TypeClass {
@@ -393,6 +397,10 @@
 def Sub : AluOpcode;
 def Add : AluOpcode;
 def Mul : AluOpcode;
+def Rem : Opcode {
+  let Types = [NumberTypeClass];
+  let HasGroup = 1;
+}
 
 
 //===--===//
Index: clang/lib/AST/Interp/Interp.h
===
--- clang/lib/AST/Interp/Interp.h
+++ clang/lib/AST/Interp/Interp.h
@@ -153,6 +153,26 @@
   return AddSubMulHelper(S, OpPC, Bits, LHS, RHS);
 }
 
+/// 1) Pops the RHS from the stack.
+/// 2) Pops the LHS from the stack.
+/// 3) Pushes 'LHS % RHS' on the stack (the remainder of dividing LHS by RHS).
+template ::T>
+bool Rem(InterpState &S, CodePtr OpPC) {
+  const T &RHS = S.Stk.pop();
+  const T &LHS = S.Stk.pop();
+
+  if (RHS.isZero()) {
+const SourceInfo &Loc = S.Current->getSource(OpPC);
+S.FFDiag(Loc, diag::note_expr_divide_by_zero);
+return false;
+  }
+  const unsigned Bits = RHS.bitWidth() * 2;
+  T Result;
+  T::rem(LHS, RHS, Bits, &Result);
+  S.Stk.push(Result);
+  return true;
+}
+
 //===--===//
 // Inv
 //===--===//
Index: clang/lib/AST/Interp/Integral.h
===
--- clang/lib/AST/Interp/Integral.h
+++ clang/lib/AST/Interp/Integral.h
@@ -210,6 +210,13 @@
 return CheckMulUB(A.V, B.V, R->V);
   }
 
+  static bool rem(Integral A, Integral B, unsigned OpBits, Integral *R) {
+if (B.V == 0)
+  return true;
+*R = Integral(A.V % B.V);
+return false;
+  }
+
   static bool neg(Integral A, Integral *R) {
 *R = -A;
 return false;
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -211,6 +211,8 @@
   return Discard(this->emitAdd(*T, BO));
 case BO_Mul:
   return Discard(this->emitMul(*T, BO));
+case BO_Rem:
+  return Discard(this->emitRem(*T, BO));
 case BO_Assign:
   if (!this->emitStore(*T, BO))
 return false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D134744: [clang][Interp] Implement rem opcode

2022-09-27 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 463245.

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

https://reviews.llvm.org/D134744

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/Integral.h
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/Opcodes.td
  clang/test/AST/Interp/literals.cpp

Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -145,3 +145,25 @@
 
 #endif
 };
+
+namespace rem {
+  static_assert(2 % 2 == 0, "");
+  static_assert(2 % 1 == 0, "");
+  static_assert(-3 % 4 == -3, "");
+  static_assert(4 % -2 == 0, "");
+  static_assert(-3 % -4 == -3, "");
+
+  constexpr int zero() { return 0; }
+  static_assert(10 % zero() == 20, ""); // ref-error {{not an integral constant expression}} \
+// ref-note {{division by zero}} \
+// expected-error {{not an integral constant expression}} \
+// expected-note {{division by zero}}
+
+
+  static_assert(true % true == 0, "");
+  static_assert(false % true == 0, "");
+  static_assert(true % false == 10, ""); // ref-error {{not an integral constant expression}} \
+ // ref-note {{division by zero}} \
+ // expected-error {{not an integral constant expression}} \
+ // expected-note {{division by zero}}
+};
Index: clang/lib/AST/Interp/Opcodes.td
===
--- clang/lib/AST/Interp/Opcodes.td
+++ clang/lib/AST/Interp/Opcodes.td
@@ -54,9 +54,13 @@
   list Types;
 }
 
-def AluTypeClass : TypeClass {
+def NumberTypeClass : TypeClass {
   let Types = [Sint8, Uint8, Sint16, Uint16, Sint32,
-   Uint32, Sint64, Uint64, Bool];
+   Uint32, Sint64, Uint64];
+}
+
+def AluTypeClass : TypeClass {
+  let Types = !listconcat(NumberTypeClass.Types, [Bool]);
 }
 
 def PtrTypeClass : TypeClass {
@@ -393,6 +397,10 @@
 def Sub : AluOpcode;
 def Add : AluOpcode;
 def Mul : AluOpcode;
+def Rem : Opcode {
+  let Types = [NumberTypeClass];
+  let HasGroup = 1;
+}
 
 
 //===--===//
Index: clang/lib/AST/Interp/Interp.h
===
--- clang/lib/AST/Interp/Interp.h
+++ clang/lib/AST/Interp/Interp.h
@@ -153,6 +153,26 @@
   return AddSubMulHelper(S, OpPC, Bits, LHS, RHS);
 }
 
+/// 1) Pops the RHS from the stack.
+/// 2) Pops the LHS from the stack.
+/// 3) Pushes 'LHS % RHS' on the stack (the remainder of dividing LHS by RHS).
+template ::T>
+bool Rem(InterpState &S, CodePtr OpPC) {
+  const T &RHS = S.Stk.pop();
+  const T &LHS = S.Stk.pop();
+
+  if (RHS.isZero()) {
+const SourceInfo &Loc = S.Current->getSource(OpPC);
+S.FFDiag(Loc, diag::note_expr_divide_by_zero);
+return false;
+  }
+  const unsigned Bits = RHS.bitWidth() * 2;
+  T Result;
+  T::rem(LHS, RHS, Bits, &Result);
+  S.Stk.push(Result);
+  return true;
+}
+
 //===--===//
 // Inv
 //===--===//
Index: clang/lib/AST/Interp/Integral.h
===
--- clang/lib/AST/Interp/Integral.h
+++ clang/lib/AST/Interp/Integral.h
@@ -210,6 +210,11 @@
 return CheckMulUB(A.V, B.V, R->V);
   }
 
+  static bool rem(Integral A, Integral B, unsigned OpBits, Integral *R) {
+*R = Integral(A.V % B.V);
+return false;
+  }
+
   static bool neg(Integral A, Integral *R) {
 *R = -A;
 return false;
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -211,6 +211,8 @@
   return Discard(this->emitAdd(*T, BO));
 case BO_Mul:
   return Discard(this->emitMul(*T, BO));
+case BO_Rem:
+  return Discard(this->emitRem(*T, BO));
 case BO_Assign:
   if (!this->emitStore(*T, BO))
 return false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D134745: [LV][Metadata] Add loop.interleave.enable for loop vectorizer

2022-09-27 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD created this revision.
eopXD added reviewers: sdesmalen, paulwalker-arm, fhahn, reames, hfinkel.
Herald added subscribers: frasercrmck, luismarques, apazos, sameer.abuasal, 
s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, 
edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, 
asb, hiraditya.
Herald added a project: All.
eopXD requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, pcwang-thead, MaskRay.
Herald added projects: clang, LLVM.

Adding this metadata allows {loop.vectorize.enable, false} to be used
without disabling the whole pass.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134745

Files:
  clang/lib/CodeGen/CGLoopInfo.cpp
  clang/lib/CodeGen/CGLoopInfo.h
  clang/test/CodeGenCXX/pragma-loop-predicate.cpp
  clang/test/CodeGenCXX/pragma-loop-safety.cpp
  clang/test/CodeGenCXX/pragma-loop.cpp
  llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h
  llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  
llvm/test/Transforms/LoopVectorize/AArch64/outer_loop_test1_no_explicit_vect_width.ll
  llvm/test/Transforms/LoopVectorize/RISCV/force-vect-msg.ll
  llvm/test/Transforms/LoopVectorize/RISCV/riscv-vector-reverse.ll
  llvm/test/Transforms/LoopVectorize/X86/metadata-enable.ll
  
llvm/test/Transforms/LoopVectorize/X86/outer_loop_test1_no_explicit_vect_width.ll
  llvm/test/Transforms/LoopVectorize/X86/vect.omp.force.ll
  llvm/test/Transforms/LoopVectorize/X86/vectorization-remarks-missed.ll
  llvm/test/Transforms/LoopVectorize/explicit_outer_detection.ll
  llvm/test/Transforms/LoopVectorize/explicit_outer_nonuniform_inner.ll
  llvm/test/Transforms/LoopVectorize/explicit_outer_uniform_diverg_branch.ll
  llvm/test/Transforms/LoopVectorize/no_switch.ll
  llvm/test/Transforms/LoopVectorize/no_switch_disable_vectorization.ll
  llvm/test/Transforms/LoopVectorize/nounroll.ll
  llvm/test/Transforms/LoopVectorize/optsize.ll
  llvm/test/Transforms/LoopVectorize/outer-loop-vec-phi-predecessor-order.ll
  llvm/test/Transforms/LoopVectorize/outer_loop_test1.ll
  llvm/test/Transforms/LoopVectorize/outer_loop_test2.ll
  llvm/test/Transforms/LoopVectorize/vect.omp.persistence.ll
  llvm/test/Transforms/LoopVectorize/vplan-outer-loop-uncomputable-trip-count.ll
  llvm/test/Transforms/LoopVectorize/vplan-printing-outer-loop.ll
  llvm/test/Transforms/LoopVectorize/vplan-vectorize-inner-loop-reduction.ll
  llvm/test/Transforms/LoopVectorize/vplan-widen-call-instruction.ll
  llvm/test/Transforms/LoopVectorize/vplan-widen-select-instruction.ll

Index: llvm/test/Transforms/LoopVectorize/vplan-widen-select-instruction.ll
===
--- llvm/test/Transforms/LoopVectorize/vplan-widen-select-instruction.ll
+++ llvm/test/Transforms/LoopVectorize/vplan-widen-select-instruction.ll
@@ -196,5 +196,6 @@
 exit:
   ret void
 }
-!0 = distinct !{!0, !1}
+!0 = distinct !{!0, !1, !2}
 !1 = !{!"llvm.loop.vectorize.enable", i1 true}
+!2 = !{!"llvm.loop.interleave.enable", i1 false}
Index: llvm/test/Transforms/LoopVectorize/vplan-widen-call-instruction.ll
===
--- llvm/test/Transforms/LoopVectorize/vplan-widen-call-instruction.ll
+++ llvm/test/Transforms/LoopVectorize/vplan-widen-call-instruction.ll
@@ -68,5 +68,6 @@
   ret void
 }
 
-!0 = distinct !{!0, !1}
+!0 = distinct !{!0, !1, !2}
 !1 = !{!"llvm.loop.vectorize.enable", i1 true}
+!2 = !{!"llvm.loop.interleave.enable", i1 false}
Index: llvm/test/Transforms/LoopVectorize/vplan-vectorize-inner-loop-reduction.ll
===
--- llvm/test/Transforms/LoopVectorize/vplan-vectorize-inner-loop-reduction.ll
+++ llvm/test/Transforms/LoopVectorize/vplan-vectorize-inner-loop-reduction.ll
@@ -77,5 +77,6 @@
   ret void
 }
 
-!0 = distinct !{!0, !1}
+!0 = distinct !{!0, !1, !2}
 !1 = !{!"llvm.loop.vectorize.enable", i1 true}
+!2 = !{!"llvm.loop.interleave.enable", i1 false}
Index: llvm/test/Transforms/LoopVectorize/vplan-printing-outer-loop.ll
===
--- llvm/test/Transforms/LoopVectorize/vplan-printing-outer-loop.ll
+++ llvm/test/Transforms/LoopVectorize/vplan-printing-outer-loop.ll
@@ -69,6 +69,7 @@
   ret void
 }
 
-!1 = distinct !{!1, !2, !3}
+!1 = distinct !{!1, !2, !3, !4}
 !2 = !{!"llvm.loop.vectorize.width", i32 4}
 !3 = !{!"llvm.loop.vectorize.enable", i1 true}
+!4 = !{!"llvm.loop.interleave.enable", i1 false}
Index: llvm/test/Transforms/LoopVectorize/vplan-outer-loop-uncomputable-trip-count.ll
===
--- llvm/test/Transforms/LoopVectorize/vplan-outer-loop-uncomputable-trip-count.ll
+++ llvm/test/Transforms/LoopVectorize/vplan-outer-loop-uncomputable-trip-count.ll
@@ -43,5 +43,6 @@
   ret void
 }
 
-!0 = distinct !{!0, !1}
+!0 = 

[PATCH] D134745: [LV][Metadata] Add loop.interleave.enable for loop vectorizer

2022-09-27 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD added a comment.

Please feel free to add appropriate reviewer to this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134745

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


[clang] f50a7c7 - [LinkerWrapper] Fix optimized debugging builds for NVPTX LTO

2022-09-27 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2022-09-27T10:49:17-05:00
New Revision: f50a7c7a26e074231cc9a60a3fcaef7520ceb67f

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

LOG: [LinkerWrapper] Fix optimized debugging builds for NVPTX LTO

The ptxas assembler does not allow the `-g` flag along with
optimizations. Normally this is degraded to line info in the driver, but
when using LTO we did not have this step and the linker wrapper was not
correctly degrading the option. Note that this will not work if the user
does not pass `-g` again to the linker invocation. That will require
setting some flags in the binary to indicate that debugging was used
when building.

This fixes #57990

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/test/Driver/linker-wrapper.c
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Removed: 




diff  --git a/clang/test/Driver/linker-wrapper.c 
b/clang/test/Driver/linker-wrapper.c
index dd0fba763cd46..e8c127501e26e 100644
--- a/clang/test/Driver/linker-wrapper.c
+++ b/clang/test/Driver/linker-wrapper.c
@@ -24,10 +24,19 @@
 // RUN:   
--image=file=%S/Inputs/dummy-elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70
 \
 // RUN:   
--image=file=%S/Inputs/dummy-elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70
 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o 
-fembed-offload-object=%t.out
-// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run 
--device-debug \
-// RUN:   --linker-path=/usr/bin/ld -- %t.o -o a.out 2>&1 | FileCheck %s 
--check-prefix=NVPTX_LINK_DEBUG
+// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run 
--device-debug -O0 \
+// RUN:   --linker-path=/usr/bin/ld -- %t.o -o a.out 2>&1 | FileCheck %s 
--check-prefix=NVPTX-LINK-DEBUG
 
-// NVPTX_LINK_DEBUG: nvlink{{.*}}-m64 -g -o {{.*}}.out -arch sm_70 {{.*}}.o 
{{.*}}.o
+// NVPTX-LINK-DEBUG: nvlink{{.*}}-m64 -g -o {{.*}}.out -arch sm_70 {{.*}}.o 
{{.*}}.o
+
+// RUN: clang-offload-packager -o %t.out \
+// RUN:   
--image=file=%S/Inputs/dummy-bc.bc,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70
 \
+// RUN:   
--image=file=%S/Inputs/dummy-bc.bc,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70
+// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o 
-fembed-offload-object=%t.out
+// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run 
--device-debug -O2 \
+// RUN:   --linker-path=/usr/bin/ld -- %t.o -o a.out 2>&1 | FileCheck %s 
--check-prefix=NVPTX-LINK-DEBUG-LTO
+
+// NVPTX-LINK-DEBUG-LTO: ptxas{{.*}}-m64 -o {{.*}}.cubin -O2 --gpu-name sm_70 
-lineinfo {{.*}}.s
 
 // RUN: clang-offload-packager -o %t.out \
 // RUN:   
--image=file=%S/Inputs/dummy-elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908
 \

diff  --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp 
b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index d29c4f93d60f7..40825ac831a50 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -295,8 +295,10 @@ Expected assemble(StringRef InputFile, const 
ArgList &Args,
   CmdArgs.push_back(Args.MakeArgString("-" + OptLevel));
   CmdArgs.push_back("--gpu-name");
   CmdArgs.push_back(Arch);
-  if (Args.hasArg(OPT_debug))
+  if (Args.hasArg(OPT_debug) && OptLevel[1] == '0')
 CmdArgs.push_back("-g");
+  else if (Args.hasArg(OPT_debug))
+CmdArgs.push_back("-lineinfo");
   if (RDC)
 CmdArgs.push_back("-c");
 



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


[PATCH] D134660: [LinkerWrapper] Fix optimized debugging builds for NVPTX LTO

2022-09-27 Thread Joseph Huber via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf50a7c7a26e0: [LinkerWrapper] Fix optimized debugging builds 
for NVPTX LTO (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134660

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


Index: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
===
--- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -295,8 +295,10 @@
   CmdArgs.push_back(Args.MakeArgString("-" + OptLevel));
   CmdArgs.push_back("--gpu-name");
   CmdArgs.push_back(Arch);
-  if (Args.hasArg(OPT_debug))
+  if (Args.hasArg(OPT_debug) && OptLevel[1] == '0')
 CmdArgs.push_back("-g");
+  else if (Args.hasArg(OPT_debug))
+CmdArgs.push_back("-lineinfo");
   if (RDC)
 CmdArgs.push_back("-c");
 
Index: clang/test/Driver/linker-wrapper.c
===
--- clang/test/Driver/linker-wrapper.c
+++ clang/test/Driver/linker-wrapper.c
@@ -24,10 +24,19 @@
 // RUN:   
--image=file=%S/Inputs/dummy-elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70
 \
 // RUN:   
--image=file=%S/Inputs/dummy-elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70
 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o 
-fembed-offload-object=%t.out
-// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run 
--device-debug \
-// RUN:   --linker-path=/usr/bin/ld -- %t.o -o a.out 2>&1 | FileCheck %s 
--check-prefix=NVPTX_LINK_DEBUG
+// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run 
--device-debug -O0 \
+// RUN:   --linker-path=/usr/bin/ld -- %t.o -o a.out 2>&1 | FileCheck %s 
--check-prefix=NVPTX-LINK-DEBUG
 
-// NVPTX_LINK_DEBUG: nvlink{{.*}}-m64 -g -o {{.*}}.out -arch sm_70 {{.*}}.o 
{{.*}}.o
+// NVPTX-LINK-DEBUG: nvlink{{.*}}-m64 -g -o {{.*}}.out -arch sm_70 {{.*}}.o 
{{.*}}.o
+
+// RUN: clang-offload-packager -o %t.out \
+// RUN:   
--image=file=%S/Inputs/dummy-bc.bc,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70
 \
+// RUN:   
--image=file=%S/Inputs/dummy-bc.bc,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70
+// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o 
-fembed-offload-object=%t.out
+// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run 
--device-debug -O2 \
+// RUN:   --linker-path=/usr/bin/ld -- %t.o -o a.out 2>&1 | FileCheck %s 
--check-prefix=NVPTX-LINK-DEBUG-LTO
+
+// NVPTX-LINK-DEBUG-LTO: ptxas{{.*}}-m64 -o {{.*}}.cubin -O2 --gpu-name sm_70 
-lineinfo {{.*}}.s
 
 // RUN: clang-offload-packager -o %t.out \
 // RUN:   
--image=file=%S/Inputs/dummy-elf.o,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908
 \


Index: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
===
--- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -295,8 +295,10 @@
   CmdArgs.push_back(Args.MakeArgString("-" + OptLevel));
   CmdArgs.push_back("--gpu-name");
   CmdArgs.push_back(Arch);
-  if (Args.hasArg(OPT_debug))
+  if (Args.hasArg(OPT_debug) && OptLevel[1] == '0')
 CmdArgs.push_back("-g");
+  else if (Args.hasArg(OPT_debug))
+CmdArgs.push_back("-lineinfo");
   if (RDC)
 CmdArgs.push_back("-c");
 
Index: clang/test/Driver/linker-wrapper.c
===
--- clang/test/Driver/linker-wrapper.c
+++ clang/test/Driver/linker-wrapper.c
@@ -24,10 +24,19 @@
 // RUN:   --image=file=%S/Inputs/dummy-elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 \
 // RUN:   --image=file=%S/Inputs/dummy-elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70
 // RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o -fembed-offload-object=%t.out
-// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run --device-debug \
-// RUN:   --linker-path=/usr/bin/ld -- %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=NVPTX_LINK_DEBUG
+// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run --device-debug -O0 \
+// RUN:   --linker-path=/usr/bin/ld -- %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=NVPTX-LINK-DEBUG
 
-// NVPTX_LINK_DEBUG: nvlink{{.*}}-m64 -g -o {{.*}}.out -arch sm_70 {{.*}}.o {{.*}}.o
+// NVPTX-LINK-DEBUG: nvlink{{.*}}-m64 -g -o {{.*}}.out -arch sm_70 {{.*}}.o {{.*}}.o
+
+// RUN: clang-offload-packager -o %t.out \
+// RUN:   --image=file=%S/Inputs/dummy-bc.bc,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70 \
+// RUN:   --image=file=%S/Inputs/dummy-bc.bc,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70
+// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o 

[PATCH] D134744: [clang][Interp] Implement rem opcode

2022-09-27 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/AST/Interp/Integral.h:213
 
+  static bool rem(Integral A, Integral B, unsigned OpBits, Integral *R) {
+*R = Integral(A.V % B.V);

Its a touch weird we return 'bool' in all these places, rather than an 
`Optional`, right?  Perhaps a refactor idea for a future patch.



Comment at: clang/lib/AST/Interp/Interp.h:171
+  T Result;
+  T::rem(LHS, RHS, Bits, &Result);
+  S.Stk.push(Result);

I get that we 'know' that rem doesn't have an error case, but it seems like a 
mistake to not check the return value... Perhaps an even better reason to use 
optional.



Comment at: clang/lib/AST/Interp/Opcodes.td:57
 
-def AluTypeClass : TypeClass {
+def NumberTypeClass : TypeClass {
   let Types = [Sint8, Uint8, Sint16, Uint16, Sint32,

Perhaps `IntegralTypeClass`, unless we expect floats to be here too?



Comment at: clang/lib/AST/Interp/Opcodes.td:62
+
+def AluTypeClass : TypeClass {
+  let Types = !listconcat(NumberTypeClass.Types, [Bool]);

What does "Alu" mean here?


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

https://reviews.llvm.org/D134744

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


[PATCH] D134337: [clang] [Driver] More flexible rules for loading default configs (WIP)

2022-09-27 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Thanks. Since the algorithm's good, I'll work on updating the docs and tests.


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

https://reviews.llvm.org/D134337

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


[PATCH] D134744: [clang][Interp] Implement rem opcode

2022-09-27 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 463251.

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

https://reviews.llvm.org/D134744

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/Integral.h
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/Opcodes.td
  clang/test/AST/Interp/literals.cpp

Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -145,3 +145,25 @@
 
 #endif
 };
+
+namespace rem {
+  static_assert(2 % 2 == 0, "");
+  static_assert(2 % 1 == 0, "");
+  static_assert(-3 % 4 == -3, "");
+  static_assert(4 % -2 == 0, "");
+  static_assert(-3 % -4 == -3, "");
+
+  constexpr int zero() { return 0; }
+  static_assert(10 % zero() == 20, ""); // ref-error {{not an integral constant expression}} \
+// ref-note {{division by zero}} \
+// expected-error {{not an integral constant expression}} \
+// expected-note {{division by zero}}
+
+
+  static_assert(true % true == 0, "");
+  static_assert(false % true == 0, "");
+  static_assert(true % false == 10, ""); // ref-error {{not an integral constant expression}} \
+ // ref-note {{division by zero}} \
+ // expected-error {{not an integral constant expression}} \
+ // expected-note {{division by zero}}
+};
Index: clang/lib/AST/Interp/Opcodes.td
===
--- clang/lib/AST/Interp/Opcodes.td
+++ clang/lib/AST/Interp/Opcodes.td
@@ -54,9 +54,13 @@
   list Types;
 }
 
-def AluTypeClass : TypeClass {
+def NumberTypeClass : TypeClass {
   let Types = [Sint8, Uint8, Sint16, Uint16, Sint32,
-   Uint32, Sint64, Uint64, Bool];
+   Uint32, Sint64, Uint64];
+}
+
+def AluTypeClass : TypeClass {
+  let Types = !listconcat(NumberTypeClass.Types, [Bool]);
 }
 
 def PtrTypeClass : TypeClass {
@@ -393,6 +397,10 @@
 def Sub : AluOpcode;
 def Add : AluOpcode;
 def Mul : AluOpcode;
+def Rem : Opcode {
+  let Types = [NumberTypeClass];
+  let HasGroup = 1;
+}
 
 
 //===--===//
Index: clang/lib/AST/Interp/Interp.h
===
--- clang/lib/AST/Interp/Interp.h
+++ clang/lib/AST/Interp/Interp.h
@@ -153,6 +153,28 @@
   return AddSubMulHelper(S, OpPC, Bits, LHS, RHS);
 }
 
+/// 1) Pops the RHS from the stack.
+/// 2) Pops the LHS from the stack.
+/// 3) Pushes 'LHS % RHS' on the stack (the remainder of dividing LHS by RHS).
+template ::T>
+bool Rem(InterpState &S, CodePtr OpPC) {
+  const T &RHS = S.Stk.pop();
+  const T &LHS = S.Stk.pop();
+
+  if (RHS.isZero()) {
+const SourceInfo &Loc = S.Current->getSource(OpPC);
+S.FFDiag(Loc, diag::note_expr_divide_by_zero);
+return false;
+  }
+  const unsigned Bits = RHS.bitWidth() * 2;
+  T Result;
+  if (!T::rem(LHS, RHS, Bits, &Result)) {
+S.Stk.push(Result);
+return true;
+  }
+  return false;
+}
+
 //===--===//
 // Inv
 //===--===//
Index: clang/lib/AST/Interp/Integral.h
===
--- clang/lib/AST/Interp/Integral.h
+++ clang/lib/AST/Interp/Integral.h
@@ -210,6 +210,11 @@
 return CheckMulUB(A.V, B.V, R->V);
   }
 
+  static bool rem(Integral A, Integral B, unsigned OpBits, Integral *R) {
+*R = Integral(A.V % B.V);
+return false;
+  }
+
   static bool neg(Integral A, Integral *R) {
 *R = -A;
 return false;
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -211,6 +211,8 @@
   return Discard(this->emitAdd(*T, BO));
 case BO_Mul:
   return Discard(this->emitMul(*T, BO));
+case BO_Rem:
+  return Discard(this->emitRem(*T, BO));
 case BO_Assign:
   if (!this->emitStore(*T, BO))
 return false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D134744: [clang][Interp] Implement rem opcode

2022-09-27 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added inline comments.



Comment at: clang/lib/AST/Interp/Integral.h:213
 
+  static bool rem(Integral A, Integral B, unsigned OpBits, Integral *R) {
+*R = Integral(A.V % B.V);

erichkeane wrote:
> Its a touch weird we return 'bool' in all these places, rather than an 
> `Optional`, right?  Perhaps a refactor idea for a future patch.
The really weird part is that `false` here suddenly means success, but I get 
your point. Does using `Optional` introduce any sort of performance penalty if 
this is being called a lot?



Comment at: clang/lib/AST/Interp/Opcodes.td:57
 
-def AluTypeClass : TypeClass {
+def NumberTypeClass : TypeClass {
   let Types = [Sint8, Uint8, Sint16, Uint16, Sint32,

erichkeane wrote:
> Perhaps `IntegralTypeClass`, unless we expect floats to be here too?
Floats don't have to be in there I guess, but so far I'd say yes, they should 
be, because they are usable everywhere this class is used, afaik.



Comment at: clang/lib/AST/Interp/Opcodes.td:62
+
+def AluTypeClass : TypeClass {
+  let Types = !listconcat(NumberTypeClass.Types, [Bool]);

erichkeane wrote:
> What does "Alu" mean here?
I didn't introduce the name but I assumed it comes from "arithmetic logical 
unit".


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

https://reviews.llvm.org/D134744

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


[PATCH] D134744: [clang][Interp] Implement rem opcode

2022-09-27 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/AST/Interp/Integral.h:213
 
+  static bool rem(Integral A, Integral B, unsigned OpBits, Integral *R) {
+*R = Integral(A.V % B.V);

tbaeder wrote:
> erichkeane wrote:
> > Its a touch weird we return 'bool' in all these places, rather than an 
> > `Optional`, right?  Perhaps a refactor idea for a future patch.
> The really weird part is that `false` here suddenly means success, but I get 
> your point. Does using `Optional` introduce any sort of performance penalty 
> if this is being called a lot?
'false' as success is actually pretty common in clang, we use that all over the 
place. I don't believe Optional would have any negative penalty, at least 
compared to a pointer-param?



Comment at: clang/lib/AST/Interp/Opcodes.td:57
 
-def AluTypeClass : TypeClass {
+def NumberTypeClass : TypeClass {
   let Types = [Sint8, Uint8, Sint16, Uint16, Sint32,

tbaeder wrote:
> erichkeane wrote:
> > Perhaps `IntegralTypeClass`, unless we expect floats to be here too?
> Floats don't have to be in there I guess, but so far I'd say yes, they should 
> be, because they are usable everywhere this class is used, afaik.
Ok then, thanks.



Comment at: clang/lib/AST/Interp/Opcodes.td:62
+
+def AluTypeClass : TypeClass {
+  let Types = !listconcat(NumberTypeClass.Types, [Bool]);

tbaeder wrote:
> erichkeane wrote:
> > What does "Alu" mean here?
> I didn't introduce the name but I assumed it comes from "arithmetic logical 
> unit".
Ah! That could be.  Makes sense.


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

https://reviews.llvm.org/D134744

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


[PATCH] D134529: [C++20][Clang] P2468R2 The Equality Operator You Are Looking For

2022-09-27 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

A few ideas for tests:

- Static operators. Technically disallowed by the standard, but Clang seems to 
recover without dropping the member, so it seems we can actually look it up.

  struct X { 
bool operator ==(X const&) const;
static bool operator !=(X const&, X const&);
  };

this could potentially lead to a crash if the parameter list for the operator 
is empty:

  struct X { 
bool operator ==(X const&) const;
static bool operator !=();
  };



- template functions with non-matching template heads (so they don't 
"correspond")

  bool operator ==(X, X);




Comment at: clang/include/clang/Sema/Sema.h:3768
   NamedDecl *Dest = nullptr);
-
+  // bool HasSameExclaimEqual(const FunctionDecl *FD, SourceLocation OpLoc,
+  //  Expr *RHSArg);

This looks like a leftover from previous version. Remove?



Comment at: clang/lib/Sema/SemaOverload.cpp:887
 
-bool OverloadCandidateSet::OperatorRewriteInfo::shouldAddReversed(
-OverloadedOperatorKind Op) {

Why do we need to move this from `OperatorRewriteInfo` to 
`OverloadCandidateSet`?




Comment at: clang/lib/Sema/SemaOverload.cpp:892
+static bool shouldAddReversedEqEq(Sema &S, SourceLocation OpLoc,
+  ArrayRef Args,
+  const FunctionDecl *EqEqFD) {

We only use `Args[1]`, let's pass `Expr*` instead of an array.
The standard calls this expression "first operand", so let's sync the naming 
and accept the `Expr *FirstOperand`?



Comment at: clang/lib/Sema/SemaOverload.cpp:893
+  ArrayRef Args,
+  const FunctionDecl *EqEqFD) {
+  assert(EqEqFD->getOverloadedOperator() ==

NIT: maybe rename to `EqFD`?
`EqEqFD` is somewhat hard to grasp and I don't think there any possibility for 
confusion with assignment here.



Comment at: clang/lib/Sema/SemaOverload.cpp:912
+QualType RHS = Args[1]->getType();
+if (auto *RHSRec = RHS->getAs()) {
+  LookupResult Members(S, NotEqOp, OpLoc,

NIT:  use [early 
exits](https://llvm.org/docs/CodingStandards.html#use-early-exits-and-continue-to-simplify-code):
```
auto *RHSRec = RHS->getAs();
if (!RHSRec)
  return true;
// 
```



Comment at: clang/lib/Sema/SemaOverload.cpp:918
+  for (NamedDecl *Op : Members)
+if (S.Context.hasSameUnqualifiedType(
+MD->getParamDecl(0)->getType(),

Could we implement the "corresponds" check from 
[(basic.scope.scope)p4](https://eel.is/c++draft/basic.scope.scope) directly?

This should address the existing FIXMEs about `const` members and template 
functions.



Comment at: 
clang/test/CXX/over/over.match/over.match.funcs/over.match.oper/p3-2a.cpp:141
+namespace P2468R2 {
+//=Problem cases prior to P2468R2 but now intentionally 
rejected=
+namespace no_more_problem_cases {

NIT: the rest of the file uses plain comments. Maybe stick to existing style 
and avoid heading padded with `=`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134529

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


[PATCH] D134744: [clang][Interp] Implement rem opcode

2022-09-27 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder marked 7 inline comments as done.
tbaeder added inline comments.



Comment at: clang/lib/AST/Interp/Integral.h:213
 
+  static bool rem(Integral A, Integral B, unsigned OpBits, Integral *R) {
+*R = Integral(A.V % B.V);

erichkeane wrote:
> tbaeder wrote:
> > erichkeane wrote:
> > > Its a touch weird we return 'bool' in all these places, rather than an 
> > > `Optional`, right?  Perhaps a refactor idea for a future patch.
> > The really weird part is that `false` here suddenly means success, but I 
> > get your point. Does using `Optional` introduce any sort of performance 
> > penalty if this is being called a lot?
> 'false' as success is actually pretty common in clang, we use that all over 
> the place. I don't believe Optional would have any negative penalty, at least 
> compared to a pointer-param?
Yeah I know it's being used elsewhere in the codebase like this, but the all 
the AST visitors in the interpreter code return `false` for failure, so this is 
kinda confusing to me.

I'll note the refactoring for later.


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

https://reviews.llvm.org/D134744

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


[PATCH] D86049: RFC: Implement optional exportable wrapper function generation for objc_direct methods.

2022-09-27 Thread Michael Wyman via Phabricator via cfe-commits
mwyman added a comment.

In D86049#3816006 , @plotfi wrote:

> @dmaclach @ahatanak @mwyman How do things look from here? Do you want 
> something for properties as well or would it be ok if we did this in a later 
> commit?

Huh, for some reason I thought when I'd last poked at using the `visibility` 
attribute it wasn't allowed on ObjC methods, which is why I'd suggested adding 
the enum on `objc_direct`, but as that no longer appears to be the case yes I 
like this approach better.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86049

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


[PATCH] D134749: [clang][Interp] Implement Div opcode

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

Same as the `rem` patch basically.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134749

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/Integral.h
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/Opcodes.td
  clang/test/AST/Interp/literals.cpp


Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -167,3 +167,19 @@
  // expected-error {{not an integral 
constant expression}} \
  // expected-note {{division by zero}}
 };
+
+namespace div {
+  constexpr int zero() { return 0; }
+  static_assert(12 / 3 == 4, "");
+  static_assert(12 / 0 == 12, ""); // ref-error {{not an integral constant 
expression}} \
+   // ref-note {{division by zero}} \
+   // expected-error {{not an integral 
constant expression}} \
+   // expected-note {{division by zero}}
+  static_assert(12 / -3 == -4, "");
+  static_assert(-12 / 3 == -4, "");
+
+
+  constexpr int LHS = 12;
+  constexpr long unsigned RHS = 3;
+  static_assert(LHS / RHS == 4, "");
+};
Index: clang/lib/AST/Interp/Opcodes.td
===
--- clang/lib/AST/Interp/Opcodes.td
+++ clang/lib/AST/Interp/Opcodes.td
@@ -401,7 +401,10 @@
   let Types = [NumberTypeClass];
   let HasGroup = 1;
 }
-
+def Div : Opcode {
+  let Types = [NumberTypeClass];
+  let HasGroup = 1;
+}
 
 
//===--===//
 // Unary operators.
Index: clang/lib/AST/Interp/Interp.h
===
--- clang/lib/AST/Interp/Interp.h
+++ clang/lib/AST/Interp/Interp.h
@@ -175,6 +175,25 @@
   return false;
 }
 
+template ::T>
+bool Div(InterpState &S, CodePtr OpPC) {
+  const T &RHS = S.Stk.pop();
+  const T &LHS = S.Stk.pop();
+
+  if (RHS.isZero()) {
+const SourceInfo &Loc = S.Current->getSource(OpPC);
+S.FFDiag(Loc, diag::note_expr_divide_by_zero);
+return false;
+  }
+  const unsigned Bits = RHS.bitWidth() * 2;
+  T Result;
+  if (!T::div(LHS, RHS, Bits, &Result)) {
+S.Stk.push(Result);
+return true;
+  }
+  return false;
+}
+
 
//===--===//
 // Inv
 
//===--===//
Index: clang/lib/AST/Interp/Integral.h
===
--- clang/lib/AST/Interp/Integral.h
+++ clang/lib/AST/Interp/Integral.h
@@ -215,6 +215,11 @@
 return false;
   }
 
+  static bool div(Integral A, Integral B, unsigned OpBits, Integral *R) {
+*R = Integral(A.V / B.V);
+return false;
+  }
+
   static bool neg(Integral A, Integral *R) {
 *R = -A;
 return false;
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -213,6 +213,8 @@
   return Discard(this->emitMul(*T, BO));
 case BO_Rem:
   return Discard(this->emitRem(*T, BO));
+case BO_Div:
+  return Discard(this->emitDiv(*T, BO));
 case BO_Assign:
   if (!this->emitStore(*T, BO))
 return false;


Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -167,3 +167,19 @@
  // expected-error {{not an integral constant expression}} \
  // expected-note {{division by zero}}
 };
+
+namespace div {
+  constexpr int zero() { return 0; }
+  static_assert(12 / 3 == 4, "");
+  static_assert(12 / 0 == 12, ""); // ref-error {{not an integral constant expression}} \
+   // ref-note {{division by zero}} \
+   // expected-error {{not an integral constant expression}} \
+   // expected-note {{division by zero}}
+  static_assert(12 / -3 == -4, "");
+  static_assert(-12 / 3 == -4, "");
+
+
+  constexpr int LHS = 12;
+  constexpr long unsigned RHS = 3;
+  static_assert(LHS / RHS == 4, "");
+};
Index: clang/lib/AST/Interp/Opcodes.td
===
--- clang/lib/AST/Interp/Opcodes.td
+++ clang/lib/AST/Interp/Opcodes.td
@@ -401,7 +401,10 @@
   let Types = [NumberTypeClass];
   let Ha

[PATCH] D134749: [clang][Interp] Implement Div opcode

2022-09-27 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added inline comments.



Comment at: clang/lib/AST/Interp/Interp.h:189
+  const unsigned Bits = RHS.bitWidth() * 2;
+  T Result;
+  if (!T::div(LHS, RHS, Bits, &Result)) {

Could use a helper function here and in `Rem` to reduce code duplication.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134749

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


[PATCH] D134556: [Clang][OpenMP] Fix run time crash when use_device_addr is used.

2022-09-27 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 updated this revision to Diff 463257.
jyu2 added a comment.

Merge duplicate code as Alexey suggested.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134556

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/target_data_codegen.cpp
  openmp/libomptarget/test/mapping/target_use_device_addr.c

Index: openmp/libomptarget/test/mapping/target_use_device_addr.c
===
--- /dev/null
+++ openmp/libomptarget/test/mapping/target_use_device_addr.c
@@ -0,0 +1,18 @@
+// RUN: %libomptarget-compile-generic -fopenmp-version=51
+// RUN: %libomptarget-run-generic 2>&1 \
+// RUN: | %fcheck-generic
+
+#include 
+int main() {
+  short x[10];
+  short *xp = &x[0];
+
+  x[1] = 111;
+
+  printf("%d, %p\n", xp[1], &xp[1]);
+#pragma omp target data use_device_addr(xp [1:3]) map(tofrom : x)
+#pragma omp target is_device_ptr(xp)
+  { xp[1] = 222; }
+  // CHECK: 222
+  printf("%d, %p\n", xp[1], &xp[1]);
+}
Index: clang/test/OpenMP/target_data_codegen.cpp
===
--- clang/test/OpenMP/target_data_codegen.cpp
+++ clang/test/OpenMP/target_data_codegen.cpp
@@ -596,15 +596,18 @@
 }
 #endif
 ///==///
-// RUN: %clang_cc1 -no-opaque-pointers -DCK7 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK7 --check-prefix CK7-64
-// RUN: %clang_cc1 -no-opaque-pointers -DCK7 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
-// RUN: %clang_cc1 -no-opaque-pointers -fopenmp -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK7 --check-prefix CK7-64
+// RUN: %clang_cc1 -no-opaque-pointers -DCK7 -verify -fopenmp -fopenmp-targets=x86_64 -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK7 --check-prefix CK7-64
+// RUN: %clang_cc1 -no-opaque-pointers -DCK7 -fopenmp -fopenmp-targets=x86_64 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -no-opaque-pointers -fopenmp -fopenmp-targets=x86_64 -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK7 --check-prefix CK7-64
 
-// RUN: %clang_cc1 -no-opaque-pointers -DCK7 -verify -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY7 %s
-// RUN: %clang_cc1 -no-opaque-pointers -DCK7 -fopenmp-simd -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
-// RUN: %clang_cc1 -no-opaque-pointers -fopenmp-simd -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY7 %s
+// RUN: %clang_cc1 -no-opaque-pointers -DCK7 -verify -fopenmp-simd -fopenmp-targets=x86_64 -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY7 %s
+// RUN: %clang_cc1 -no-opaque-pointers -DCK7 -fopenmp-simd -fopenmp-targets=x86_64 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -no-opaque-pointers -fopenmp-simd -fopenmp-targets=x86_64 -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY7 %s
 // SIMD-ONLY7-NOT: {{__kmpc|__tgt}}
 #ifdef CK7
+// CK7: private unnamed_addr constant [2 x i64] [i64 64, i64 64]
+// CK7: private unnamed_addr constant [2 x i64] [i64 3, i64 64]
+// CK7-NOT: private unnamed_addr constant [2 x i64] [i64 64, i64 3]
 // CK7: test_device_ptr_addr
 void test_device_ptr_addr(int arg) {
   int *p;
@@ -612,6 +615,16 @@
   // CK7: add nsw i32
   #pragma omp target data use_device_ptr(p) use_device_addr(arg)
   { ++arg, ++(*p); }
+
+  short x[10];
+  short *xp = &x[0];
+
+  x[1] = 111;
+
+  #pragma omp target data map(tofrom: x) use_device_addr(xp[1:3])
+  {
+xp[1] = 222;
+  }
 }
 #endif
 ///==///
Index: clang/lib/CodeGen/CGOpenMPRuntime.cpp
===
--- clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -8547,49 +8547,92 @@
   }
 }
 
-// Look at the use_device_ptr clause information and mark the existing map
-// entries as such. If there is no map information for an entry in the
-// use_device_ptr list, we create one with map type 'alloc' and zero size
-// section. It is the user fault if that was not mapped before. If there is
-// no map information and the pointer is a struct member, then we defer the
-// emission of that entry until the whole struct has been processed.
+// Look at the use_device_ptr 

[PATCH] D134529: [C++20][Clang] P2468R2 The Equality Operator You Are Looking For

2022-09-27 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a reviewer: clang-language-wg.
ilya-biryukov added a comment.

Overall LG, thanks!
The only major comment from me is that we probably want to implement the full 
"corresponds" check so we handle various cases mentioned in the FIXMEs.

Also adding the Language WG as reviewers in case someone else wants to take a 
look.

> I don't follow why this disallows the reverse #4.

It seems the trick is to pick the right type of the lookup.
The particular wording says to search 
 for a name in 
scope rather than do a qualified lookup 
.
Only the latter should look inside the qualified namespaces.

Another idea for a test: try replacing declarations of `operator!=` with `using 
other_ns::operator!=`  in various examples and make sure that it keeps working.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134529

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


[PATCH] D134749: [clang][Interp] Implement Div opcode

2022-09-27 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.

Seems good enoguh to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134749

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


[PATCH] D134745: [LV][Metadata] Add loop.interleave.enable for loop vectorizer

2022-09-27 Thread Michael Berg via Phabricator via cfe-commits
mcberg2021 added inline comments.



Comment at: clang/lib/CodeGen/CGLoopInfo.cpp:673
+setInterleaveEnable(false);
 setInterleaveCount(1);
 break;

Can you update the comments on lines: 665 and 671 as they both need update.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134745

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


[PATCH] D134745: [LV][Metadata] Add loop.interleave.enable for loop vectorizer

2022-09-27 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 463261.
eopXD added a comment.

Update comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134745

Files:
  clang/lib/CodeGen/CGLoopInfo.cpp
  clang/lib/CodeGen/CGLoopInfo.h
  clang/test/CodeGenCXX/pragma-loop-predicate.cpp
  clang/test/CodeGenCXX/pragma-loop-safety.cpp
  clang/test/CodeGenCXX/pragma-loop.cpp
  llvm/include/llvm/Transforms/Vectorize/LoopVectorizationLegality.h
  llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  
llvm/test/Transforms/LoopVectorize/AArch64/outer_loop_test1_no_explicit_vect_width.ll
  llvm/test/Transforms/LoopVectorize/RISCV/force-vect-msg.ll
  llvm/test/Transforms/LoopVectorize/RISCV/riscv-vector-reverse.ll
  llvm/test/Transforms/LoopVectorize/X86/metadata-enable.ll
  
llvm/test/Transforms/LoopVectorize/X86/outer_loop_test1_no_explicit_vect_width.ll
  llvm/test/Transforms/LoopVectorize/X86/vect.omp.force.ll
  llvm/test/Transforms/LoopVectorize/X86/vectorization-remarks-missed.ll
  llvm/test/Transforms/LoopVectorize/explicit_outer_detection.ll
  llvm/test/Transforms/LoopVectorize/explicit_outer_nonuniform_inner.ll
  llvm/test/Transforms/LoopVectorize/explicit_outer_uniform_diverg_branch.ll
  llvm/test/Transforms/LoopVectorize/no_switch.ll
  llvm/test/Transforms/LoopVectorize/no_switch_disable_vectorization.ll
  llvm/test/Transforms/LoopVectorize/nounroll.ll
  llvm/test/Transforms/LoopVectorize/optsize.ll
  llvm/test/Transforms/LoopVectorize/outer-loop-vec-phi-predecessor-order.ll
  llvm/test/Transforms/LoopVectorize/outer_loop_test1.ll
  llvm/test/Transforms/LoopVectorize/outer_loop_test2.ll
  llvm/test/Transforms/LoopVectorize/vect.omp.persistence.ll
  llvm/test/Transforms/LoopVectorize/vplan-outer-loop-uncomputable-trip-count.ll
  llvm/test/Transforms/LoopVectorize/vplan-printing-outer-loop.ll
  llvm/test/Transforms/LoopVectorize/vplan-vectorize-inner-loop-reduction.ll
  llvm/test/Transforms/LoopVectorize/vplan-widen-call-instruction.ll
  llvm/test/Transforms/LoopVectorize/vplan-widen-select-instruction.ll

Index: llvm/test/Transforms/LoopVectorize/vplan-widen-select-instruction.ll
===
--- llvm/test/Transforms/LoopVectorize/vplan-widen-select-instruction.ll
+++ llvm/test/Transforms/LoopVectorize/vplan-widen-select-instruction.ll
@@ -196,5 +196,6 @@
 exit:
   ret void
 }
-!0 = distinct !{!0, !1}
+!0 = distinct !{!0, !1, !2}
 !1 = !{!"llvm.loop.vectorize.enable", i1 true}
+!2 = !{!"llvm.loop.interleave.enable", i1 false}
Index: llvm/test/Transforms/LoopVectorize/vplan-widen-call-instruction.ll
===
--- llvm/test/Transforms/LoopVectorize/vplan-widen-call-instruction.ll
+++ llvm/test/Transforms/LoopVectorize/vplan-widen-call-instruction.ll
@@ -68,5 +68,6 @@
   ret void
 }
 
-!0 = distinct !{!0, !1}
+!0 = distinct !{!0, !1, !2}
 !1 = !{!"llvm.loop.vectorize.enable", i1 true}
+!2 = !{!"llvm.loop.interleave.enable", i1 false}
Index: llvm/test/Transforms/LoopVectorize/vplan-vectorize-inner-loop-reduction.ll
===
--- llvm/test/Transforms/LoopVectorize/vplan-vectorize-inner-loop-reduction.ll
+++ llvm/test/Transforms/LoopVectorize/vplan-vectorize-inner-loop-reduction.ll
@@ -77,5 +77,6 @@
   ret void
 }
 
-!0 = distinct !{!0, !1}
+!0 = distinct !{!0, !1, !2}
 !1 = !{!"llvm.loop.vectorize.enable", i1 true}
+!2 = !{!"llvm.loop.interleave.enable", i1 false}
Index: llvm/test/Transforms/LoopVectorize/vplan-printing-outer-loop.ll
===
--- llvm/test/Transforms/LoopVectorize/vplan-printing-outer-loop.ll
+++ llvm/test/Transforms/LoopVectorize/vplan-printing-outer-loop.ll
@@ -69,6 +69,7 @@
   ret void
 }
 
-!1 = distinct !{!1, !2, !3}
+!1 = distinct !{!1, !2, !3, !4}
 !2 = !{!"llvm.loop.vectorize.width", i32 4}
 !3 = !{!"llvm.loop.vectorize.enable", i1 true}
+!4 = !{!"llvm.loop.interleave.enable", i1 false}
Index: llvm/test/Transforms/LoopVectorize/vplan-outer-loop-uncomputable-trip-count.ll
===
--- llvm/test/Transforms/LoopVectorize/vplan-outer-loop-uncomputable-trip-count.ll
+++ llvm/test/Transforms/LoopVectorize/vplan-outer-loop-uncomputable-trip-count.ll
@@ -43,5 +43,6 @@
   ret void
 }
 
-!0 = distinct !{!0, !1}
+!0 = distinct !{!0, !1, !2}
 !1 = !{!"llvm.loop.vectorize.enable", i1 true}
+!2 = !{!"llvm.loop.interleave.enable", i1 false}
Index: llvm/test/Transforms/LoopVectorize/vect.omp.persistence.ll
===
--- llvm/test/Transforms/LoopVectorize/vect.omp.persistence.ll
+++ llvm/test/Transforms/LoopVectorize/vect.omp.persistence.ll
@@ -2,7 +2,7 @@
 ; REQUIRES: asserts
 
 ; CHECK: LV: Checking a loop in 'foo'
-; CHECK: LV: Loop hints: 

[PATCH] D134745: [LV][Metadata] Add loop.interleave.enable for loop vectorizer

2022-09-27 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD marked an inline comment as done.
eopXD added a comment.

After this patch, we can remove setVectorizeWidth(1) and setInterleaveCount(1) 
when vectorize(disable) and interleave(disable) is specified. For now it is not 
removed to keep the patch limited and simple enough.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134745

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


[PATCH] D126481: [analyzer] Handle SymbolCast in SValBuilder

2022-09-27 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

@martong wrote:
I think you did get it. I'm not talking about range but about concrete int. And 
I see that the current behavior needs an improvement or rework.
Consider next code, which I used in my example:

  1. void test(int x) {
  2.   assert((short)x == 0);
  3.   clang_analyzer_eval(x == 1);
  4. }

Your patch does next:

- on the line 3 we know that `(int)(short)(int x) = 0` and `(int x) = 1`
- simplify `(int)(short)(int x)`. Try to get a constant for `(short)(int x)`. 
Result is nothing because it is not presented in the range map. **Continue 
**unwrapping.
- go deeper and simplify `(short)(int x)`.  Try to get a constant for `(int 
x)`. Result is 1. **Stop **visiting.
- return 1.
- intersect the range of the original symbol `(int)(short)(int x)` which is 
**0** and the range which is returned - **1**
- result is an **infeasible** state.

My patch above yours does next:

- on the line 3 we know that `(int)(short)(int x) = 0` and `(int x) = 1`, but 
now we also know that  `(short)(int x) = 0` as an equivalent for 
`(int)(short)(int x)` due to the improvement.
- simplify `(int)(short)(int x)`. Try to get a constant for `(short)(int x)`. 
Result is 0. **Stop **visiting.
- return 0.
- intersect the range of the original symbol `(int)(short)(int x)` which is 
**0** and the range which is returned - **0**
- result is a **feasible** state.

Here what I'm saying. This is not about ranges. This simplification dosn't take 
into account that differents operands of the cast symbol may have different 
asocciated ranges or constants. And what do we have to do we them in this case?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126481

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


[PATCH] D134456: [PGO] Consider parent context when weighing branches with likelyhood.

2022-09-27 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Maybe we could have a `-f` flag to control whether to prefer annotations or 
profile data when they conflict?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134456

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


[PATCH] D134441: [ObjC][ARC] Fix target register for call expanded from CALL_RVMARKER on Windows

2022-09-27 Thread Stefan Gränitz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGed8409dfa0a9: [ObjC][ARC] Fix target register for call 
expanded from CALL_RVMARKER on Windows (authored by sgraenitz).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134441

Files:
  llvm/lib/Target/X86/X86ExpandPseudo.cpp
  llvm/test/CodeGen/X86/call-rv-marker.ll


Index: llvm/test/CodeGen/X86/call-rv-marker.ll
===
--- llvm/test/CodeGen/X86/call-rv-marker.ll
+++ llvm/test/CodeGen/X86/call-rv-marker.ll
@@ -1,4 +1,5 @@
 ; RUN: llc -mtriple=x86_64-apple-macosx -verify-machineinstrs -o - %s | 
FileCheck --check-prefix=CHECK %s
+; RUN: llc -mtriple=x86_64-windows-msvc -verify-machineinstrs -o - %s | 
FileCheck --check-prefix=WINABI %s
 
 ; TODO: support marker generation with GlobalISel
 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
@@ -33,6 +34,12 @@
 ; CHECK-NEXT:popq%rcx
 ; CHECK-NEXT:retq
 ;
+; WINABI-LABEL: rv_marker_1_retain:
+; WINABI:callq   foo1
+; WINABI-NEXT:   movq%rax, %rcx
+; WINABI-NEXT:   callq   objc_retainAutoreleasedReturnValue
+; WINABI-NEXT:   nop
+;
 entry:
   %call = call ptr @foo1() [ "clang.arc.attachedcall"(ptr 
@objc_retainAutoreleasedReturnValue) ]
   ret ptr %call
Index: llvm/lib/Target/X86/X86ExpandPseudo.cpp
===
--- llvm/lib/Target/X86/X86ExpandPseudo.cpp
+++ llvm/lib/Target/X86/X86ExpandPseudo.cpp
@@ -224,9 +224,11 @@
   // Emit marker "movq %rax, %rdi".  %rdi is not callee-saved, so it cannot be
   // live across the earlier call. The call to the ObjC runtime function 
returns
   // the first argument, so the value of %rax is unchanged after the ObjC
-  // runtime call.
+  // runtime call. On Windows targets, the runtime call follows the regular
+  // x64 calling convention and expects the first argument in %rcx.
+  auto TargetReg = STI->getTargetTriple().isOSWindows() ? X86::RCX : X86::RDI;
   auto *Marker = BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(X86::MOV64rr))
- .addReg(X86::RDI, RegState::Define)
+ .addReg(TargetReg, RegState::Define)
  .addReg(X86::RAX)
  .getInstr();
   if (MI.shouldUpdateCallSiteInfo())


Index: llvm/test/CodeGen/X86/call-rv-marker.ll
===
--- llvm/test/CodeGen/X86/call-rv-marker.ll
+++ llvm/test/CodeGen/X86/call-rv-marker.ll
@@ -1,4 +1,5 @@
 ; RUN: llc -mtriple=x86_64-apple-macosx -verify-machineinstrs -o - %s | FileCheck --check-prefix=CHECK %s
+; RUN: llc -mtriple=x86_64-windows-msvc -verify-machineinstrs -o - %s | FileCheck --check-prefix=WINABI %s
 
 ; TODO: support marker generation with GlobalISel
 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
@@ -33,6 +34,12 @@
 ; CHECK-NEXT:popq%rcx
 ; CHECK-NEXT:retq
 ;
+; WINABI-LABEL: rv_marker_1_retain:
+; WINABI:callq   foo1
+; WINABI-NEXT:   movq%rax, %rcx
+; WINABI-NEXT:   callq   objc_retainAutoreleasedReturnValue
+; WINABI-NEXT:   nop
+;
 entry:
   %call = call ptr @foo1() [ "clang.arc.attachedcall"(ptr @objc_retainAutoreleasedReturnValue) ]
   ret ptr %call
Index: llvm/lib/Target/X86/X86ExpandPseudo.cpp
===
--- llvm/lib/Target/X86/X86ExpandPseudo.cpp
+++ llvm/lib/Target/X86/X86ExpandPseudo.cpp
@@ -224,9 +224,11 @@
   // Emit marker "movq %rax, %rdi".  %rdi is not callee-saved, so it cannot be
   // live across the earlier call. The call to the ObjC runtime function returns
   // the first argument, so the value of %rax is unchanged after the ObjC
-  // runtime call.
+  // runtime call. On Windows targets, the runtime call follows the regular
+  // x64 calling convention and expects the first argument in %rcx.
+  auto TargetReg = STI->getTargetTriple().isOSWindows() ? X86::RCX : X86::RDI;
   auto *Marker = BuildMI(MBB, MBBI, MI.getDebugLoc(), TII->get(X86::MOV64rr))
- .addReg(X86::RDI, RegState::Define)
+ .addReg(TargetReg, RegState::Define)
  .addReg(X86::RAX)
  .getInstr();
   if (MI.shouldUpdateCallSiteInfo())
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D134556: [Clang][OpenMP] Fix run time crash when use_device_addr is used.

2022-09-27 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134556

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


[clang] d1ad006 - [Driver] Prevent Mips specific code from claiming -mabi argument on other targets.

2022-09-27 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2022-09-27T10:07:20-07:00
New Revision: d1ad006a8f64bdc17f618deffa9e7c91d82c444d

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

LOG: [Driver] Prevent Mips specific code from claiming -mabi argument on other 
targets.

Fixes PR57976.

Reviewed By: erichkeane, arichardson, MaskRay

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

Added: 
clang/test/Driver/mabi.c

Modified: 
clang/lib/Driver/Driver.cpp

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index c16797f318f6d..73ee0b9585cf6 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -634,36 +634,38 @@ static llvm::Triple computeTargetTriple(const Driver &D,
 
   // If target is MIPS adjust the target triple
   // accordingly to provided ABI name.
-  A = Args.getLastArg(options::OPT_mabi_EQ);
-  if (A && Target.isMIPS()) {
-StringRef ABIName = A->getValue();
-if (ABIName == "32") {
-  Target = Target.get32BitArchVariant();
-  if (Target.getEnvironment() == llvm::Triple::GNUABI64 ||
-  Target.getEnvironment() == llvm::Triple::GNUABIN32)
-Target.setEnvironment(llvm::Triple::GNU);
-} else if (ABIName == "n32") {
-  Target = Target.get64BitArchVariant();
-  if (Target.getEnvironment() == llvm::Triple::GNU ||
-  Target.getEnvironment() == llvm::Triple::GNUABI64)
-Target.setEnvironment(llvm::Triple::GNUABIN32);
-} else if (ABIName == "64") {
-  Target = Target.get64BitArchVariant();
-  if (Target.getEnvironment() == llvm::Triple::GNU ||
-  Target.getEnvironment() == llvm::Triple::GNUABIN32)
-Target.setEnvironment(llvm::Triple::GNUABI64);
+  if (Target.isMIPS()) {
+if (A = Args.getLastArg(options::OPT_mabi_EQ)) {
+  StringRef ABIName = A->getValue();
+  if (ABIName == "32") {
+Target = Target.get32BitArchVariant();
+if (Target.getEnvironment() == llvm::Triple::GNUABI64 ||
+Target.getEnvironment() == llvm::Triple::GNUABIN32)
+  Target.setEnvironment(llvm::Triple::GNU);
+  } else if (ABIName == "n32") {
+Target = Target.get64BitArchVariant();
+if (Target.getEnvironment() == llvm::Triple::GNU ||
+Target.getEnvironment() == llvm::Triple::GNUABI64)
+  Target.setEnvironment(llvm::Triple::GNUABIN32);
+  } else if (ABIName == "64") {
+Target = Target.get64BitArchVariant();
+if (Target.getEnvironment() == llvm::Triple::GNU ||
+Target.getEnvironment() == llvm::Triple::GNUABIN32)
+  Target.setEnvironment(llvm::Triple::GNUABI64);
+  }
 }
   }
 
   // If target is RISC-V adjust the target triple according to
   // provided architecture name
-  A = Args.getLastArg(options::OPT_march_EQ);
-  if (A && Target.isRISCV()) {
-StringRef ArchName = A->getValue();
-if (ArchName.startswith_insensitive("rv32"))
-  Target.setArch(llvm::Triple::riscv32);
-else if (ArchName.startswith_insensitive("rv64"))
-  Target.setArch(llvm::Triple::riscv64);
+  if (Target.isRISCV()) {
+if (A = Args.getLastArg(options::OPT_march_EQ)) {
+  StringRef ArchName = A->getValue();
+  if (ArchName.startswith_insensitive("rv32"))
+Target.setArch(llvm::Triple::riscv32);
+  else if (ArchName.startswith_insensitive("rv64"))
+Target.setArch(llvm::Triple::riscv64);
+}
   }
 
   return Target;

diff  --git a/clang/test/Driver/mabi.c b/clang/test/Driver/mabi.c
new file mode 100644
index 0..01e494d91b7a2
--- /dev/null
+++ b/clang/test/Driver/mabi.c
@@ -0,0 +1,6 @@
+// RUN: %clang --target=i386-unknown-linux -mabi=ms -S %s -### 2>&1 | 
FileCheck --check-prefix=CHECK %s
+
+int f() {
+  // CHECK: warning: argument unused during compilation: '-mabi=ms'
+  return 0;
+}



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


[PATCH] D134671: [Driver] Prevent Mips specific code from claiming -mabi argument on other targets.

2022-09-27 Thread Craig Topper via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd1ad006a8f64: [Driver] Prevent Mips specific code from 
claiming -mabi argument on other… (authored by craig.topper).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134671

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/mabi.c


Index: clang/test/Driver/mabi.c
===
--- /dev/null
+++ clang/test/Driver/mabi.c
@@ -0,0 +1,6 @@
+// RUN: %clang --target=i386-unknown-linux -mabi=ms -S %s -### 2>&1 | 
FileCheck --check-prefix=CHECK %s
+
+int f() {
+  // CHECK: warning: argument unused during compilation: '-mabi=ms'
+  return 0;
+}
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -634,36 +634,38 @@
 
   // If target is MIPS adjust the target triple
   // accordingly to provided ABI name.
-  A = Args.getLastArg(options::OPT_mabi_EQ);
-  if (A && Target.isMIPS()) {
-StringRef ABIName = A->getValue();
-if (ABIName == "32") {
-  Target = Target.get32BitArchVariant();
-  if (Target.getEnvironment() == llvm::Triple::GNUABI64 ||
-  Target.getEnvironment() == llvm::Triple::GNUABIN32)
-Target.setEnvironment(llvm::Triple::GNU);
-} else if (ABIName == "n32") {
-  Target = Target.get64BitArchVariant();
-  if (Target.getEnvironment() == llvm::Triple::GNU ||
-  Target.getEnvironment() == llvm::Triple::GNUABI64)
-Target.setEnvironment(llvm::Triple::GNUABIN32);
-} else if (ABIName == "64") {
-  Target = Target.get64BitArchVariant();
-  if (Target.getEnvironment() == llvm::Triple::GNU ||
-  Target.getEnvironment() == llvm::Triple::GNUABIN32)
-Target.setEnvironment(llvm::Triple::GNUABI64);
+  if (Target.isMIPS()) {
+if (A = Args.getLastArg(options::OPT_mabi_EQ)) {
+  StringRef ABIName = A->getValue();
+  if (ABIName == "32") {
+Target = Target.get32BitArchVariant();
+if (Target.getEnvironment() == llvm::Triple::GNUABI64 ||
+Target.getEnvironment() == llvm::Triple::GNUABIN32)
+  Target.setEnvironment(llvm::Triple::GNU);
+  } else if (ABIName == "n32") {
+Target = Target.get64BitArchVariant();
+if (Target.getEnvironment() == llvm::Triple::GNU ||
+Target.getEnvironment() == llvm::Triple::GNUABI64)
+  Target.setEnvironment(llvm::Triple::GNUABIN32);
+  } else if (ABIName == "64") {
+Target = Target.get64BitArchVariant();
+if (Target.getEnvironment() == llvm::Triple::GNU ||
+Target.getEnvironment() == llvm::Triple::GNUABIN32)
+  Target.setEnvironment(llvm::Triple::GNUABI64);
+  }
 }
   }
 
   // If target is RISC-V adjust the target triple according to
   // provided architecture name
-  A = Args.getLastArg(options::OPT_march_EQ);
-  if (A && Target.isRISCV()) {
-StringRef ArchName = A->getValue();
-if (ArchName.startswith_insensitive("rv32"))
-  Target.setArch(llvm::Triple::riscv32);
-else if (ArchName.startswith_insensitive("rv64"))
-  Target.setArch(llvm::Triple::riscv64);
+  if (Target.isRISCV()) {
+if (A = Args.getLastArg(options::OPT_march_EQ)) {
+  StringRef ArchName = A->getValue();
+  if (ArchName.startswith_insensitive("rv32"))
+Target.setArch(llvm::Triple::riscv32);
+  else if (ArchName.startswith_insensitive("rv64"))
+Target.setArch(llvm::Triple::riscv64);
+}
   }
 
   return Target;


Index: clang/test/Driver/mabi.c
===
--- /dev/null
+++ clang/test/Driver/mabi.c
@@ -0,0 +1,6 @@
+// RUN: %clang --target=i386-unknown-linux -mabi=ms -S %s -### 2>&1 | FileCheck --check-prefix=CHECK %s
+
+int f() {
+  // CHECK: warning: argument unused during compilation: '-mabi=ms'
+  return 0;
+}
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -634,36 +634,38 @@
 
   // If target is MIPS adjust the target triple
   // accordingly to provided ABI name.
-  A = Args.getLastArg(options::OPT_mabi_EQ);
-  if (A && Target.isMIPS()) {
-StringRef ABIName = A->getValue();
-if (ABIName == "32") {
-  Target = Target.get32BitArchVariant();
-  if (Target.getEnvironment() == llvm::Triple::GNUABI64 ||
-  Target.getEnvironment() == llvm::Triple::GNUABIN32)
-Target.setEnvironment(llvm::Triple::GNU);
-} else if (ABIName == "n32") {
-  Target = Target.get64BitArchVariant();
-  if (Target.getEnvironment() == llvm::Triple::GNU ||
-  Target.getEnvironment() == llvm::Triple::GNUABI64)
-Target.setEnvironment(llvm::Triple::GNUABIN32);
-} else if (ABIName == "64") {
-  Target = Targ

[clang] cbbce9b - [Driver] Silence a -Wparentheses error. NFC

2022-09-27 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2022-09-27T10:25:23-07:00
New Revision: cbbce9b537adfbc2271424ab66b3f2d818a2499f

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

LOG: [Driver] Silence a -Wparentheses error. NFC

Added: 


Modified: 
clang/lib/Driver/Driver.cpp

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 73ee0b9585cf..a40a992ac087 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -635,7 +635,7 @@ static llvm::Triple computeTargetTriple(const Driver &D,
   // If target is MIPS adjust the target triple
   // accordingly to provided ABI name.
   if (Target.isMIPS()) {
-if (A = Args.getLastArg(options::OPT_mabi_EQ)) {
+if ((A = Args.getLastArg(options::OPT_mabi_EQ))) {
   StringRef ABIName = A->getValue();
   if (ABIName == "32") {
 Target = Target.get32BitArchVariant();
@@ -659,7 +659,7 @@ static llvm::Triple computeTargetTriple(const Driver &D,
   // If target is RISC-V adjust the target triple according to
   // provided architecture name
   if (Target.isRISCV()) {
-if (A = Args.getLastArg(options::OPT_march_EQ)) {
+if ((A = Args.getLastArg(options::OPT_march_EQ))) {
   StringRef ArchName = A->getValue();
   if (ArchName.startswith_insensitive("rv32"))
 Target.setArch(llvm::Triple::riscv32);



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


[PATCH] D134337: [clang] [Driver] More flexible rules for loading default configs (WIP)

2022-09-27 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 463274.
mgorny added a comment.

Update tests. Docs coming up next.


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

https://reviews.llvm.org/D134337

Files:
  clang/include/clang/Driver/Driver.h
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/config-file3.c

Index: clang/test/Driver/config-file3.c
===
--- clang/test/Driver/config-file3.c
+++ clang/test/Driver/config-file3.c
@@ -14,107 +14,261 @@
 // CHECK-REL: Configuration file: {{.*}}/workdir/cfg-1
 // CHECK-REL: -Wundefined-var-template
 
+//--- Config files are searched for in binary directory as well.
+//
+// RUN: mkdir %t/testbin
+// RUN: ln -s %clang %t/testbin/clang
+// RUN: echo "-Werror" > %t/testbin/aaa.cfg
+// RUN: %t/testbin/clang --config-system-dir= --config-user-dir= --config aaa.cfg -c -no-canonical-prefixes -### %s 2>&1 | FileCheck %s -check-prefix CHECK-BIN
+//
+// CHECK-BIN: Configuration file: {{.*}}/testbin/aaa.cfg
+// CHECK-BIN: -Werror
 
-//--- Invocation qqq-clang-g++ tries to find config file qqq-clang-g++.cfg first.
+//--- Invocation x86_64-unknown-linux-gnu-clang-g++ tries x86_64-unknown-linux-gnu-clang++.cfg first.
 //
 // RUN: mkdir %t/testdmode
-// RUN: ln -s %clang %t/testdmode/qqq-clang-g++
-// RUN: echo "-Wundefined-func-template" > %t/testdmode/qqq-clang-g++.cfg
-// RUN: echo "-Werror" > %t/testdmode/qqq.cfg
-// RUN: %t/testdmode/qqq-clang-g++ --config-system-dir= --config-user-dir= -c -no-canonical-prefixes -### %s 2>&1 | FileCheck %s -check-prefix FULL-NAME
+// RUN: ln -s %clang %t/testdmode/i386-unknown-linux-gnu-clang-g++
+// RUN: ln -s %clang %t/testdmode/x86_64-unknown-linux-gnu-clang-g++
+// RUN: ln -s %clang %t/testdmode/x86_64-unknown-linux-gnu-clang
+// RUN: echo > %t/testdmode/x86_64-unknown-linux-gnu-clang++.cfg
+// RUN: echo > %t/testdmode/x86_64-unknown-linux-gnu-clang-g++.cfg
+// RUN: echo > %t/testdmode/x86_64-unknown-linux-gnu-clang.cfg
+// RUN: echo > %t/testdmode/x86_64-unknown-linux-gnu.cfg
+// RUN: echo > %t/testdmode/i386-unknown-linux-gnu-clang++.cfg
+// RUN: echo > %t/testdmode/i386-unknown-linux-gnu-clang-g++.cfg
+// RUN: echo > %t/testdmode/i386-unknown-linux-gnu-clang.cfg
+// RUN: echo > %t/testdmode/i386-unknown-linux-gnu.cfg
+// RUN: echo > %t/testdmode/clang++.cfg
+// RUN: echo > %t/testdmode/clang-g++.cfg
+// RUN: echo > %t/testdmode/clang.cfg
+// RUN: %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1
 //
-// FULL-NAME: Configuration file: {{.*}}/testdmode/qqq-clang-g++.cfg
-// FULL-NAME: -Wundefined-func-template
-// FULL-NAME-NOT: -Werror
+// FULL1: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu-clang++.cfg
+// FULL1-NOT: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu-clang-g++.cfg
+// FULL1-NOT: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu-clang.cfg
+// FULL1-NOT: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu.cfg
+// FULL1-NOT: Configuration file: {{.*}}/testdmode/i386-unknown-linux-gnu-clang++.cfg
+// FULL1-NOT: Configuration file: {{.*}}/testdmode/i386-unknown-linux-gnu-clang-g++.cfg
+// FULL1-NOT: Configuration file: {{.*}}/testdmode/i386-unknown-linux-gnu-clang.cfg
+// FULL1-NOT: Configuration file: {{.*}}/testdmode/i386-unknown-linux-gnu.cfg
+// FULL1-NOT: Configuration file: {{.*}}/testdmode/clang++.cfg
+// FULL1-NOT: Configuration file: {{.*}}/testdmode/clang-g++.cfg
+// FULL1-NOT: Configuration file: {{.*}}/testdmode/clang.cfg
+
+//--- -m32 overrides triple.
 //
-//--- Invocation qqq-clang-g++ tries to find config file qqq-clang-g++.cfg even without -no-canonical-prefixes.
-// (As the clang executable and symlink are in different directories, this
-// requires specifying the path via --config-*-dir= though.)
+// RUN: %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ -m32 --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1-I386
 //
-// RUN: %t/testdmode/qqq-clang-g++ --config-system-dir= --config-user-dir=%t/testdmode -c -### %s 2>&1 | FileCheck %s -check-prefix SYMLINK
+// FULL1-I386-NOT: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu-clang++.cfg
+// FULL1-I386-NOT: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu-clang-g++.cfg
+// FULL1-I386-NOT: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu-clang.cfg
+// FULL1-I386-NOT: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu.cfg
+// FULL1-I386: Configuration file: {{.*}}/testdmode/i386-unknown-linux-gnu-clang++.cfg
+// FULL1-I386-NOT: Configuration file: {{.*}}/testdmode/i386-unknown-linux-gnu-clang-g++.cfg
+// FULL1-I386-NOT: Configuration file: {{.*}}/testdmode/i386-unknown-linux-gnu-clang.cfg
+// FULL1-I386-NOT: Configuration file: {{.*}}/testdmode/i386-unknown-linux-gnu.cfg
+// FULL1-I386-NOT: Configuration file: {{.*}}/testd

[PATCH] D134693: [CMake] Add `CLANG_ENABLE_HLSL` CMake option

2022-09-27 Thread Chris Bieneman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe432108bf254: [CMake] Add `CLANG_ENABLE_HLSL` CMake option 
(authored by beanz).

Changed prior to commit:
  https://reviews.llvm.org/D134693?vs=463079&id=463275#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134693

Files:
  clang/CMakeLists.txt
  clang/cmake/caches/HLSL.cmake
  clang/lib/Headers/CMakeLists.txt
  clang/tools/driver/CMakeLists.txt


Index: clang/tools/driver/CMakeLists.txt
===
--- clang/tools/driver/CMakeLists.txt
+++ clang/tools/driver/CMakeLists.txt
@@ -61,7 +61,11 @@
   set(CLANG_LINKS_TO_CREATE clang++ clang-cl clang-cpp)
 endif()
 
-foreach(link ${CLANG_LINKS_TO_CREATE})
+if (CLANG_ENABLE_HLSL)
+  set(HLSL_LINK clang-dxc)
+endif()
+
+foreach(link ${CLANG_LINKS_TO_CREATE} ${HLSL_LINK})
   add_clang_symlink(${link} clang)
 endforeach()
 
Index: clang/lib/Headers/CMakeLists.txt
===
--- clang/lib/Headers/CMakeLists.txt
+++ clang/lib/Headers/CMakeLists.txt
@@ -62,11 +62,15 @@
   __clang_hip_runtime_wrapper.h
   )
 
-set(hlsl_files
-  hlsl.h
+set(hlsl_h hlsl.h)
+set(hlsl_subdir_files
   hlsl/hlsl_basic_types.h
   hlsl/hlsl_intrinsics.h
   )
+set(hlsl_files
+  ${hlsl_h}
+  ${hlsl_subdir_files}
+  )
 
 set(mips_msa_files
   msa.h
@@ -548,10 +552,20 @@
   EXCLUDE_FROM_ALL
   COMPONENT x86-resource-headers)
 
+if(NOT CLANG_ENABLE_HLSL)
+  set(EXCLUDE_HLSL EXCLUDE_FROM_ALL)
+endif()
+
 install(
-  FILES ${hlsl_files}
+  FILES ${hlsl_h}
   DESTINATION ${header_install_dir}
-  EXCLUDE_FROM_ALL
+  ${EXCLUDE_HLSL}
+  COMPONENT hlsl-resource-headers)
+
+install(
+  FILES ${hlsl_subdir_files}
+  DESTINATION ${header_install_dir}/hlsl
+  ${EXCLUDE_HLSL}
   COMPONENT hlsl-resource-headers)
 
 install(
Index: clang/cmake/caches/HLSL.cmake
===
--- clang/cmake/caches/HLSL.cmake
+++ clang/cmake/caches/HLSL.cmake
@@ -9,3 +9,5 @@
 # HLSL support is currently limted to clang, eventually it will expand to
 # clang-tools-extra too.
 set(LLVM_ENABLE_PROJECTS "clang" CACHE STRING "")
+
+set(CLANG_ENABLE_HLSL On CACHE BOOL "")
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -482,6 +482,10 @@
"Generate build targets for the Clang unit tests."
${LLVM_INCLUDE_TESTS})
 
+option(CLANG_ENABLE_HLSL "Include HLSL build products" Off)
+# While HLSL support is experimental this should stay hidden.
+mark_as_advanced(CLANG_ENABLE_HLSL)
+
 add_subdirectory(utils/TableGen)
 
 # Export CLANG_TABLEGEN_EXE for use by flang docs.


Index: clang/tools/driver/CMakeLists.txt
===
--- clang/tools/driver/CMakeLists.txt
+++ clang/tools/driver/CMakeLists.txt
@@ -61,7 +61,11 @@
   set(CLANG_LINKS_TO_CREATE clang++ clang-cl clang-cpp)
 endif()
 
-foreach(link ${CLANG_LINKS_TO_CREATE})
+if (CLANG_ENABLE_HLSL)
+  set(HLSL_LINK clang-dxc)
+endif()
+
+foreach(link ${CLANG_LINKS_TO_CREATE} ${HLSL_LINK})
   add_clang_symlink(${link} clang)
 endforeach()
 
Index: clang/lib/Headers/CMakeLists.txt
===
--- clang/lib/Headers/CMakeLists.txt
+++ clang/lib/Headers/CMakeLists.txt
@@ -62,11 +62,15 @@
   __clang_hip_runtime_wrapper.h
   )
 
-set(hlsl_files
-  hlsl.h
+set(hlsl_h hlsl.h)
+set(hlsl_subdir_files
   hlsl/hlsl_basic_types.h
   hlsl/hlsl_intrinsics.h
   )
+set(hlsl_files
+  ${hlsl_h}
+  ${hlsl_subdir_files}
+  )
 
 set(mips_msa_files
   msa.h
@@ -548,10 +552,20 @@
   EXCLUDE_FROM_ALL
   COMPONENT x86-resource-headers)
 
+if(NOT CLANG_ENABLE_HLSL)
+  set(EXCLUDE_HLSL EXCLUDE_FROM_ALL)
+endif()
+
 install(
-  FILES ${hlsl_files}
+  FILES ${hlsl_h}
   DESTINATION ${header_install_dir}
-  EXCLUDE_FROM_ALL
+  ${EXCLUDE_HLSL}
+  COMPONENT hlsl-resource-headers)
+
+install(
+  FILES ${hlsl_subdir_files}
+  DESTINATION ${header_install_dir}/hlsl
+  ${EXCLUDE_HLSL}
   COMPONENT hlsl-resource-headers)
 
 install(
Index: clang/cmake/caches/HLSL.cmake
===
--- clang/cmake/caches/HLSL.cmake
+++ clang/cmake/caches/HLSL.cmake
@@ -9,3 +9,5 @@
 # HLSL support is currently limted to clang, eventually it will expand to
 # clang-tools-extra too.
 set(LLVM_ENABLE_PROJECTS "clang" CACHE STRING "")
+
+set(CLANG_ENABLE_HLSL On CACHE BOOL "")
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -482,6 +482,10 @@
"Generate build targets for the Clang unit tests."
${LLVM_INCLUDE_TESTS})
 
+option(CLANG_ENABLE_HLSL "Include HLSL build products" Off)
+# While HLSL support is experimental this shoul

[clang] e432108 - [CMake] Add `CLANG_ENABLE_HLSL` CMake option

2022-09-27 Thread Chris Bieneman via cfe-commits

Author: Chris Bieneman
Date: 2022-09-27T12:33:22-05:00
New Revision: e432108bf25456f428a3956fd79d29ea7fc196ac

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

LOG: [CMake] Add `CLANG_ENABLE_HLSL` CMake option

The HLSL support in clang is in progress and not fully functioning. As
such we don't want to install the related optional build components by
default (yet), but we do need an option to build and install them
locally for testing and for some key users.

This adds the `CLANG_ENABLE_HLSL` option which is off by default and can
be enabled to install the HLSL clang headers and the clang-dxc symlink.

Reviewed By: phosek

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

Added: 


Modified: 
clang/CMakeLists.txt
clang/cmake/caches/HLSL.cmake
clang/lib/Headers/CMakeLists.txt
clang/tools/driver/CMakeLists.txt

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 22b5118c83eda..f43fa51a3379c 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -482,6 +482,10 @@ option(CLANG_INCLUDE_TESTS
"Generate build targets for the Clang unit tests."
${LLVM_INCLUDE_TESTS})
 
+option(CLANG_ENABLE_HLSL "Include HLSL build products" Off)
+# While HLSL support is experimental this should stay hidden.
+mark_as_advanced(CLANG_ENABLE_HLSL)
+
 add_subdirectory(utils/TableGen)
 
 # Export CLANG_TABLEGEN_EXE for use by flang docs.

diff  --git a/clang/cmake/caches/HLSL.cmake b/clang/cmake/caches/HLSL.cmake
index e2d02b6b281a3..71f81e53f6bd3 100644
--- a/clang/cmake/caches/HLSL.cmake
+++ b/clang/cmake/caches/HLSL.cmake
@@ -9,3 +9,5 @@ set(LLVM_EXPERIMENTAL_TARGETS_TO_BUILD DirectX CACHE STRING "")
 # HLSL support is currently limted to clang, eventually it will expand to
 # clang-tools-extra too.
 set(LLVM_ENABLE_PROJECTS "clang" CACHE STRING "")
+
+set(CLANG_ENABLE_HLSL On CACHE BOOL "")

diff  --git a/clang/lib/Headers/CMakeLists.txt 
b/clang/lib/Headers/CMakeLists.txt
index c374580ceb5c8..b8ee1fec86a2a 100644
--- a/clang/lib/Headers/CMakeLists.txt
+++ b/clang/lib/Headers/CMakeLists.txt
@@ -62,11 +62,15 @@ set(hip_files
   __clang_hip_runtime_wrapper.h
   )
 
-set(hlsl_files
-  hlsl.h
+set(hlsl_h hlsl.h)
+set(hlsl_subdir_files
   hlsl/hlsl_basic_types.h
   hlsl/hlsl_intrinsics.h
   )
+set(hlsl_files
+  ${hlsl_h}
+  ${hlsl_subdir_files}
+  )
 
 set(mips_msa_files
   msa.h
@@ -548,10 +552,20 @@ install(
   EXCLUDE_FROM_ALL
   COMPONENT x86-resource-headers)
 
+if(NOT CLANG_ENABLE_HLSL)
+  set(EXCLUDE_HLSL EXCLUDE_FROM_ALL)
+endif()
+
 install(
-  FILES ${hlsl_files}
+  FILES ${hlsl_h}
   DESTINATION ${header_install_dir}
-  EXCLUDE_FROM_ALL
+  ${EXCLUDE_HLSL}
+  COMPONENT hlsl-resource-headers)
+
+install(
+  FILES ${hlsl_subdir_files}
+  DESTINATION ${header_install_dir}/hlsl
+  ${EXCLUDE_HLSL}
   COMPONENT hlsl-resource-headers)
 
 install(

diff  --git a/clang/tools/driver/CMakeLists.txt 
b/clang/tools/driver/CMakeLists.txt
index d05b71db13f21..e233ee7168080 100644
--- a/clang/tools/driver/CMakeLists.txt
+++ b/clang/tools/driver/CMakeLists.txt
@@ -61,7 +61,11 @@ if(NOT CLANG_LINKS_TO_CREATE)
   set(CLANG_LINKS_TO_CREATE clang++ clang-cl clang-cpp)
 endif()
 
-foreach(link ${CLANG_LINKS_TO_CREATE})
+if (CLANG_ENABLE_HLSL)
+  set(HLSL_LINK clang-dxc)
+endif()
+
+foreach(link ${CLANG_LINKS_TO_CREATE} ${HLSL_LINK})
   add_clang_symlink(${link} clang)
 endforeach()
 



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


[PATCH] D134705: [clang][DebugInfo] Emit debuginfo for non-constant case value

2022-09-27 Thread David Blaikie via Phabricator via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

SGTM - could you also add some CHECKs in the test that show the enumeration was 
added to the enumerators list on the CU (& you can probably test with just one 
enumerator - don't need two in each test for instance)

& I'm not quite following - what's the difference between the two cases being 
tested? Oh, I guess the second has implicit conversions in the case parameters? 
Fair enough, maybe would benefit from some comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134705

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


[PATCH] D133817: MSVC ABI: Looks like even non-aarch64 uses the MSVC/14 definition for pod/aggregate passing

2022-09-27 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Ping on this.

(also sent out D134688  for the HFA stuff, 
which separates that from the "isTrivialFor" functionality entirely making it 
easier to make the different choices here)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133817

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


[PATCH] D86049: RFC: Implement optional exportable wrapper function generation for objc_direct methods.

2022-09-27 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi added a comment.

In D86049#3818435 , @mwyman wrote:

> In D86049#3816006 , @plotfi wrote:
>
>> @dmaclach @ahatanak @mwyman How do things look from here? Do you want 
>> something for properties as well or would it be ok if we did this in a later 
>> commit?
>
> Huh, for some reason I thought when I'd last poked at using the `visibility` 
> attribute it wasn't allowed on ObjC methods, which is why I'd suggested 
> adding the enum on `objc_direct`, but as that no longer appears to be the 
> case yes I like this approach better.

@dmaclach @mwyman  I am also very happy with the fact that we can just reuse 
the regular `visibility` attribute. In the future we can decide on revised 
behavior for `hasMethodVisibilityDefault`.

@ahatanak Do you have feedback on this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86049

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


[PATCH] D133683: [c++] implements tentative DR1432 for partial ordering of function template

2022-09-27 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 463283.
ychen added a comment.

- add test for the conditioning on `ClangABICompat15`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133683

Files:
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/CXX/drs/dr6xx.cpp
  clang/test/SemaCXX/pre-dr692.cpp

Index: clang/test/SemaCXX/pre-dr692.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/pre-dr692.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -std=c++11 -verify -fexceptions -fcxx-exceptions -pedantic-errors -fno-spell-checking -fclang-abi-compat=15
+
+template  struct A1 {};
+template  struct A2 {};
+template  void e1(A1);  // expected-note {{candidate}}
+template  void e1(A1);  // expected-note {{candidate}}
+template  void e2(A2);  // expected-note {{candidate}}
+template  void e2(A2);  // expected-note {{candidate}}
+void h() {
+  A1 b1;
+  e1(b1); // expected-error{{call to 'e1' is ambiguous}}
+  A2 b2;
+  e2(b2); // expected-error{{call to 'e2' is ambiguous}}
+}
Index: clang/test/CXX/drs/dr6xx.cpp
===
--- clang/test/CXX/drs/dr6xx.cpp
+++ clang/test/CXX/drs/dr6xx.cpp
@@ -1083,13 +1083,23 @@
   // Also see dr1395.
 
   namespace temp_func_order_example2 {
-template  struct A {};
-template  void f(U, A *p = 0); // expected-note {{candidate}}
-template  int &f(U, A *p = 0); // expected-note {{candidate}}
+template  struct A1 {}; // expected-error 0-1{{C++11}}
+template  struct A2 {}; // expected-error 0-1{{C++11}}
+template  void e1(A1) = delete; // expected-error 0-2{{C++11}}
+template  void e1(A1);
+template  void e2(A2) = delete; // expected-error 0-2{{C++11}}
+template  void e2(A2);
+template  void f(U, A1 *p = 0) = delete; // expected-note {{candidate}} expected-error 0-1{{C++11}}
+template  int &f(U, A1 *p = 0); // expected-note {{candidate}}
 template  void g(T, T = T()); // expected-note {{candidate}}
 template  void g(T, U...); // expected-note {{candidate}} expected-error 0-1{{C++11}}
 void h() {
-  int &r = f(42, (A *)0);
+  A1 a;
+  int &r = f(42, &a);
+  A1 b1;
+  e1(b1);
+  A2 b2;
+  e2(b2);
   f(42); // expected-error {{ambiguous}}
   g(42); // expected-error {{ambiguous}}
 }
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -5222,6 +5222,39 @@
   return FT1;
   }
 
+  // This a speculative fix for CWG1432 (Similar to the fix for CWG1395) that
+  // there is no wording or even resolution for this issue.
+  bool ClangABICompat15 =
+  Context.getLangOpts().getClangABICompat() <= LangOptions::ClangABI::Ver15;
+  if (!ClangABICompat15) {
+for (int i = 0, e = std::min(NumParams1, NumParams2); i < e; ++i) {
+  QualType T1 = FD1->getParamDecl(i)->getType().getCanonicalType();
+  QualType T2 = FD2->getParamDecl(i)->getType().getCanonicalType();
+  auto *TST1 = dyn_cast(T1);
+  auto *TST2 = dyn_cast(T2);
+  if (!TST1 || !TST2)
+continue;
+  const TemplateArgument &TA1 = TST1->template_arguments().back();
+  if (TA1.getKind() == TemplateArgument::Pack) {
+assert(TST1->getNumArgs() == TST2->getNumArgs());
+const TemplateArgument &TA2 = TST2->template_arguments().back();
+assert(TA2.getKind() == TemplateArgument::Pack);
+unsigned PackSize1 = TA1.pack_size();
+unsigned PackSize2 = TA2.pack_size();
+bool IsPackExpansion1 =
+PackSize1 && TA1.pack_elements().back().isPackExpansion();
+bool IsPackExpansion2 =
+PackSize2 && TA2.pack_elements().back().isPackExpansion();
+if (PackSize1 != PackSize2 && IsPackExpansion1 != IsPackExpansion2) {
+  if (PackSize1 > PackSize2 && IsPackExpansion1)
+return FT2;
+  if (PackSize1 < PackSize2 && IsPackExpansion2)
+return FT1;
+}
+  }
+}
+  }
+
   return JudgeByConstraints();
 }
 
@@ -5457,30 +5490,29 @@
 return nullptr;
 
   if (Better1 && Better2) {
+// This a speculative fix for CWG1432 (Similar to the fix for CWG1395) that
+// there is no wording or even resolution for this issue.
 bool ClangABICompat15 = S.Context.getLangOpts().getClangABICompat() <=
 LangOptions::ClangABI::Ver15;
 if (!ClangABICompat15) {
-  // Consider this a fix for CWG1432. Similar to the fix for CWG1395.
-  auto *TST1 = T1->castAs();
-  auto *TST2 = T2->castAs();
-  if (TST1->getNumArgs()) {
-const TemplateArgument &TA1 = TST1->template_arguments().back();
-if (TA1.getKind() == TemplateArgument::Pack) {
-  assert(TST1->getNumArgs() == TST2->getNumArgs());
-  const Templ

[PATCH] D131858: [clang] Track the templated entity in type substitution.

2022-09-27 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

In D131858#3817750 , @davrec wrote:

> Question was referring to @ChuanqiXu 's comment about this patch breaking 
> modules for function importing, see his repro (which I haven't looked at 
> closely).  I was asking if this meant that classes were already broken in a 
> similar way, since you said this patch brings them into consistency.

No, I haven't had time to investigate that test case, as right now I am 
advancing in other parts of the stack.

But what I meant was that importing classes was already a case where the 
template parts could be accessed before the whole class was imported, and the 
existing code was already importing the template bits first to cope with that. 
The changes in this patch align the other cases to align with the need to 
import template parts first.

> I think we misunderstand each other again, but are you saying the breakage 
> found by @ChuanqiXu does not need to be fixed because it is out of scope?  
> (If classes are already broken due to this issue, the argument might have 
> some validity.)

No, fixing that breakage is in scope.

What I mean is out of scope is a major refactoring that would change how 
objects are deserialized, so that they are not accessed while they are part way 
there.
This, or a subset thereof, is what @ChuanqiXu was referring to, which would 
take about two months to implement.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131858

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


[PATCH] D86049: RFC: Implement optional exportable wrapper function generation for objc_direct methods.

2022-09-27 Thread Michael Wyman via Phabricator via cfe-commits
mwyman added a comment.

I think it's reasonable to do `@property` behavior in a follow-up.

Are we thinking to allow `__attribute__((visibility("default")))` on an 
`@property` declaration, to keep the visibility behavior consistent?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86049

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


[PATCH] D134337: [clang] [Driver] More flexible rules for loading default configs (WIP)

2022-09-27 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 463288.
mgorny added a comment.

Added doc update. Would use some help with release notes.


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

https://reviews.llvm.org/D134337

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Driver/Driver.h
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/config-file3.c

Index: clang/test/Driver/config-file3.c
===
--- clang/test/Driver/config-file3.c
+++ clang/test/Driver/config-file3.c
@@ -14,107 +14,261 @@
 // CHECK-REL: Configuration file: {{.*}}/workdir/cfg-1
 // CHECK-REL: -Wundefined-var-template
 
+//--- Config files are searched for in binary directory as well.
+//
+// RUN: mkdir %t/testbin
+// RUN: ln -s %clang %t/testbin/clang
+// RUN: echo "-Werror" > %t/testbin/aaa.cfg
+// RUN: %t/testbin/clang --config-system-dir= --config-user-dir= --config aaa.cfg -c -no-canonical-prefixes -### %s 2>&1 | FileCheck %s -check-prefix CHECK-BIN
+//
+// CHECK-BIN: Configuration file: {{.*}}/testbin/aaa.cfg
+// CHECK-BIN: -Werror
 
-//--- Invocation qqq-clang-g++ tries to find config file qqq-clang-g++.cfg first.
+//--- Invocation x86_64-unknown-linux-gnu-clang-g++ tries x86_64-unknown-linux-gnu-clang++.cfg first.
 //
 // RUN: mkdir %t/testdmode
-// RUN: ln -s %clang %t/testdmode/qqq-clang-g++
-// RUN: echo "-Wundefined-func-template" > %t/testdmode/qqq-clang-g++.cfg
-// RUN: echo "-Werror" > %t/testdmode/qqq.cfg
-// RUN: %t/testdmode/qqq-clang-g++ --config-system-dir= --config-user-dir= -c -no-canonical-prefixes -### %s 2>&1 | FileCheck %s -check-prefix FULL-NAME
+// RUN: ln -s %clang %t/testdmode/i386-unknown-linux-gnu-clang-g++
+// RUN: ln -s %clang %t/testdmode/x86_64-unknown-linux-gnu-clang-g++
+// RUN: ln -s %clang %t/testdmode/x86_64-unknown-linux-gnu-clang
+// RUN: echo > %t/testdmode/x86_64-unknown-linux-gnu-clang++.cfg
+// RUN: echo > %t/testdmode/x86_64-unknown-linux-gnu-clang-g++.cfg
+// RUN: echo > %t/testdmode/x86_64-unknown-linux-gnu-clang.cfg
+// RUN: echo > %t/testdmode/x86_64-unknown-linux-gnu.cfg
+// RUN: echo > %t/testdmode/i386-unknown-linux-gnu-clang++.cfg
+// RUN: echo > %t/testdmode/i386-unknown-linux-gnu-clang-g++.cfg
+// RUN: echo > %t/testdmode/i386-unknown-linux-gnu-clang.cfg
+// RUN: echo > %t/testdmode/i386-unknown-linux-gnu.cfg
+// RUN: echo > %t/testdmode/clang++.cfg
+// RUN: echo > %t/testdmode/clang-g++.cfg
+// RUN: echo > %t/testdmode/clang.cfg
+// RUN: %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1
 //
-// FULL-NAME: Configuration file: {{.*}}/testdmode/qqq-clang-g++.cfg
-// FULL-NAME: -Wundefined-func-template
-// FULL-NAME-NOT: -Werror
+// FULL1: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu-clang++.cfg
+// FULL1-NOT: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu-clang-g++.cfg
+// FULL1-NOT: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu-clang.cfg
+// FULL1-NOT: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu.cfg
+// FULL1-NOT: Configuration file: {{.*}}/testdmode/i386-unknown-linux-gnu-clang++.cfg
+// FULL1-NOT: Configuration file: {{.*}}/testdmode/i386-unknown-linux-gnu-clang-g++.cfg
+// FULL1-NOT: Configuration file: {{.*}}/testdmode/i386-unknown-linux-gnu-clang.cfg
+// FULL1-NOT: Configuration file: {{.*}}/testdmode/i386-unknown-linux-gnu.cfg
+// FULL1-NOT: Configuration file: {{.*}}/testdmode/clang++.cfg
+// FULL1-NOT: Configuration file: {{.*}}/testdmode/clang-g++.cfg
+// FULL1-NOT: Configuration file: {{.*}}/testdmode/clang.cfg
+
+//--- -m32 overrides triple.
 //
-//--- Invocation qqq-clang-g++ tries to find config file qqq-clang-g++.cfg even without -no-canonical-prefixes.
-// (As the clang executable and symlink are in different directories, this
-// requires specifying the path via --config-*-dir= though.)
+// RUN: %t/testdmode/x86_64-unknown-linux-gnu-clang-g++ -m32 --config-system-dir= --config-user-dir= -no-canonical-prefixes --version 2>&1 | FileCheck %s -check-prefix FULL1-I386
 //
-// RUN: %t/testdmode/qqq-clang-g++ --config-system-dir= --config-user-dir=%t/testdmode -c -### %s 2>&1 | FileCheck %s -check-prefix SYMLINK
+// FULL1-I386-NOT: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu-clang++.cfg
+// FULL1-I386-NOT: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu-clang-g++.cfg
+// FULL1-I386-NOT: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu-clang.cfg
+// FULL1-I386-NOT: Configuration file: {{.*}}/testdmode/x86_64-unknown-linux-gnu.cfg
+// FULL1-I386: Configuration file: {{.*}}/testdmode/i386-unknown-linux-gnu-clang++.cfg
+// FULL1-I386-NOT: Configuration file: {{.*}}/testdmode/i386-unknown-linux-gnu-clang-g++.cfg
+// FULL1-I386-NOT: Configuration file: {{.*}}/testdmode/i386-unknown-linux-gnu-clang.cfg
+// FULL1-I386-NOT: Configuration file: {{.*}}/testdmode/i386-unknown-linux-gnu.cfg

[PATCH] D133683: [c++] implements tentative DR1432 for partial ordering of function template

2022-09-27 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D133683#3817523 , @mizvekov wrote:

> - Missing release notes.

I didn't add that because this patch is logically part of D128745 
 which has a release note already.

> - FWIW GCC treats the `g(42)` case as not ambiguous, as I expected, so it 
> might be worth pointing that out with a FIXME regardless.

I think GCC is the one that is not conforming. MSVC agrees it is ambiguous 
(https://godbolt.org/z/T5zbxaTYq). Basically, only the first parameter is 
considered for partial ordering. 
(https://eel.is/c++draft/temp.deduct.partial#3.1)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133683

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


[PATCH] D134507: [Clang] add missing ClangABICompat check

2022-09-27 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D134507#3817928 , @probinson wrote:

> It feels odd to use a ClangABI check for something that is affecting what 
> source is accepted, but this is not my area of expertise.
> @aaron.ballman or @rjmccall would probably be the right people to weigh in on 
> this.

This was discussed here https://reviews.llvm.org/D128745#inline-1244757. Yeah, 
it is somewhat confusing to key the legacy language behavior on ClangABI. I'm 
not sure there are better choices than inventing new flags.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134507

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


[PATCH] D126481: [analyzer] Handle SymbolCast in SValBuilder

2022-09-27 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

Yeah okay. I get it now.  Thank you for your patience and your time on 
elaborating the issue.

First, I think we'd need to fabricate a test case that shows us the bug even 
without applying your patch (D103096 ).

Then we can iterate onto the solution. What we could do is to collect the 
constants and types on the way of the cast visitation and then apply the same 
logic that you have in D103096 . But then 
there is an open question: what should we do if there is another kind of symbol 
in the chain of SymbolCasts? E.g SymbolCast, UnarySymExpr, SymbolCast.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126481

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


[PATCH] D134702: [Clang] Don't warn if deferencing void pointers in unevaluated context

2022-09-27 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers accepted this revision.
nickdesaulniers added a comment.
This revision is now accepted and ready to land.

Thanks for the quick fix!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134702

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


[PATCH] D133683: [c++] implements tentative DR1432 for partial ordering of function template

2022-09-27 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

In D133683#3818752 , @ychen wrote:

> I didn't add that because this patch is logically part of D128745 
>  which has a release note already.

Okay, I see that the existing release note entry talks just about implementing 
those DRs without going specific, so that is fine.
It does not mention that DR1432 implementation is tentative as there is no 
published resolution though.

> I think GCC is the one that is not conforming. MSVC agrees it is ambiguous 
> (https://godbolt.org/z/T5zbxaTYq). Basically, only the first parameter is 
> considered for partial ordering. 
> (https://eel.is/c++draft/temp.deduct.partial#3.1)

I could totally buy that the GCC behavior is accidental, but it does make 
sense, with the idea behind DR1432, that we should prefer the first overload 
because that deduction is simpler, or because it does not deduce a parameter 
pack.

If there was a resolution, the answer here would be clear cut, but since there 
isn't, we are making up our own rules and getting into a language design 
discussion.
If you don't think that is clear cut, it's fine, we can move this discussion 
elsewhere :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133683

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


[PATCH] D134507: [Clang] add missing ClangABICompat check

2022-09-27 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I don't think I agree that changes to template partial ordering rules are 
"ABI-breaking changes".  They're breaking changes to *language semantics*, and 
the ABI break is downstream of that, just like any other semantic change to 
overload resolution would be.  I think the right approach for Clang is to gate 
this by language version and add a note somewhere that C++23 changed the 
overload resolution rules around function templates and that this means 
adopting C++23 can be ABI-breaking.  Fortunately, it should only be 
ABI-breaking in rare circumstances.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134507

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


  1   2   3   >