[clang] 09d6ee7 - [Clang] Directly create opaque pointers

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

Author: Nikita Popov
Date: 2023-06-15T09:09:33+02:00
New Revision: 09d6ee765780837d5156ac81f968465bdcec73ba

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

LOG: [Clang] Directly create opaque pointers

In CGTypes, directly create opaque pointers, without computing the
LLVM element type. This is not as straightforward as I though it
would be, because apparently computing the LLVM type also causes a
number of side effects.

In particular, we no longer produce diagnostics like -Wpacked for
typed (only) behind pointers, because we no longer depend on their
layout.

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

Added: 


Modified: 
clang/lib/CodeGen/CodeGenTypes.cpp
clang/test/CodeGenCXX/matrix-type-builtins.cpp
clang/test/CodeGenCXX/warn-all-padded-packed-packed-non-pod.cpp
clang/test/Modules/compare-record.c
clang/test/PCH/headersearch.cpp
clang/test/Sema/ms_class_layout.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenTypes.cpp 
b/clang/lib/CodeGen/CodeGenTypes.cpp
index 0ceab41cdd360..e4836c850a157 100644
--- a/clang/lib/CodeGen/CodeGenTypes.cpp
+++ b/clang/lib/CodeGen/CodeGenTypes.cpp
@@ -675,19 +675,15 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
   case Type::RValueReference: {
 const ReferenceType *RTy = cast(Ty);
 QualType ETy = RTy->getPointeeType();
-llvm::Type *PointeeType = ConvertTypeForMem(ETy);
 unsigned AS = getTargetAddressSpace(ETy);
-ResultType = llvm::PointerType::get(PointeeType, AS);
+ResultType = llvm::PointerType::get(getLLVMContext(), AS);
 break;
   }
   case Type::Pointer: {
 const PointerType *PTy = cast(Ty);
 QualType ETy = PTy->getPointeeType();
-llvm::Type *PointeeType = ConvertTypeForMem(ETy);
-if (PointeeType->isVoidTy())
-  PointeeType = llvm::Type::getInt8Ty(getLLVMContext());
 unsigned AS = getTargetAddressSpace(ETy);
-ResultType = llvm::PointerType::get(PointeeType, AS);
+ResultType = llvm::PointerType::get(getLLVMContext(), AS);
 break;
   }
 
@@ -764,15 +760,9 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
 break;
   }
 
-  case Type::ObjCObjectPointer: {
-// Protocol qualifications do not influence the LLVM type, we just return a
-// pointer to the underlying interface type. We don't need to worry about
-// recursive conversion.
-llvm::Type *T =
-  ConvertTypeForMem(cast(Ty)->getPointeeType());
-ResultType = T->getPointerTo();
+  case Type::ObjCObjectPointer:
+ResultType = llvm::PointerType::getUnqual(getLLVMContext());
 break;
-  }
 
   case Type::Enum: {
 const EnumDecl *ED = cast(Ty)->getDecl();
@@ -786,18 +776,15 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
   }
 
   case Type::BlockPointer: {
-const QualType FTy = cast(Ty)->getPointeeType();
-llvm::Type *PointeeType = CGM.getLangOpts().OpenCL
-  ? CGM.getGenericBlockLiteralType()
-  : ConvertTypeForMem(FTy);
 // Block pointers lower to function type. For function type,
 // getTargetAddressSpace() returns default address space for
 // function pointer i.e. program address space. Therefore, for block
 // pointers, it is important to pass the pointee AST address space when
 // calling getTargetAddressSpace(), to ensure that we get the LLVM IR
 // address space for data pointers and not function pointers.
+const QualType FTy = cast(Ty)->getPointeeType();
 unsigned AS = Context.getTargetAddressSpace(FTy.getAddressSpace());
-ResultType = llvm::PointerType::get(PointeeType, AS);
+ResultType = llvm::PointerType::get(getLLVMContext(), AS);
 break;
   }
 

diff  --git a/clang/test/CodeGenCXX/matrix-type-builtins.cpp 
b/clang/test/CodeGenCXX/matrix-type-builtins.cpp
index 24bf797ab94a0..732fe1a18db3b 100644
--- a/clang/test/CodeGenCXX/matrix-type-builtins.cpp
+++ b/clang/test/CodeGenCXX/matrix-type-builtins.cpp
@@ -31,20 +31,20 @@ void test_transpose_template1() {
 
 void test_transpose_template2(MyMatrix &M) {
   // CHECK-LABEL: define{{.*}} void 
@_Z24test_transpose_template2R8MyMatrixIdLj7ELj6EE(
-  // CHECK: call void 
@_Z9transposeIdLj7ELj6EE8MyMatrixIT_XT1_EXT0_EERKS0_IS1_XT0_EXT1_EE(ptr 
sret(%struct.MyMatrix.2) align 8 %ref.tmp1, ptr noundef nonnull align 8 
dereferenceable(336) %0)
-  // CHECK-NEXT:call void 
@_Z9transposeIdLj6ELj7EE8MyMatrixIT_XT1_EXT0_EERKS0_IS1_XT0_EXT1_EE(ptr 
sret(%struct.MyMatrix.1) align 8 %ref.tmp, ptr noundef nonnull align 8 
dereferenceable(336) %ref.tmp1)
-  // CHECK-NEXT:call void 
@_Z9transposeIdLj7ELj6EE8MyMatrixIT_XT1_EXT0_EERKS0_IS1_XT0_EXT1_EE(ptr 
sret(%struct.MyMatrix.2) align 8 %M2_t, ptr noundef nonnull align 8 
dereferenceable(336) %ref.tmp)
+  // CHE

[PATCH] D152505: [Clang] Directly create opaque pointers

2023-06-15 Thread Nikita Popov 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 rG09d6ee765780: [Clang] Directly create opaque pointers 
(authored by nikic).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152505

Files:
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/test/CodeGenCXX/matrix-type-builtins.cpp
  clang/test/CodeGenCXX/warn-all-padded-packed-packed-non-pod.cpp
  clang/test/Modules/compare-record.c
  clang/test/PCH/headersearch.cpp
  clang/test/Sema/ms_class_layout.cpp

Index: clang/test/Sema/ms_class_layout.cpp
===
--- clang/test/Sema/ms_class_layout.cpp
+++ clang/test/Sema/ms_class_layout.cpp
@@ -147,16 +147,16 @@
   // This avoid "Can't yet mangle constructors!" for MS ABI.
   C* c;
   c->foo();
-  DerivedStruct* v;
-  H* g;
+  DerivedStruct v;
+  H g;
   BaseStruct* u;
-  I* i;
-  N* n;
-  O* o;
-  P* p;
-  R* r;
-  sd *h;
-  EV *j;
+  I i;
+  N n;
+  O o;
+  P p;
+  R r;
+  sd h;
+  EV j;
   return 0;
 }
 
@@ -206,15 +206,6 @@
 // CHECK-NEXT: sizeof=80, align=8
 // CHECK-NEXT: nvsize=64, nvalign=8
 
-// CHECK: %class.D = type { ptr, double }
-
-// CHECK: %class.B = type { ptr, i32 }
-
-// CHECK: %class.A = type { %class.B, i32, i8 }
-
-// CHECK: %class.C = type { %class.D, %class.B, ptr, double, i32, double, i32, [4 x i8], %class.A }
-// CHECK: %class.C.base = type { %class.D, %class.B, ptr, double, i32, double, i32 }
-
 // CHECK-LABEL: 0 | struct BaseStruct{{$}}
 // CHECK-NEXT:  0 |   double v0
 // CHECK-NEXT:  8 |   float v1
@@ -239,8 +230,6 @@
 // CHECK-NEXT: sizeof=96, align=8
 // CHECK-NEXT: nvsize=96, nvalign=8
 
-// CHECK: %struct.BaseStruct = type { double, float, %class.C }
-
 // CHECK-LABEL: 0 | struct DerivedStruct{{$}}
 // CHECK-NEXT:  0 |   struct BaseStruct (base)
 // CHECK-NEXT:  0 | double v0
@@ -267,8 +256,6 @@
 // CHECK-NEXT: sizeof=104, align=8
 // CHECK-NEXT: nvsize=104, nvalign=8
 
-// CHECK: %struct.DerivedStruct = type { %struct.BaseStruct, i32 }
-
 // CHECK-LABEL:0 | struct G
 // CHECK-NEXT: 0 |   int g_field
 // CHECK-NEXT: sizeof=4, align=4
@@ -284,8 +271,6 @@
 // CHECK-NEXT: sizeof=24, align=8
 // CHECK-NEXT: nvsize=8, nvalign=8
 
-// CHECK: %struct.H = type { %struct.G, ptr, %class.D }
-
 // CHECK-LABEL: 0 | struct I{{$}}
 // CHECK-NEXT:  0 |   (I vftable pointer)
 // CHECK-NEXT:  8 |   (I vbtable pointer)
@@ -296,9 +281,6 @@
 // CHECK-NEXT: sizeof=40, align=8
 // CHECK-NEXT: nvsize=24, nvalign=8
 
-// CHECK: %struct.I = type { ptr, [4 x i8], ptr, double, %class.D }
-// CHECK: %struct.I.base = type { ptr, [4 x i8], ptr, double }
-
 // CHECK-LABEL: 0 | struct L{{$}}
 // CHECK-NEXT:  0 |   int l
 // CHECK-NEXT: sizeof=4, align=4
@@ -316,9 +298,6 @@
 // CHECK-NEXT:  8 | int k
 // CHECK-NEXT: sizeof=12, align=4
 
-//CHECK: %struct.M = type { ptr, i32, %struct.K }
-//CHECK: %struct.M.base = type { ptr, i32 }
-
 // CHECK-LABEL: 0 | struct N{{$}}
 // CHECK-NEXT:  0 |   (N vftable pointer)
 // CHECK-NEXT:  4 |   struct L (base)
@@ -331,8 +310,6 @@
 // CHECK-NEXT: sizeof=20, align=4
 // CHECK-NEXT: nvsize=16, nvalign=4
 
-//CHECK: %struct.N = type { ptr, %struct.L, %struct.M.base, %struct.K }
-
 // CHECK-LABEL: 0 | struct O{{$}}
 // CHECK-NEXT:  0 |   (O vftable pointer)
 // CHECK-NEXT:  8 |   struct H (base)
@@ -347,9 +324,6 @@
 // CHECK-NEXT:| [sizeof=40, align=8
 // CHECK-NEXT:|  nvsize=24, nvalign=8]
 
-// CHECK: struct.O = type { ptr, [4 x i8], %struct.H.base, %struct.G, %class.D }
-// CHECK: struct.O.base = type { ptr, [4 x i8], %struct.H.base, %struct.G, [4 x i8] }
-
 // CHECK-LABEL: 0 | struct P{{$}}
 // CHECK-NEXT:  0 |   struct M (base)
 // CHECK-NEXT:  0 | (M vbtable pointer)
@@ -362,14 +336,10 @@
 // CHECK-NEXT: sizeof=20, align=4
 // CHECK-NEXT: nvsize=12, nvalign=4
 
-//CHECK: %struct.P = type { %struct.M.base, i32, %struct.K, %struct.L }
-
 // CHECK-LABEL: 0 | struct R (empty){{$}}
 // CHECK-NEXT:  sizeof=1, align=1
 // CHECK-NEXT:  nvsize=0, nvalign=1
 
-//CHECK: %struct.R = type { i8 }
-
 // CHECK-LABEL: 0 | struct f{{$}}
 // CHECK-NEXT:  0 |   (f vftable pointer)
 // CHECK-NEXT: sizeof=4, align=4
@@ -419,12 +389,6 @@
 // CHECK-NEXT: sizeof=48, align=4
 // CHECK-NEXT: nvsize=12, nvalign=4
 
-// CHECK: %struct.f = type { ptr }
-// CHECK: %struct.s = type { ptr, ptr, i32, i32, %struct.f }
-// CHECK: %class.IA = type { ptr }
-// CHECK: %class.ICh = type { ptr, ptr, i32, %class.IA }
-// CHECK: %struct.sd = type { ptr, i32, i8, i32, %struct.f, %struct.s.base, i32, %class.IA, %class.ICh.base }
-
 // CHECK-LABEL: 0 | struct AV{{$}}
 // CHECK-NEXT:  0 |   (AV vftable pointer)
 // CHECK-NEXT: sizeof=4, align=4
@@ -445,11 +409,6 @@
 // CHECK-NEXT: sizeof=12, align=4
 // CHECK-NEXT: nvsize=4, nvalign=4
 
-// CHECK: %struct.AV = type { ptr }
-// CHECK: %struct.BV = ty

[PATCH] D129635: [OpenMP] Update the default version of OpenMP to 5.1

2023-06-15 Thread Animesh Kumar 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 rG0c6f2f629cc0: [OpenMP] Update the default version of OpenMP 
to 5.1 (authored by animeshk-amd).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129635

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/AST/ast-dump-openmp-task.c
  clang/test/Analysis/cfg-openmp.cpp
  clang/test/Index/openmp-tile.c
  clang/test/OpenMP/align_clause_ast_print.cpp
  clang/test/OpenMP/align_clause_codegen.cpp
  clang/test/OpenMP/align_clause_global_codegen.cpp
  clang/test/OpenMP/align_clause_messages.cpp
  clang/test/OpenMP/allocate_codegen_attr.cpp
  clang/test/OpenMP/assumes_messages_attr.c
  clang/test/OpenMP/atomic_ast_print.cpp
  clang/test/OpenMP/atomic_capture_codegen.cpp
  clang/test/OpenMP/atomic_compare_codegen.cpp
  clang/test/OpenMP/atomic_messages.c
  clang/test/OpenMP/atomic_messages.cpp
  clang/test/OpenMP/begin_declare_variant_messages.c
  clang/test/OpenMP/critical_codegen_attr.cpp
  clang/test/OpenMP/declare_mapper_ast_print.c
  clang/test/OpenMP/declare_mapper_codegen.cpp
  clang/test/OpenMP/declare_mapper_messages.c
  clang/test/OpenMP/declare_mapper_messages.cpp
  clang/test/OpenMP/declare_target_ast_print.cpp
  clang/test/OpenMP/declare_target_messages.cpp
  clang/test/OpenMP/declare_variant_clauses_ast_print.c
  clang/test/OpenMP/declare_variant_clauses_ast_print.cpp
  clang/test/OpenMP/declare_variant_clauses_messages.cpp
  clang/test/OpenMP/declare_variant_construct_codegen_1.c
  clang/test/OpenMP/declare_variant_messages.c
  clang/test/OpenMP/declare_variant_messages.cpp
  clang/test/OpenMP/default_firstprivate_ast_print.cpp
  clang/test/OpenMP/default_private_ast_print.cpp
  clang/test/OpenMP/depobj_messages.cpp
  clang/test/OpenMP/dispatch_ast_print.cpp
  clang/test/OpenMP/distribute_parallel_for_default_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_proc_bind_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_default_messages.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_misc_messages.c
  clang/test/OpenMP/distribute_parallel_for_simd_proc_bind_messages.cpp
  clang/test/OpenMP/distribute_simd_misc_messages.c
  clang/test/OpenMP/driver.c
  clang/test/OpenMP/flush_ast_print.cpp
  clang/test/OpenMP/flush_messages.cpp
  clang/test/OpenMP/for_codegen.cpp
  clang/test/OpenMP/for_misc_messages.c
  clang/test/OpenMP/for_order_messages.cpp
  clang/test/OpenMP/for_simd_misc_messages.c
  clang/test/OpenMP/generic_loop_ast_print.cpp
  clang/test/OpenMP/generic_loop_messages.cpp
  clang/test/OpenMP/interop_ast_print.cpp
  clang/test/OpenMP/irbuilder_for_iterator.cpp
  clang/test/OpenMP/irbuilder_for_rangefor.cpp
  clang/test/OpenMP/irbuilder_unroll_full.c
  clang/test/OpenMP/irbuilder_unroll_heuristic.c
  clang/test/OpenMP/irbuilder_unroll_partial_factor.c
  clang/test/OpenMP/irbuilder_unroll_partial_factor_for.c
  clang/test/OpenMP/irbuilder_unroll_partial_factor_for_collapse.c
  clang/test/OpenMP/irbuilder_unroll_partial_heuristic.c
  clang/test/OpenMP/irbuilder_unroll_partial_heuristic_constant_for.c
  clang/test/OpenMP/irbuilder_unroll_partial_heuristic_for_collapse.c
  clang/test/OpenMP/irbuilder_unroll_partial_heuristic_runtime_for.c
  clang/test/OpenMP/irbuilder_unroll_unroll_partial_factor.c
  clang/test/OpenMP/irbuilder_unroll_unroll_partial_heuristic.c
  clang/test/OpenMP/masked_ast_print.cpp
  clang/test/OpenMP/masked_codegen.cpp
  clang/test/OpenMP/masked_messages_attr.cpp
  clang/test/OpenMP/masked_taskloop_simd_ast_print.cpp
  clang/test/OpenMP/master_taskloop_simd_ast_print.cpp
  clang/test/OpenMP/openmp_attribute.cpp
  clang/test/OpenMP/openmp_attribute_compat.cpp
  clang/test/OpenMP/openmp_attribute_parsing.cpp
  clang/test/OpenMP/parallel_ast_print.cpp
  clang/test/OpenMP/parallel_default_messages.cpp
  clang/test/OpenMP/parallel_for_default_messages.cpp
  clang/test/OpenMP/parallel_for_messages.cpp
  clang/test/OpenMP/parallel_for_proc_bind_messages.cpp
  clang/test/OpenMP/parallel_for_simd_default_messages.cpp
  clang/test/OpenMP/parallel_for_simd_misc_messages.c
  clang/test/OpenMP/parallel_for_simd_proc_bind_messages.cpp
  clang/test/OpenMP/parallel_generic_loop_ast_print.cpp
  clang/test/OpenMP/parallel_generic_loop_messages.cpp
  clang/test/OpenMP/parallel_masked_default_messages.cpp
  clang/test/OpenMP/parallel_masked_proc_bind_messages.cpp
  clang/test/OpenMP/parallel_masked_taskloop_simd_ast_print.cpp
  clang/test/OpenMP/parallel_masked_taskloop_simd_lastprivate_messages.cpp
  clang/test/OpenMP/parallel_masked_taskloop_simd_loop_messages.cpp
  clang/test/OpenMP/parallel_masked_taskloop_simd_reduction_messages.cpp
  clang/test/OpenMP/parallel_master_codegen.cpp
  clang/test/OpenMP/parallel_master_default_messages.cpp

[PATCH] D152995: Remove clang/ModuleInfo.txt

2023-06-15 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld created this revision.
Hahnfeld added reviewers: rsmith, aaron.ballman.
Herald added a project: All.
Hahnfeld requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The script `build-for-llvm-top.sh` and LLVM's `ModuleInfo.txt` are gone since a 
long time (commit rGd20ea7dc59 
 in 
November 2011), and `llvm-top` itself has even been removed from llvm-archive 
(it can be found here: 
https://github.com/llvm/llvm-archive/tree/cab7f8f160f0bd8d20d9a4036aa4083f2bc2740a/llvm-top)
 so delete Clang's `ModuleInfo.txt` as well.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152995

Files:
  clang/ModuleInfo.txt


Index: clang/ModuleInfo.txt
===
--- clang/ModuleInfo.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-# This file provides information for llvm-top
-DepModule: llvm 
-ConfigCmd:
-ConfigTest:
-BuildCmd:


Index: clang/ModuleInfo.txt
===
--- clang/ModuleInfo.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-# This file provides information for llvm-top
-DepModule: llvm 
-ConfigCmd:
-ConfigTest:
-BuildCmd:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D152995: Remove clang/ModuleInfo.txt

2023-06-15 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

Just checking to be sure there is no other use case that the file is used for, 
but I doubt it...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152995

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


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

2023-06-15 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD created this revision.
Herald added subscribers: jobnoorman, luke, VincentWu, vkmr, frasercrmck, 
luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, 
PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, 
shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, 
hiraditya, arichardson.
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.

Depends on D152889 .

Additional data member is added under RISCVInstrFormats to distinguish
between vector fixed-point and vector floating-point instructions.
Additional data member is added under RVVIntrinsic to distinguish vfadd
with rounding mode control operand.

The value to indicate no rounding mode control is changed from 4 to 99.
As frm has a value range of [0, 4].


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152996

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/include/clang/Basic/riscv_vector_common.td
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Sema/SemaRISCVVectorLookup.cpp
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  clang/utils/TableGen/RISCVVEmitter.cpp
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
  llvm/lib/Target/RISCV/RISCVInsertReadWriteCSR.cpp
  llvm/lib/Target/RISCV/RISCVInstrFormats.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td

Index: llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
===
--- llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
+++ llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
@@ -611,7 +611,9 @@
op1_reg_class:$rs1,
op2_reg_class:$rs2,
(mask_type V0),
-   (XLenVT 4), // vxrm value for RISCVInertReadWriteCSR
+   // Value to indicate no rounding mode change in
+   // RISCVInertReadWriteCSR
+   (XLenVT 99),
GPR:$vl, log2sew, TAIL_AGNOSTIC)>;
 
 
@@ -706,7 +708,9 @@
vop_reg_class:$rs1,
xop_kind:$rs2,
(mask_type V0),
-   (XLenVT 4), // vxrm value for RISCVInertReadWriteCSR
+   // Value to indicate no rounding mode change in
+   // RISCVInertReadWriteCSR
+   (XLenVT 99),
GPR:$vl, log2sew, TAIL_AGNOSTIC)>;
 
 
@@ -861,6 +865,36 @@
scalar_reg_class:$rs2,
(mask_type V0), GPR:$vl, log2sew, TAIL_AGNOSTIC)>;
 
+class VPatBinaryVL_VF_RM
+: Pat<(result_type (vop (vop1_type vop_reg_class:$rs1),
+   (vop2_type (SplatFPOp scalar_reg_class:$rs2)),
+   (result_type result_reg_class:$merge),
+   (mask_type V0),
+   VLOpFrag)),
+  (!cast(
+   !if(isSEWAware,
+   instruction_name#"_"#vlmul.MX#"_E"#!shl(1, log2sew)#"_MASK",
+   instruction_name#"_"#vlmul.MX#"_MASK"))
+   result_reg_class:$merge,
+   vop_reg_class:$rs1,
+   scalar_reg_class:$rs2,
+   (mask_type V0),
+   // Value to indicate no rounding mode change in
+   // RISCVInertReadWriteCSR
+   (XLenVT 99),
+   GPR:$vl, log2sew, TAIL_AGNOSTIC)>;
+
 multiclass VPatBinaryFPVL_VV_VF {
   foreach vti = AllFloatVectors in {
@@ -877,6 +911,22 @@
   }
 }
 
+multiclass VPatBinaryFPVL_VV_VF_RM {
+  foreach vti = AllFloatVectors in {
+let Predicates = GetVTypePredicates.Predicates in {
+  def : VPatBinaryVL_V_RM;
+  def : VPatBinaryVL_VF_RM;
+  }
+  }
+}
+
 multiclass VPatBinaryFPVL_R_VF {
   foreach fvti = AllFloatVectors in {
@@ -1897,7 +1947,7 @@
 // 13. Vector Floating-Point Instructions
 
 // 13.2. Vector Single-Width Floating-Point Add/Subtract Instructions
-defm : VPatBinaryFPVL_VV_VF;
+defm : VPatBinaryFPVL_VV_VF_RM;
 defm : VPatBinaryFPVL_VV_VF;
 defm : VPatBinaryFPVL_R_VF;
 
Index: llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td
===
--- llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td
+++ llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td
@@ -110,7 +110,9 @@
  instruction_name#"_VV_"# vlmul.MX))
  op_reg_class:$rs1,
  op_reg_class:$rs2,
- (XLenVT 4), // vxrm value for RISCVInertReadWriteCSR
+ // Value to indicate no rounding mode change in
+ // RISCVInertReadWriteCSR
+ (

[clang] b92ccc3 - [CGCall] Directly create opaque pointers (NFCI)

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

Author: Nikita Popov
Date: 2023-06-15T10:06:40+02:00
New Revision: b92ccc355acb8a329918ceb2837df1b351675ece

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

LOG: [CGCall] Directly create opaque pointers (NFCI)

Added: 


Modified: 
clang/lib/CodeGen/CGCall.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 8bb8e2bb3969e..71268d9abcbda 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -1637,9 +1637,8 @@ CodeGenTypes::GetFunctionType(const CGFunctionInfo &FI) {
 if (retAI.getInAllocaSRet()) {
   // sret things on win32 aren't void, they return the sret pointer.
   QualType ret = FI.getReturnType();
-  llvm::Type *ty = ConvertType(ret);
   unsigned addressSpace = CGM.getTypes().getTargetAddressSpace(ret);
-  resultType = llvm::PointerType::get(ty, addressSpace);
+  resultType = llvm::PointerType::get(getLLVMContext(), addressSpace);
 } else {
   resultType = llvm::Type::getVoidTy(getLLVMContext());
 }
@@ -1661,17 +1660,17 @@ CodeGenTypes::GetFunctionType(const CGFunctionInfo &FI) 
{
   // Add type for sret argument.
   if (IRFunctionArgs.hasSRetArg()) {
 QualType Ret = FI.getReturnType();
-llvm::Type *Ty = ConvertType(Ret);
 unsigned AddressSpace = CGM.getTypes().getTargetAddressSpace(Ret);
 ArgTypes[IRFunctionArgs.getSRetArgNo()] =
-llvm::PointerType::get(Ty, AddressSpace);
+llvm::PointerType::get(getLLVMContext(), AddressSpace);
   }
 
   // Add type for inalloca argument.
   if (IRFunctionArgs.hasInallocaArg()) {
 auto ArgStruct = FI.getArgStruct();
 assert(ArgStruct);
-ArgTypes[IRFunctionArgs.getInallocaArgNo()] = ArgStruct->getPointerTo();
+ArgTypes[IRFunctionArgs.getInallocaArgNo()] =
+llvm::PointerType::getUnqual(getLLVMContext());
   }
 
   // Add in all of the required arguments.
@@ -1695,20 +1694,17 @@ CodeGenTypes::GetFunctionType(const CGFunctionInfo &FI) 
{
   assert(NumIRArgs == 0);
   break;
 
-case ABIArgInfo::Indirect: {
+case ABIArgInfo::Indirect:
   assert(NumIRArgs == 1);
   // indirect arguments are always on the stack, which is alloca addr 
space.
-  llvm::Type *LTy = ConvertTypeForMem(it->type);
-  ArgTypes[FirstIRArg] = LTy->getPointerTo(
-  CGM.getDataLayout().getAllocaAddrSpace());
+  ArgTypes[FirstIRArg] = llvm::PointerType::get(
+  getLLVMContext(), CGM.getDataLayout().getAllocaAddrSpace());
   break;
-}
-case ABIArgInfo::IndirectAliased: {
+case ABIArgInfo::IndirectAliased:
   assert(NumIRArgs == 1);
-  llvm::Type *LTy = ConvertTypeForMem(it->type);
-  ArgTypes[FirstIRArg] = LTy->getPointerTo(ArgInfo.getIndirectAddrSpace());
+  ArgTypes[FirstIRArg] = llvm::PointerType::get(
+  getLLVMContext(), ArgInfo.getIndirectAddrSpace());
   break;
-}
 case ABIArgInfo::Extend:
 case ABIArgInfo::Direct: {
   // Fast-isel and the optimizer generally like scalar values better than
@@ -2861,13 +2857,10 @@ void CodeGenFunction::EmitFunctionProlog(const 
CGFunctionInfo &FI,
   // If we're using inalloca, all the memory arguments are GEPs off of the last
   // parameter, which is a pointer to the complete memory area.
   Address ArgStruct = Address::invalid();
-  if (IRFunctionArgs.hasInallocaArg()) {
+  if (IRFunctionArgs.hasInallocaArg())
 ArgStruct = Address(Fn->getArg(IRFunctionArgs.getInallocaArgNo()),
 FI.getArgStruct(), FI.getArgStructAlignment());
 
-assert(ArgStruct.getType() == FI.getArgStruct()->getPointerTo());
-  }
-
   // Name the struct return parameter.
   if (IRFunctionArgs.hasSRetArg()) {
 auto AI = Fn->getArg(IRFunctionArgs.getSRetArgNo());
@@ -3933,8 +3926,8 @@ static AggValueSlot createPlaceholderSlot(CodeGenFunction 
&CGF,
   // FIXME: Generate IR in one pass, rather than going back and fixing up these
   // placeholders.
   llvm::Type *IRTy = CGF.ConvertTypeForMem(Ty);
-  llvm::Type *IRPtrTy = IRTy->getPointerTo();
-  llvm::Value *Placeholder = llvm::PoisonValue::get(IRPtrTy->getPointerTo());
+  llvm::Type *IRPtrTy = llvm::PointerType::getUnqual(CGF.getLLVMContext());
+  llvm::Value *Placeholder = llvm::PoisonValue::get(IRPtrTy);
 
   // FIXME: When we generate this IR in one pass, we shouldn't need
   // this win32-specific alignment hack.
@@ -5331,35 +5324,6 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo 
&CallInfo,
   // If we're using inalloca, set up that argument.
   if (ArgMemory.isValid()) {
 llvm::Value *Arg = ArgMemory.getPointer();
-if (CallInfo.isVariadic()) {
-  // When passing non-POD arguments by value to variadic functions, we will
-  // end up with a variadic prototype and an inalloca call

[PATCH] D152645: [clangd] Handle DependentNameType in HeuristicResolver::resolveTypeToRecordDecl()

2023-06-15 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/HeuristicResolver.cpp:33
 
+const Type *HeuristicResolver::resolveDeclsToType(
+const std::vector &Decls) const {

the reason to promote this utility function to a class method seems to be able 
to access the member field ASTContext. If so, I'd probably just passing the 
ASTContext as a parameter rather then making them member methods.



Comment at: clang-tools-extra/clangd/HeuristicResolver.cpp:38
+  if (const auto *TD = dyn_cast(Decls[0])) {
+return Ctx.getTypeDeclType(TD).getTypePtr();
+  }

nridge wrote:
> I wanted to call out the change on this line which is easy to overlook due to 
> the code move:
> 
> We were previously calling 
> [TypeDecl::getTypeForDecl()](https://searchfox.org/llvm/rev/5b657f50b8e8dc5836fb80e566ca7569fd04c26f/clang/include/clang/AST/Decl.h#3301),
>  but that's actually a low-level accessor for a cached value. The function 
> that also populates the value if needed is `ASTContext::getTypeDeclType()`, 
> hence I switch to using that.
thanks for the highlight, I think this change makes sense.



Comment at: clang-tools-extra/clangd/HeuristicResolver.cpp:56
+  if (const auto *DNT = T->getAs()) {
+T = resolveDeclsToType(resolveDependentNameType(DNT));
+if (!T)

Is the `resolveDeclsToType` call necessary here?  
The code path we're doing is `dependent-type => Decl* => Type => Decl*`, the 
later two steps seems redundant, can we just use the Decl result from 
`resolveDependentNameType()`?




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152645

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


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

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

Looks reasonable. Main note I have is that I think the use of getUnqual() over 
passing AddrSpace=0 would be preferred.




Comment at: clang/lib/CodeGen/CGAtomic.cpp:91
 auto Addr = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
-VoidPtrAddr, IntTy->getPointerTo(), "atomic_bitfield_base");
+VoidPtrAddr, llvm::PointerType::get(CGF.getLLVMContext(), 0),
+"atomic_bitfield_base");

getUnqual



Comment at: clang/lib/CodeGen/TargetInfo.cpp:2045
   if (IsIndirect)
-LLTy = LLTy->getPointerTo(0);
+LLTy = llvm::PointerType::get(getVMContext(), 0);
   FrameFields.push_back(LLTy);

getLLVMContext?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152321

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


[PATCH] D153001: [clang][ThreadSafety] Add __builtin_instance_member (WIP)

2023-06-15 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: aaronpuchert, NoQ, aaron.ballman.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

As discussed in https://github.com/llvm/llvm-project/issues/20777, this adds 
`__builtin_instance_member(membername)`, which acts like `this->membername`, 
but in C.

This is obviously very much WIP and the patch contains several placeholders, 
but I wonder if this is the right approach to take here and if I should 
continue on this path, so I'm opening this for review.

As you can see from the test case, this works for the (one) use case it was 
created for.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153001

Files:
  clang/include/clang/AST/EvaluatedExprVisitor.h
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Expr.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Analysis/ThreadSafetyCommon.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/Sema/warn-thread-safety-analysis.c

Index: clang/test/Sema/warn-thread-safety-analysis.c
===
--- clang/test/Sema/warn-thread-safety-analysis.c
+++ clang/test/Sema/warn-thread-safety-analysis.c
@@ -145,6 +145,24 @@
   return 0;
 }
 
+struct Holder {
+  struct Mutex *M;
+  int counter GUARDED_BY(__builtin_instance_member(M));
+};
+
+static void lock_holder(struct Holder *H) __attribute__((acquire_capability(H->M))) NO_THREAD_SAFETY_ANALYSIS {}
+static void unlock_holder(struct Holder *H) __attribute__((release_capability(H->M))) NO_THREAD_SAFETY_ANALYSIS {}
+
+static void test_holder(void) {
+  struct Holder H = {(void*)0, 0};
+
+  lock_holder(&H);
+  H.counter++;
+  unlock_holder(&H);
+
+  H.counter--; // expected-warning {{requires holding mutex 'H.M'}}
+}
+
 // We had a problem where we'd skip all attributes that follow a late-parsed
 // attribute in a single __attribute__.
 void run(void) __attribute__((guarded_by(mu1), guarded_by(mu1))); // expected-warning 2{{only applies to non-static data members and global variables}}
Index: clang/lib/Serialization/ASTWriterStmt.cpp
===
--- clang/lib/Serialization/ASTWriterStmt.cpp
+++ clang/lib/Serialization/ASTWriterStmt.cpp
@@ -747,6 +747,9 @@
   Code = serialization::EXPR_UNARY_OPERATOR;
 }
 
+void ASTStmtWriter::VisitBuiltinInstanceMemberExpr(
+BuiltinInstanceMemberExpr *E) {}
+
 void ASTStmtWriter::VisitOffsetOfExpr(OffsetOfExpr *E) {
   VisitExpr(E);
   Record.push_back(E->getNumComponents());
Index: clang/lib/Serialization/ASTReaderStmt.cpp
===
--- clang/lib/Serialization/ASTReaderStmt.cpp
+++ clang/lib/Serialization/ASTReaderStmt.cpp
@@ -714,6 +714,9 @@
 FPOptionsOverride::getFromOpaqueInt(Record.readInt()));
 }
 
+void ASTStmtReader::VisitBuiltinInstanceMemberExpr(
+BuiltinInstanceMemberExpr *E) {}
+
 void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
   VisitExpr(E);
   assert(E->getNumComponents() == Record.peekInt());
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -10957,6 +10957,12 @@
SubExpr.get());
 }
 
+template 
+ExprResult TreeTransform::TransformBuiltinInstanceMemberExpr(
+BuiltinInstanceMemberExpr *E) {
+  return ExprError();
+}
+
 template
 ExprResult
 TreeTransform::TransformOffsetOfExpr(OffsetOfExpr *E) {
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -16700,6 +16700,19 @@
   Comps, Exprs, RParenLoc);
 }
 
+ExprResult Sema::ActOnBuiltinInstanceMember(const IdentifierInfo *MemberII) {
+  const auto *RD = dyn_cast(getFunctionLevelDeclContext());
+  assert(RD); // TODO: Diagnostic.
+
+  auto It = llvm::find_if(RD->fields(), [MemberII](const FieldDecl *F) {
+return F->getIdentifier() == MemberII;
+  });
+
+  assert(It != RD->fields().end()); // TODO: Diagnostic.
+
+  return BuiltinInstanceMemberExpr::Create(Context, *It);
+}
+
 ExprResult Sema::ActOnBuiltinOffsetOf(Scope *S,
   SourceLocation BuiltinLoc,
   SourceLocation TypeLoc,
Index: clang/lib/Parse/ParseExpr.cpp
===
--- clang/lib/Parse/ParseExpr.cpp
+++ clang/lib/Parse/ParseExpr.cpp
@@ -13

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

2023-06-15 Thread Simon Tatham via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG10e42281144e: [ARM,AArch64] Add a full set of -mtp= options. 
(authored by simon_tatham).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152433

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

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

[clang] 10e4228 - [ARM,AArch64] Add a full set of -mtp= options.

2023-06-15 Thread Simon Tatham via cfe-commits

Author: Simon Tatham
Date: 2023-06-15T09:27:41+01:00
New Revision: 10e42281144ecca019764b554f3f0f709bba0f71

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

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

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

Currently clang supports only a subset of these registers, and not
even a consistent subset between AArch64 and AArch32:

 - For AArch64, clang permits you to choose between the four TPIDR_ELn
   thread registers, but not the fifth one, TPIDRRO_EL0.

 - In AArch32, on the other hand, the //only// thread register you can
   choose (apart from 'none, use a function call') is TPIDRURO, which
   corresponds to (the bottom 32 bits of) AArch64's TPIDRRO_EL0.

So there is no thread register that you can currently use in both
targets!

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

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

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

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

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

Reviewed By: nickdesaulniers

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

Added: 
clang/test/Driver/aarch64-thread-pointer.c
clang/test/Driver/arm-thread-pointer.c

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

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 750b6ab343852..06f02a05b7f13 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3595,8 +3595,10 @@ def mexecute_only : Flag<["-"], "mexecute-only">, 
Group,
 def mno_execute_only : Flag<["-"], "mno-execute-only">, 
Group,
   HelpText<"Allow generation of data access to code sections (ARM only)">;
 let Flags = [TargetSpecific] in {
-def mtp_mode_EQ : Joined<["-"], "mtp=">, Group, 
Values<"soft,cp15,el0,el1,el2,el3">,
-  HelpText<"Thread pointer access method (AArch32/AArch64 only)">;
+def mtp_mode_EQ : Joined<["-"], "mtp=">, Group, 
Values<"soft,cp15,tpidrurw,tpidruro,tpidrprw,el0,el1,el2,el3,tpidr_el0,tpidr_el1,tpidr_el2,tpidr_el3,tpidrro_el0">,
+  HelpText<"Thread pointer access method. "
+   "For AArch32: 'soft' uses a function call, or 'tpidrurw', 
'tpidruro' or 'tpidrprw' use the three CP15 registers. 'cp15' is an alias for 
'tpidruro'. "
+   "For AArch64: 'tpidr_el0', 'tpidr_el1', 'tpidr_el2', 'tpidr_el3' or 
'tpidrro_el0' use the five system registers. 'elN' is an alias for 
'tpidr_elN'.">;
 def mpure_code : Flag<["-"], "mpure-code">, Alias; // Alias for 
GCC compatibility
 def mno_pure_code : Flag<["-"], "mno-pure-code">, Alias;
 def mtvos_version_min_EQ : Joined<["-"], "mtvos-version-min=">, Group;

diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index f3bc00188c784..3547031635795 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -291,13 +291,15 @@ void aarch64::getAArch64TargetFeatures(const Driver &D,
 
   if (Arg *A = Args.getLastArg(options::OPT_mtp_mode_EQ)) {
 String

[PATCH] D152275: Use memory region declaration intrinsic when generating code for array subscripts

2023-06-15 Thread Simeon Krastnikov via Phabricator via cfe-commits
simeon added a comment.

> - The compile-time overhead of creating a bunch of extra intrinsics might be 
> significant.  Maybe we can mitigate to some extent by avoiding emitting the 
> intrinsic in simple cases where it doesn't actually help (constant indexes?).

Yes, that would make sense.

> - User code might not actually obey the language rules; do we have any 
> sanitizer that checks if user code trips over this?

I believe AddressSanitizer  
should be able to detect out-of-bounds accesses.

> - Not sure how this interacts with full restrict and related proposals.

So far as alias analysis goes, the two approaches should be orthogonal, but 
nevertheless we'd still have to go through the usual procedure of modifying the 
direct `GetElementPtrInst` checks and casts used by such patches.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152275

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


[PATCH] D153003: [ODRHash] Fix ODR hashing of template names

2023-06-15 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld created this revision.
Hahnfeld added reviewers: rtrieu, vsapsai, ChuanqiXu, Bigcheese.
Herald added a project: All.
Hahnfeld requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

For hashing, we should not differentiate between templates and qualified
templates and only look at the underlying name. As an example, consider
the added test case of a template template parameter; the two modules
have slightly differing `using` declarations (`using C = B` vs `B`)
which should be treated as identical.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153003

Files:
  clang/lib/AST/ODRHash.cpp
  clang/test/Modules/merge-template-template-parameters.cppm


Index: clang/test/Modules/merge-template-template-parameters.cppm
===
--- /dev/null
+++ clang/test/Modules/merge-template-template-parameters.cppm
@@ -0,0 +1,44 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface -I%t %t/module1.cppm -o 
%t/module1.pcm
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface -I%t %t/module2.cppm -o 
%t/module2.pcm
+// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/merge.cpp -verify 
-fsyntax-only
+
+//--- header.h
+namespace NS {
+template 
+class A {
+};
+
+template  class T>
+class B {
+};
+}
+
+//--- module1.cppm
+// inside NS, using C = B
+module;
+export module module1;
+#include "header.h"
+namespace NS {
+using C = B;
+}
+export struct D : NS::C {};
+
+//--- module2.cppm
+// inside NS, using C = B
+module;
+export module module2;
+#include "header.h"
+namespace NS {
+using C = B;
+}
+export struct D : NS::C {};
+
+//--- merge.cpp
+// expected-no-diagnostics
+import module1;
+import module2;
+D d;
Index: clang/lib/AST/ODRHash.cpp
===
--- clang/lib/AST/ODRHash.cpp
+++ clang/lib/AST/ODRHash.cpp
@@ -139,23 +139,8 @@
 }
 
 void ODRHash::AddTemplateName(TemplateName Name) {
-  auto Kind = Name.getKind();
-  ID.AddInteger(Kind);
-
-  switch (Kind) {
-  case TemplateName::Template:
-AddDecl(Name.getAsTemplateDecl());
-break;
-  // TODO: Support these cases.
-  case TemplateName::OverloadedTemplate:
-  case TemplateName::AssumedTemplate:
-  case TemplateName::QualifiedTemplate:
-  case TemplateName::DependentTemplate:
-  case TemplateName::SubstTemplateTemplateParm:
-  case TemplateName::SubstTemplateTemplateParmPack:
-  case TemplateName::UsingTemplate:
-break;
-  }
+  if (auto *TD = Name.getAsTemplateDecl())
+AddDecl(TD);
 }
 
 void ODRHash::AddTemplateArgument(TemplateArgument TA) {


Index: clang/test/Modules/merge-template-template-parameters.cppm
===
--- /dev/null
+++ clang/test/Modules/merge-template-template-parameters.cppm
@@ -0,0 +1,44 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface -I%t %t/module1.cppm -o %t/module1.pcm
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface -I%t %t/module2.cppm -o %t/module2.pcm
+// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/merge.cpp -verify -fsyntax-only
+
+//--- header.h
+namespace NS {
+template 
+class A {
+};
+
+template  class T>
+class B {
+};
+}
+
+//--- module1.cppm
+// inside NS, using C = B
+module;
+export module module1;
+#include "header.h"
+namespace NS {
+using C = B;
+}
+export struct D : NS::C {};
+
+//--- module2.cppm
+// inside NS, using C = B
+module;
+export module module2;
+#include "header.h"
+namespace NS {
+using C = B;
+}
+export struct D : NS::C {};
+
+//--- merge.cpp
+// expected-no-diagnostics
+import module1;
+import module2;
+D d;
Index: clang/lib/AST/ODRHash.cpp
===
--- clang/lib/AST/ODRHash.cpp
+++ clang/lib/AST/ODRHash.cpp
@@ -139,23 +139,8 @@
 }
 
 void ODRHash::AddTemplateName(TemplateName Name) {
-  auto Kind = Name.getKind();
-  ID.AddInteger(Kind);
-
-  switch (Kind) {
-  case TemplateName::Template:
-AddDecl(Name.getAsTemplateDecl());
-break;
-  // TODO: Support these cases.
-  case TemplateName::OverloadedTemplate:
-  case TemplateName::AssumedTemplate:
-  case TemplateName::QualifiedTemplate:
-  case TemplateName::DependentTemplate:
-  case TemplateName::SubstTemplateTemplateParm:
-  case TemplateName::SubstTemplateTemplateParmPack:
-  case TemplateName::UsingTemplate:
-break;
-  }
+  if (auto *TD = Name.getAsTemplateDecl())
+AddDecl(TD);
 }
 
 void ODRHash::AddTemplateArgument(TemplateArgument TA) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

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

Bump CI due to rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151397

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

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


[PATCH] D153003: [ODRHash] Fix ODR hashing of template names

2023-06-15 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

This looks not so good. In this way, we can't disambiguate other template 
types. At least we added the kind and a TODO here.

BTW, the attached test case is in fact in correct. See 
https://eel.is/c++draft/basic.def.odr#14.3, such mergeable declarations 
shouldn't be attached to named modules. (And this is also a defect that now we 
don't diagnose it correctly).

Even if you put them into the global module fragment, I think we should try to 
look other places like `isSameEntity` to solve this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153003

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


[clang] 1dee56a - [clang] NFC: Use `DirectoryEntryRef` in `FileManager::getCanonicalName()`

2023-06-15 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2023-06-15T11:22:31+02:00
New Revision: 1dee56aed7357ad87e7b30316554b760c75d5779

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

LOG: [clang] NFC: Use `DirectoryEntryRef` in `FileManager::getCanonicalName()`

This patch removes the last use of deprecated `DirectoryEntry::getName()`.

Depends on D151855.

Reviewed By: benlangmuir

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

Added: 


Modified: 
clang-tools-extra/clang-move/Move.cpp
clang-tools-extra/clangd/SourceCode.cpp
clang/include/clang/Basic/FileManager.h
clang/lib/Basic/FileManager.cpp
clang/lib/Lex/ModuleMap.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-move/Move.cpp 
b/clang-tools-extra/clang-move/Move.cpp
index e237a8ee1ebf1..905f1f456f4ac 100644
--- a/clang-tools-extra/clang-move/Move.cpp
+++ b/clang-tools-extra/clang-move/Move.cpp
@@ -92,7 +92,7 @@ std::string MakeAbsolutePath(const SourceManager &SM, 
StringRef Path) {
  << '\n';
   // Handle symbolic link path cases.
   // We are trying to get the real file path of the symlink.
-  auto Dir = SM.getFileManager().getDirectory(
+  auto Dir = SM.getFileManager().getOptionalDirectoryRef(
   llvm::sys::path::parent_path(AbsolutePath.str()));
   if (Dir) {
 StringRef DirName = SM.getFileManager().getCanonicalName(*Dir);

diff  --git a/clang-tools-extra/clangd/SourceCode.cpp 
b/clang-tools-extra/clangd/SourceCode.cpp
index c460ae307f114..474570cb6459f 100644
--- a/clang-tools-extra/clangd/SourceCode.cpp
+++ b/clang-tools-extra/clangd/SourceCode.cpp
@@ -537,7 +537,7 @@ std::optional getCanonicalPath(const 
FileEntryRef F,
   //
   //  The file path of Symbol is "/project/src/foo.h" instead of
   //  "/tmp/build/foo.h"
-  if (auto Dir = FileMgr.getDirectory(
+  if (auto Dir = FileMgr.getOptionalDirectoryRef(
   llvm::sys::path::parent_path(FilePath))) {
 llvm::SmallString<128> RealPath;
 llvm::StringRef DirName = FileMgr.getCanonicalName(*Dir);

diff  --git a/clang/include/clang/Basic/FileManager.h 
b/clang/include/clang/Basic/FileManager.h
index 84d569363a4a0..502b69c3b41ba 100644
--- a/clang/include/clang/Basic/FileManager.h
+++ b/clang/include/clang/Basic/FileManager.h
@@ -320,7 +320,7 @@ class FileManager : public RefCountedBase {
   /// This is a very expensive operation, despite its results being cached,
   /// and should only be used when the physical layout of the file system is
   /// required, which is (almost) never.
-  StringRef getCanonicalName(const DirectoryEntry *Dir);
+  StringRef getCanonicalName(DirectoryEntryRef Dir);
 
   /// Retrieve the canonical name for a given file.
   ///

diff  --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp
index 0f544f0215ac1..f92c1aeb21124 100644
--- a/clang/lib/Basic/FileManager.cpp
+++ b/clang/lib/Basic/FileManager.cpp
@@ -631,16 +631,15 @@ void FileManager::GetUniqueIDMapping(
 UIDToFiles[VFE->getUID()] = VFE;
 }
 
-StringRef FileManager::getCanonicalName(const DirectoryEntry *Dir) {
-  llvm::DenseMap::iterator Known
-= CanonicalNames.find(Dir);
+StringRef FileManager::getCanonicalName(DirectoryEntryRef Dir) {
+  auto Known = CanonicalNames.find(Dir);
   if (Known != CanonicalNames.end())
 return Known->second;
 
-  StringRef CanonicalName(Dir->getName());
+  StringRef CanonicalName(Dir.getName());
 
   SmallString<4096> CanonicalNameBuf;
-  if (!FS->getRealPath(Dir->getName(), CanonicalNameBuf))
+  if (!FS->getRealPath(Dir.getName(), CanonicalNameBuf))
 CanonicalName = CanonicalNameBuf.str().copy(CanonicalNameStorage);
 
   CanonicalNames.insert({Dir, CanonicalName});

diff  --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index 56329410c87da..cf546c4b3f9fe 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -1319,9 +1319,9 @@ 
ModuleMap::canonicalizeModuleMapPath(SmallVectorImpl &Path) {
   }
 
   FileManager &FM = SourceMgr.getFileManager();
-  auto DirEntry = FM.getDirectory(Dir.empty() ? "." : Dir);
+  auto DirEntry = FM.getDirectoryRef(Dir.empty() ? "." : Dir);
   if (!DirEntry)
-return DirEntry.getError();
+return llvm::errorToErrorCode(DirEntry.takeError());
 
   // Canonicalize the directory.
   StringRef CanonicalDir = FM.getCanonicalName(*DirEntry);



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


[clang] 7bca6f4 - [clang] Use `{File,Directory}EntryRef` in modular header search (part 2/2)

2023-06-15 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2023-06-15T11:22:31+02:00
New Revision: 7bca6f452f53a4a8d31a56b480e5b9fbaabad4fb

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

LOG: [clang] Use `{File,Directory}EntryRef` in modular header search (part 2/2)

This patch removes some deprecated uses of `{File,Directory}Entry::getName()`. 
No functional change intended.

Depends on D151854.

Reviewed By: benlangmuir

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

Added: 


Modified: 
clang/include/clang/Lex/HeaderSearch.h
clang/include/clang/Lex/ModuleMap.h
clang/lib/Lex/HeaderSearch.cpp
clang/lib/Lex/ModuleMap.cpp
clang/test/Modules/crash-vfs-umbrella-frameworks.m

Removed: 




diff  --git a/clang/include/clang/Lex/HeaderSearch.h 
b/clang/include/clang/Lex/HeaderSearch.h
index 131dbdcc20007..4906fa94e8ab6 100644
--- a/clang/include/clang/Lex/HeaderSearch.h
+++ b/clang/include/clang/Lex/HeaderSearch.h
@@ -638,7 +638,7 @@ class HeaderSearch {
 
   /// Try to find a module map file in the given directory, returning
   /// \c nullopt if none is found.
-  OptionalFileEntryRef lookupModuleMapFile(const DirectoryEntry *Dir,
+  OptionalFileEntryRef lookupModuleMapFile(DirectoryEntryRef Dir,
bool IsFramework);
 
   /// Determine whether there is a module map that may map the header

diff  --git a/clang/include/clang/Lex/ModuleMap.h 
b/clang/include/clang/Lex/ModuleMap.h
index 83c227b38e1bb..8f3f234036d26 100644
--- a/clang/include/clang/Lex/ModuleMap.h
+++ b/clang/include/clang/Lex/ModuleMap.h
@@ -487,11 +487,11 @@ class ModuleMap {
 
   /// Determine whether the given header is part of a module
   /// marked 'unavailable'.
-  bool isHeaderInUnavailableModule(const FileEntry *Header) const;
+  bool isHeaderInUnavailableModule(FileEntryRef Header) const;
 
   /// Determine whether the given header is unavailable as part
   /// of the specified module.
-  bool isHeaderUnavailableInModule(const FileEntry *Header,
+  bool isHeaderUnavailableInModule(FileEntryRef Header,
const Module *RequestingModule) const;
 
   /// Retrieve a module with the given name.

diff  --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index d94fe09274ed6..723479ca4fbbc 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -1751,12 +1751,12 @@ HeaderSearch::loadModuleMapFileImpl(FileEntryRef File, 
bool IsSystem,
 }
 
 OptionalFileEntryRef
-HeaderSearch::lookupModuleMapFile(const DirectoryEntry *Dir, bool IsFramework) 
{
+HeaderSearch::lookupModuleMapFile(DirectoryEntryRef Dir, bool IsFramework) {
   if (!HSOpts->ImplicitModuleMaps)
 return std::nullopt;
   // For frameworks, the preferred spelling is Modules/module.modulemap, but
   // module.map at the framework root is also accepted.
-  SmallString<128> ModuleMapFileName(Dir->getName());
+  SmallString<128> ModuleMapFileName(Dir.getName());
   if (IsFramework)
 llvm::sys::path::append(ModuleMapFileName, "Modules");
   llvm::sys::path::append(ModuleMapFileName, "module.modulemap");
@@ -1764,7 +1764,7 @@ HeaderSearch::lookupModuleMapFile(const DirectoryEntry 
*Dir, bool IsFramework) {
 return *F;
 
   // Continue to allow module.map
-  ModuleMapFileName = Dir->getName();
+  ModuleMapFileName = Dir.getName();
   llvm::sys::path::append(ModuleMapFileName, "module.map");
   if (auto F = FileMgr.getOptionalFileRef(ModuleMapFileName))
 return *F;
@@ -1772,7 +1772,7 @@ HeaderSearch::lookupModuleMapFile(const DirectoryEntry 
*Dir, bool IsFramework) {
   // For frameworks, allow to have a private module map with a preferred
   // spelling when a public module map is absent.
   if (IsFramework) {
-ModuleMapFileName = Dir->getName();
+ModuleMapFileName = Dir.getName();
 llvm::sys::path::append(ModuleMapFileName, "Modules",
 "module.private.modulemap");
 if (auto F = FileMgr.getOptionalFileRef(ModuleMapFileName))

diff  --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index c620eb7769742..56329410c87da 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -700,13 +700,12 @@ ModuleMap::findResolvedModulesForHeader(const FileEntry 
*File) const {
   return It->second;
 }
 
-bool ModuleMap::isHeaderInUnavailableModule(const FileEntry *Header) const {
+bool ModuleMap::isHeaderInUnavailableModule(FileEntryRef Header) const {
   return isHeaderUnavailableInModule(Header, nullptr);
 }
 
-bool
-ModuleMap::isHeaderUnavailableInModule(const FileEntry *Header,
-   const Module *RequestingModule) const {
+bool ModuleMap::isHeaderUnavailableInModule(
+FileEntryRef Header, const Module *RequestingModule) const {
   r

[PATCH] D151855: [clang] Use `{File,Directory}EntryRef` in modular header search (part 2/2)

2023-06-15 Thread Jan Svoboda 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 rG7bca6f452f53: [clang] Use `{File,Directory}EntryRef` in 
modular header search (part 2/2) (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151855

Files:
  clang/include/clang/Lex/HeaderSearch.h
  clang/include/clang/Lex/ModuleMap.h
  clang/lib/Lex/HeaderSearch.cpp
  clang/lib/Lex/ModuleMap.cpp
  clang/test/Modules/crash-vfs-umbrella-frameworks.m

Index: clang/test/Modules/crash-vfs-umbrella-frameworks.m
===
--- clang/test/Modules/crash-vfs-umbrella-frameworks.m
+++ clang/test/Modules/crash-vfs-umbrella-frameworks.m
@@ -24,15 +24,7 @@
 // CHECK-NEXT: note: diagnostic msg: {{.*}}.cache
 
 // CHECKYAML:  'type': 'directory',
-// CHECKYAML:  'name': "/[[PATH:.*]]/i/Frameworks/A.framework/Frameworks/B.framework/Headers",
-// CHECKYAML-NEXT:  'contents': [
-// CHECKYAML-NEXT:{
-// CHECKYAML-NEXT:  'type': 'file',
-// CHECKYAML-NEXT:  'name': "B.h",
-// CHECKYAML-NEXT:  'external-contents': "/[[PATH]]/i/Frameworks/B.framework/Headers/B.h"
-
-// CHECKYAML:  'type': 'directory',
-// CHECKYAML:  'name': "/[[PATH]]/i/Frameworks/B.framework/Headers",
+// CHECKYAML:  'name': "/[[PATH:.*]]/i/Frameworks/B.framework/Headers",
 // CHECKYAML-NEXT:  'contents': [
 // CHECKYAML-NEXT:{
 // CHECKYAML-NEXT:  'type': 'file',
Index: clang/lib/Lex/ModuleMap.cpp
===
--- clang/lib/Lex/ModuleMap.cpp
+++ clang/lib/Lex/ModuleMap.cpp
@@ -700,13 +700,12 @@
   return It->second;
 }
 
-bool ModuleMap::isHeaderInUnavailableModule(const FileEntry *Header) const {
+bool ModuleMap::isHeaderInUnavailableModule(FileEntryRef Header) const {
   return isHeaderUnavailableInModule(Header, nullptr);
 }
 
-bool
-ModuleMap::isHeaderUnavailableInModule(const FileEntry *Header,
-   const Module *RequestingModule) const {
+bool ModuleMap::isHeaderUnavailableInModule(
+FileEntryRef Header, const Module *RequestingModule) const {
   resolveHeaderDirectives(Header);
   HeadersMap::const_iterator Known = Headers.find(Header);
   if (Known != Headers.end()) {
@@ -734,8 +733,8 @@
 return true;
   }
 
-  const DirectoryEntry *Dir = Header->getDir();
-  SmallVector SkippedDirs;
+  OptionalDirectoryEntryRef Dir = Header.getDir();
+  SmallVector SkippedDirs;
   StringRef DirName = Dir->getName();
 
   auto IsUnavailable = [&](const Module *M) {
@@ -746,8 +745,7 @@
   // Keep walking up the directory hierarchy, looking for a directory with
   // an umbrella header.
   do {
-llvm::DenseMap::const_iterator KnownDir
-  = UmbrellaDirs.find(Dir);
+auto KnownDir = UmbrellaDirs.find(*Dir);
 if (KnownDir != UmbrellaDirs.end()) {
   Module *Found = KnownDir->second;
   if (IsUnavailable(Found))
@@ -761,11 +759,11 @@
 UmbrellaModule = UmbrellaModule->Parent;
 
   if (UmbrellaModule->InferSubmodules) {
-for (const DirectoryEntry *SkippedDir : llvm::reverse(SkippedDirs)) {
+for (DirectoryEntryRef SkippedDir : llvm::reverse(SkippedDirs)) {
   // Find or create the module that corresponds to this directory name.
   SmallString<32> NameBuf;
   StringRef Name = sanitizeFilenameAsIdentifier(
-  llvm::sys::path::stem(SkippedDir->getName()), NameBuf);
+  llvm::sys::path::stem(SkippedDir.getName()), NameBuf);
   Found = lookupModuleQualified(Name, Found);
   if (!Found)
 return false;
@@ -776,7 +774,7 @@
 // Infer a submodule with the same name as this header file.
 SmallString<32> NameBuf;
 StringRef Name = sanitizeFilenameAsIdentifier(
-   llvm::sys::path::stem(Header->getName()),
+   llvm::sys::path::stem(Header.getName()),
NameBuf);
 Found = lookupModuleQualified(Name, Found);
 if (!Found)
@@ -786,7 +784,7 @@
   return IsUnavailable(Found);
 }
 
-SkippedDirs.push_back(Dir);
+SkippedDirs.push_back(*Dir);
 
 // Retrieve our parent path.
 DirName = llvm::sys::path::parent_path(DirName);
@@ -794,10 +792,7 @@
   break;
 
 // Resolve the parent path to a directory entry.
-if (auto DirEntry = SourceMgr.getFileManager().getDirectory(DirName))
-  Dir = *DirEntry;
-else
-  Dir = nullptr;
+Dir = SourceMgr.getFileManager().getOptionalDirectoryRef(DirName);
   } while (Dir);
 
   return false;
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -1751,12 +1751,12 @@
 }
 
 OptionalF

[PATCH] D151922: [clang] NFC: Use `DirectoryEntryRef` in `FileManager::getCanonicalName()`

2023-06-15 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1dee56aed735: [clang] NFC: Use `DirectoryEntryRef` in 
`FileManager::getCanonicalName()` (authored by jansvoboda11).

Changed prior to commit:
  https://reviews.llvm.org/D151922?vs=527582&id=531660#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151922

Files:
  clang-tools-extra/clang-move/Move.cpp
  clang-tools-extra/clangd/SourceCode.cpp
  clang/include/clang/Basic/FileManager.h
  clang/lib/Basic/FileManager.cpp
  clang/lib/Lex/ModuleMap.cpp


Index: clang/lib/Lex/ModuleMap.cpp
===
--- clang/lib/Lex/ModuleMap.cpp
+++ clang/lib/Lex/ModuleMap.cpp
@@ -1319,9 +1319,9 @@
   }
 
   FileManager &FM = SourceMgr.getFileManager();
-  auto DirEntry = FM.getDirectory(Dir.empty() ? "." : Dir);
+  auto DirEntry = FM.getDirectoryRef(Dir.empty() ? "." : Dir);
   if (!DirEntry)
-return DirEntry.getError();
+return llvm::errorToErrorCode(DirEntry.takeError());
 
   // Canonicalize the directory.
   StringRef CanonicalDir = FM.getCanonicalName(*DirEntry);
Index: clang/lib/Basic/FileManager.cpp
===
--- clang/lib/Basic/FileManager.cpp
+++ clang/lib/Basic/FileManager.cpp
@@ -631,16 +631,15 @@
 UIDToFiles[VFE->getUID()] = VFE;
 }
 
-StringRef FileManager::getCanonicalName(const DirectoryEntry *Dir) {
-  llvm::DenseMap::iterator Known
-= CanonicalNames.find(Dir);
+StringRef FileManager::getCanonicalName(DirectoryEntryRef Dir) {
+  auto Known = CanonicalNames.find(Dir);
   if (Known != CanonicalNames.end())
 return Known->second;
 
-  StringRef CanonicalName(Dir->getName());
+  StringRef CanonicalName(Dir.getName());
 
   SmallString<4096> CanonicalNameBuf;
-  if (!FS->getRealPath(Dir->getName(), CanonicalNameBuf))
+  if (!FS->getRealPath(Dir.getName(), CanonicalNameBuf))
 CanonicalName = CanonicalNameBuf.str().copy(CanonicalNameStorage);
 
   CanonicalNames.insert({Dir, CanonicalName});
Index: clang/include/clang/Basic/FileManager.h
===
--- clang/include/clang/Basic/FileManager.h
+++ clang/include/clang/Basic/FileManager.h
@@ -320,7 +320,7 @@
   /// This is a very expensive operation, despite its results being cached,
   /// and should only be used when the physical layout of the file system is
   /// required, which is (almost) never.
-  StringRef getCanonicalName(const DirectoryEntry *Dir);
+  StringRef getCanonicalName(DirectoryEntryRef Dir);
 
   /// Retrieve the canonical name for a given file.
   ///
Index: clang-tools-extra/clangd/SourceCode.cpp
===
--- clang-tools-extra/clangd/SourceCode.cpp
+++ clang-tools-extra/clangd/SourceCode.cpp
@@ -537,7 +537,7 @@
   //
   //  The file path of Symbol is "/project/src/foo.h" instead of
   //  "/tmp/build/foo.h"
-  if (auto Dir = FileMgr.getDirectory(
+  if (auto Dir = FileMgr.getOptionalDirectoryRef(
   llvm::sys::path::parent_path(FilePath))) {
 llvm::SmallString<128> RealPath;
 llvm::StringRef DirName = FileMgr.getCanonicalName(*Dir);
Index: clang-tools-extra/clang-move/Move.cpp
===
--- clang-tools-extra/clang-move/Move.cpp
+++ clang-tools-extra/clang-move/Move.cpp
@@ -92,7 +92,7 @@
  << '\n';
   // Handle symbolic link path cases.
   // We are trying to get the real file path of the symlink.
-  auto Dir = SM.getFileManager().getDirectory(
+  auto Dir = SM.getFileManager().getOptionalDirectoryRef(
   llvm::sys::path::parent_path(AbsolutePath.str()));
   if (Dir) {
 StringRef DirName = SM.getFileManager().getCanonicalName(*Dir);


Index: clang/lib/Lex/ModuleMap.cpp
===
--- clang/lib/Lex/ModuleMap.cpp
+++ clang/lib/Lex/ModuleMap.cpp
@@ -1319,9 +1319,9 @@
   }
 
   FileManager &FM = SourceMgr.getFileManager();
-  auto DirEntry = FM.getDirectory(Dir.empty() ? "." : Dir);
+  auto DirEntry = FM.getDirectoryRef(Dir.empty() ? "." : Dir);
   if (!DirEntry)
-return DirEntry.getError();
+return llvm::errorToErrorCode(DirEntry.takeError());
 
   // Canonicalize the directory.
   StringRef CanonicalDir = FM.getCanonicalName(*DirEntry);
Index: clang/lib/Basic/FileManager.cpp
===
--- clang/lib/Basic/FileManager.cpp
+++ clang/lib/Basic/FileManager.cpp
@@ -631,16 +631,15 @@
 UIDToFiles[VFE->getUID()] = VFE;
 }
 
-StringRef FileManager::getCanonicalName(const DirectoryEntry *Dir) {
-  llvm::DenseMap::iterator Known
-= CanonicalNames.find(Dir);
+StringRef FileManager::getCanonicalName(DirectoryEntryRef Dir) {
+  auto Known = CanonicalNames.find(Dir);
   if (Known != CanonicalNames.end())
 return 

[PATCH] D152275: Use memory region declaration intrinsic when generating code for array subscripts

2023-06-15 Thread Jeroen Dobbelaere via Phabricator via cfe-commits
jeroen.dobbelaere added a comment.

In D152275#4418363 , @efriedma wrote:

> - Not sure how this interacts with full restrict and related proposals.

the full restrict PropagateAndConvertNoAlias pass will need to learn about it, 
but that should be trivial.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152275

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


[PATCH] D153003: [ODRHash] Fix ODR hashing of template names

2023-06-15 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

In D153003#4423926 , @ChuanqiXu wrote:

> This looks not so good. In this way, we can't disambiguate other template 
> types. At least we added the kind and a TODO here.

Which template name types would we need to disambiguate? We could also 
normalize the `Kind`, for example from `QualifiedTemplate` to `Template` (which 
is the case I care about).

> BTW, the attached test case is in fact in correct. See 
> https://eel.is/c++draft/basic.def.odr#14.3, such mergeable declarations 
> shouldn't be attached to named modules. (And this is also a defect that now 
> we don't diagnose it correctly).

I'm not sure I understand, could you elaborate? "correct" as in "the merge 
error is right" or "should work as written". Also there are a number of `export 
struct` in the tests, but you are saying this should not be included in the 
modules? How would this work?

> Even if you put them into the global module fragment, I think we should try 
> to look other places like `isSameEntity` to solve this.

Sure, but this first requires the hash to be identical, no? My understanding is 
that two (structurally) identical Decls must always hash to the same value, but 
the same value does not imply that `isSameEntity` and friends eventually agree 
(due to hash collisions).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153003

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


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

2023-06-15 Thread Kan Shengchen via Phabricator via cfe-commits
skan added inline comments.



Comment at: llvm/lib/DebugInfo/DWARF/DWARFContext.cpp:1895
+  if (RelocatedSection != Obj.section_end() && Name.contains(".dwo")) {
+// Each section in COFF can directly contain relocations.
+if (isa(&Obj) && Section.relocations().empty())

The comment is confusing according to line 1900. Could you refine it?



Comment at: llvm/test/DebugInfo/COFF/dwarf-headers.ll:75
+!14 = !{i32 1, !"MaxTLSAlign", i32 65536}
+!15 = !{!"clang version 17.0.0 (https://github.com/llvm/llvm-project.git 
f1106ef6c9d14d5b516ec352279aeee8f9d12818)"}

Simplify it to "clang"?



Comment at: llvm/test/DebugInfo/COFF/fission-cu.ll:19
+!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang 
version 3.3 (trunk 169021) (llvm/trunk 169020)", isOptimized: false, 
runtimeVersion: 0, splitDebugFilename: "baz.dwo", emissionKind: FullDebug, 
enums: !5, retainedTypes: !5, globals: !6, imports: !5)
+!5 = !{}

Simplify the producer to "clang"?



Comment at: llvm/test/DebugInfo/COFF/fission-cu.ll:118
+; HDR-NOT: .debug_aranges
+; HDR-NOT: .rela.{{.*}}.dwo
+

Why do we check .rela* section? It's linux relocation section name


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152785

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


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

2023-06-15 Thread Kan Shengchen via Phabricator via cfe-commits
skan added inline comments.



Comment at: llvm/lib/DebugInfo/DWARF/DWARFContext.cpp:1896
+// Each section in COFF can directly contain relocations.
+if (isa(&Obj) && Section.relocations().empty())
+  continue;

Should we merge the check into line 1894?



Comment at: llvm/test/DebugInfo/COFF/fission-sections.ll:19
+!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang 
version 3.3 (trunk 169021) (llvm/trunk 169020)", isOptimized: false, 
runtimeVersion: 0, splitDebugFilename: "baz.dwo", emissionKind: FullDebug, 
enums: !5, retainedTypes: !5, globals: !6, imports: !5)
+!5 = !{}

ditto


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152785

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


[clang] 462bda1 - [clang] Deprecate `DirectoryEntry::getName()`

2023-06-15 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2023-06-15T12:14:41+02:00
New Revision: 462bda1d562acc5a907eafe0afeb79556101c65d

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

LOG: [clang] Deprecate `DirectoryEntry::getName()`

This finally officially deprecates `DirectoryEntry::getName()`. I checked no 
usages remain in targets built by any of `check-clang`, `check-clang-tools`, 
`check-clang-extra`. There are probably some remaining usages in places like 
LLDB and other clients. This will give them a chance to transition to 
`DirectoryEntryRef::getName()` before we remove the function altogether.

Depends on D151922.

Reviewed By: benlangmuir

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

Added: 


Modified: 
clang/include/clang/Basic/DirectoryEntry.h

Removed: 




diff  --git a/clang/include/clang/Basic/DirectoryEntry.h 
b/clang/include/clang/Basic/DirectoryEntry.h
index 6c8da1213655a..6580e54e3c58b 100644
--- a/clang/include/clang/Basic/DirectoryEntry.h
+++ b/clang/include/clang/Basic/DirectoryEntry.h
@@ -46,6 +46,7 @@ class DirectoryEntry {
   StringRef Name; // Name of the directory.
 
 public:
+  LLVM_DEPRECATED("Use DirectoryEntryRef::getName() instead.", "")
   StringRef getName() const { return Name; }
 };
 



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


[PATCH] D151927: [clang] Deprecate `DirectoryEntry::getName()`

2023-06-15 Thread Jan Svoboda 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 rG462bda1d562a: [clang] Deprecate `DirectoryEntry::getName()` 
(authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151927

Files:
  clang/include/clang/Basic/DirectoryEntry.h


Index: clang/include/clang/Basic/DirectoryEntry.h
===
--- clang/include/clang/Basic/DirectoryEntry.h
+++ clang/include/clang/Basic/DirectoryEntry.h
@@ -46,6 +46,7 @@
   StringRef Name; // Name of the directory.
 
 public:
+  LLVM_DEPRECATED("Use DirectoryEntryRef::getName() instead.", "")
   StringRef getName() const { return Name; }
 };
 


Index: clang/include/clang/Basic/DirectoryEntry.h
===
--- clang/include/clang/Basic/DirectoryEntry.h
+++ clang/include/clang/Basic/DirectoryEntry.h
@@ -46,6 +46,7 @@
   StringRef Name; // Name of the directory.
 
 public:
+  LLVM_DEPRECATED("Use DirectoryEntryRef::getName() instead.", "")
   StringRef getName() const { return Name; }
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

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

Bump CI due to update of parent revision.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151397

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

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


[PATCH] D153006: [clang][dataflow] Perform deep copies in copy and move operations.

2023-06-15 Thread Martin Böhme via Phabricator via cfe-commits
mboehme created this revision.
Herald added subscribers: martong, xazax.hun.
Herald added a reviewer: NoQ.
Herald added a project: All.
mboehme requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This serves two purposes:

- Because, today, we only copy the `StructValue`, modifying the destination of 
the copy also modifies the source. This is demonstrated by the new checks added 
to `CopyConstructor` and `MoveConstructor`, which fail without the deep copy.

- It lays the groundwork for eliminating the redundancy between 
`AggregateStorageLocation` and `StructValue`, which will happen as part of the 
ongoing migration to strict handling of value categories (seeo 
https://discourse.llvm.org/t/70086 for details). This will involve turning 
`StructValue` into essentially just a wrapper for `AggregateStorageLocation`; 
under this scheme, the current "shallow" copy (copying a `StructValue` from one 
`AggregateStorageLocation` to another) will no longer be possible.

Because we now perform deep copies, tests need to perform a deep equality
comparison instead of just comparing for equal identity of the `StructValue`s.
The new function `recordsEqual()` provides such a deep equality comparison.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153006

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
  clang/include/clang/Analysis/FlowSensitive/RecordOps.h
  clang/include/clang/Analysis/FlowSensitive/StorageLocation.h
  clang/include/clang/Analysis/FlowSensitive/Value.h
  clang/lib/Analysis/FlowSensitive/CMakeLists.txt
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/RecordOps.cpp
  clang/lib/Analysis/FlowSensitive/Transfer.cpp
  clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
  clang/unittests/Analysis/FlowSensitive/RecordOpsTest.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -12,7 +12,7 @@
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Analysis/FlowSensitive/DataflowAnalysisContext.h"
 #include "clang/Analysis/FlowSensitive/DataflowEnvironment.h"
-#include "clang/Analysis/FlowSensitive/NoopAnalysis.h"
+#include "clang/Analysis/FlowSensitive/RecordOps.h"
 #include "clang/Analysis/FlowSensitive/StorageLocation.h"
 #include "clang/Analysis/FlowSensitive/Value.h"
 #include "clang/Basic/LangStandard.h"
@@ -38,64 +38,6 @@
 using ::testing::NotNull;
 using ::testing::UnorderedElementsAre;
 
-using BuiltinOptions = DataflowAnalysisContext::Options;
-
-template 
-llvm::Error
-runDataflowReturnError(llvm::StringRef Code, Matcher Match,
-   DataflowAnalysisOptions Options,
-   LangStandard::Kind Std = LangStandard::lang_cxx17,
-   llvm::StringRef TargetFun = "target") {
-  using ast_matchers::hasName;
-  llvm::SmallVector ASTBuildArgs = {
-  // -fnodelayed-template-parsing is the default everywhere but on Windows.
-  // Set it explicitly so that tests behave the same on Windows as on other
-  // platforms.
-  "-fsyntax-only", "-fno-delayed-template-parsing",
-  "-std=" +
-  std::string(LangStandard::getLangStandardForKind(Std).getName())};
-  AnalysisInputs AI(
-  Code, hasName(TargetFun),
-  [UseBuiltinModel = Options.BuiltinOpts.has_value()](ASTContext &C,
-  Environment &Env) {
-return NoopAnalysis(
-C,
-DataflowAnalysisOptions{
-UseBuiltinModel ? Env.getDataflowAnalysisContext().getOptions()
-: std::optional()});
-  });
-  AI.ASTBuildArgs = ASTBuildArgs;
-  if (Options.BuiltinOpts)
-AI.BuiltinOptions = *Options.BuiltinOpts;
-  return checkDataflow(
-  std::move(AI),
-  /*VerifyResults=*/
-  [&Match](
-  const llvm::StringMap> &Results,
-  const AnalysisOutputs &AO) { Match(Results, AO.ASTCtx); });
-}
-
-template 
-void runDataflow(llvm::StringRef Code, Matcher Match,
- DataflowAnalysisOptions Options,
- LangStandard::Kind Std = LangStandard::lang_cxx17,
- llvm::StringRef TargetFun = "target") {
-  ASSERT_THAT_ERROR(
-  runDataflowReturnError(Code, Match, Options, Std, TargetFun),
-  llvm::Succeeded());
-}
-
-template 
-void runDataflow(llvm::StringRef Code, Matcher Match,
- LangStandard::Kind Std = LangStandard::lang_cxx17,
- bool ApplyBuiltinTransfer = true,
- llvm::StringRef TargetFun = "target") {
-  runDataflow(Code, std::move(Match),
-  {ApplyBuiltinTransfer 

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

2023-06-15 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 531681.
eopXD edited the summary of this revision.
eopXD added a comment.

Edit codegen test case for llvm/test/CodeGen/RISCV/rvv/{vnclip.ll/vnclipu.ll} 
correctly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152879

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

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


[clang] fa5788f - [clang][index] NFCI: Make `CXFile` a `FileEntryRef`

2023-06-15 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2023-06-15T12:34:54+02:00
New Revision: fa5788ff8dc10f36e0947757e335cd180a1a63c9

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

LOG: [clang][index] NFCI: Make `CXFile` a `FileEntryRef`

This patch swaps out the `void *` behind `CXFile` from `FileEntry *` to 
`FileEntryRef::MapEntry *`. This allows us to remove some deprecated uses of 
`FileEntry::getName()`.

Depends on D151854.

Reviewed By: benlangmuir

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

Added: 
clang/tools/libclang/CXFile.h

Modified: 
clang/include/clang/Basic/Module.h
clang/include/clang/Frontend/ASTUnit.h
clang/lib/Basic/Module.cpp
clang/lib/Frontend/ASTUnit.cpp
clang/lib/Frontend/FrontendAction.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/tools/libclang/CIndex.cpp
clang/tools/libclang/CIndexHigh.cpp
clang/tools/libclang/CIndexInclusionStack.cpp
clang/tools/libclang/CLog.h
clang/tools/libclang/CXIndexDataConsumer.cpp
clang/tools/libclang/CXIndexDataConsumer.h
clang/tools/libclang/CXLoadedDiagnostic.cpp
clang/tools/libclang/CXSourceLocation.cpp
clang/tools/libclang/Indexing.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index 9625a682c3549..399ed92a325e5 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -217,7 +217,7 @@ class alignas(8) Module {
   OptionalFileEntryRef ASTFile;
 
   /// The top-level headers associated with this module.
-  llvm::SmallSetVector TopHeaders;
+  llvm::SmallSetVector TopHeaders;
 
   /// top-level header filenames that aren't resolved to FileEntries yet.
   std::vector TopHeaderNames;
@@ -672,7 +672,7 @@ class alignas(8) Module {
   OptionalDirectoryEntryRef getEffectiveUmbrellaDir() const;
 
   /// Add a top-level header associated with this module.
-  void addTopHeader(const FileEntry *File);
+  void addTopHeader(FileEntryRef File);
 
   /// Add a top-level header filename associated with this module.
   void addTopHeaderFilename(StringRef Filename) {
@@ -680,7 +680,7 @@ class alignas(8) Module {
   }
 
   /// The top-level headers associated with this module.
-  ArrayRef getTopHeaders(FileManager &FileMgr);
+  ArrayRef getTopHeaders(FileManager &FileMgr);
 
   /// Determine whether this module has declared its intention to
   /// directly use another module.

diff  --git a/clang/include/clang/Frontend/ASTUnit.h 
b/clang/include/clang/Frontend/ASTUnit.h
index 05d149ee6dff8..db8b598866c25 100644
--- a/clang/include/clang/Frontend/ASTUnit.h
+++ b/clang/include/clang/Frontend/ASTUnit.h
@@ -643,7 +643,7 @@ class ASTUnit {
   bool visitLocalTopLevelDecls(void *context, DeclVisitorFn Fn);
 
   /// Get the PCH file if one was included.
-  const FileEntry *getPCHFile();
+  OptionalFileEntryRef getPCHFile();
 
   /// Returns true if the ASTUnit was constructed from a serialized
   /// module file.

diff  --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp
index 057fc77d0e993..3f9b8d0c775b9 100644
--- a/clang/lib/Basic/Module.cpp
+++ b/clang/lib/Basic/Module.cpp
@@ -271,18 +271,16 @@ OptionalDirectoryEntryRef 
Module::getEffectiveUmbrellaDir() const {
   return std::nullopt;
 }
 
-void Module::addTopHeader(const FileEntry *File) {
+void Module::addTopHeader(FileEntryRef File) {
   assert(File);
   TopHeaders.insert(File);
 }
 
-ArrayRef Module::getTopHeaders(FileManager &FileMgr) {
+ArrayRef Module::getTopHeaders(FileManager &FileMgr) {
   if (!TopHeaderNames.empty()) {
-for (std::vector::iterator
-   I = TopHeaderNames.begin(), E = TopHeaderNames.end(); I != E; ++I) {
-  if (auto FE = FileMgr.getFile(*I))
+for (StringRef TopHeaderName : TopHeaderNames)
+  if (auto FE = FileMgr.getOptionalFileRef(TopHeaderName))
 TopHeaders.insert(*FE);
-}
 TopHeaderNames.clear();
   }
 

diff  --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index 32ae76d673b6c..a42df66148518 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -2645,9 +2645,9 @@ bool ASTUnit::visitLocalTopLevelDecls(void *context, 
DeclVisitorFn Fn) {
   return true;
 }
 
-const FileEntry *ASTUnit::getPCHFile() {
+OptionalFileEntryRef ASTUnit::getPCHFile() {
   if (!Reader)
-return nullptr;
+return std::nullopt;
 
   serialization::ModuleFile *Mod = nullptr;
   Reader->getModuleManager().visit([&Mod](serialization::ModuleFile &M) {
@@ -2670,7 +2670,7 @@ const FileEntry *ASTUnit::getPCHFile() {
   if (Mod)
 return Mod->File;
 
-  return nullptr;
+  return std::nullopt;
 }
 
 bool ASTUnit::isModuleFile() const {

diff  --git a/clang/lib/Frontend/FrontendAction.cpp 
b/clang/lib/Frontend/FrontendAction.cpp
index cfac2f8c4e5a6..c6f9

[PATCH] D151938: [clang][index] NFCI: Make `CXFile` a `FileEntryRef`

2023-06-15 Thread Jan Svoboda 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 rGfa5788ff8dc1: [clang][index] NFCI: Make `CXFile` a 
`FileEntryRef` (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151938

Files:
  clang/include/clang/Basic/Module.h
  clang/include/clang/Frontend/ASTUnit.h
  clang/lib/Basic/Module.cpp
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CIndexHigh.cpp
  clang/tools/libclang/CIndexInclusionStack.cpp
  clang/tools/libclang/CLog.h
  clang/tools/libclang/CXFile.h
  clang/tools/libclang/CXIndexDataConsumer.cpp
  clang/tools/libclang/CXIndexDataConsumer.h
  clang/tools/libclang/CXLoadedDiagnostic.cpp
  clang/tools/libclang/CXSourceLocation.cpp
  clang/tools/libclang/Indexing.cpp

Index: clang/tools/libclang/Indexing.cpp
===
--- clang/tools/libclang/Indexing.cpp
+++ clang/tools/libclang/Indexing.cpp
@@ -255,7 +255,8 @@
 
 if (Loc == MainFileLoc && Reason == PPCallbacks::EnterFile) {
   IsMainFileEntered = true;
-  DataConsumer.enteredMainFile(SM.getFileEntryForID(SM.getMainFileID()));
+  DataConsumer.enteredMainFile(
+  *SM.getFileEntryRefForID(SM.getMainFileID()));
 }
   }
 
@@ -350,8 +351,8 @@
 PreprocessorOptions &PPOpts = CI.getPreprocessorOpts();
 
 if (!PPOpts.ImplicitPCHInclude.empty()) {
-  auto File = CI.getFileManager().getFile(PPOpts.ImplicitPCHInclude);
-  if (File)
+  if (auto File =
+  CI.getFileManager().getOptionalFileRef(PPOpts.ImplicitPCHInclude))
 DataConsumer->importedPCH(*File);
 }
 
@@ -694,17 +695,18 @@
 
   ASTUnit::ConcurrencyCheck Check(*Unit);
 
-  if (const FileEntry *PCHFile = Unit->getPCHFile())
-DataConsumer.importedPCH(PCHFile);
+  if (OptionalFileEntryRef PCHFile = Unit->getPCHFile())
+DataConsumer.importedPCH(*PCHFile);
 
   FileManager &FileMgr = Unit->getFileManager();
 
   if (Unit->getOriginalSourceFileName().empty())
-DataConsumer.enteredMainFile(nullptr);
-  else if (auto MainFile = FileMgr.getFile(Unit->getOriginalSourceFileName()))
+DataConsumer.enteredMainFile(std::nullopt);
+  else if (auto MainFile =
+   FileMgr.getFileRef(Unit->getOriginalSourceFileName()))
 DataConsumer.enteredMainFile(*MainFile);
   else
-DataConsumer.enteredMainFile(nullptr);
+DataConsumer.enteredMainFile(std::nullopt);
 
   DataConsumer.setASTContext(Unit->getASTContext());
   DataConsumer.startedTranslationUnit();
Index: clang/tools/libclang/CXSourceLocation.cpp
===
--- clang/tools/libclang/CXSourceLocation.cpp
+++ clang/tools/libclang/CXSourceLocation.cpp
@@ -13,6 +13,7 @@
 #include "CXSourceLocation.h"
 #include "CIndexer.h"
 #include "CLog.h"
+#include "CXFile.h"
 #include "CXLoadedDiagnostic.h"
 #include "CXString.h"
 #include "CXTranslationUnit.h"
@@ -128,19 +129,19 @@
   LogRef Log = Logger::make(__func__);
   ASTUnit *CXXUnit = cxtu::getASTUnit(TU);
   ASTUnit::ConcurrencyCheck Check(*CXXUnit);
-  const FileEntry *File = static_cast(file);
+  FileEntryRef File = *cxfile::getFileEntryRef(file);
   SourceLocation SLoc = CXXUnit->getLocation(File, line, column);
   if (SLoc.isInvalid()) {
 if (Log)
   *Log << llvm::format("(\"%s\", %d, %d) = invalid",
-   File->getName().str().c_str(), line, column);
+   File.getName().str().c_str(), line, column);
 return clang_getNullLocation();
   }
   
   CXSourceLocation CXLoc =
   cxloc::translateSourceLocation(CXXUnit->getASTContext(), SLoc);
   if (Log)
-*Log << llvm::format("(\"%s\", %d, %d) = ", File->getName().str().c_str(),
+*Log << llvm::format("(\"%s\", %d, %d) = ", File.getName().str().c_str(),
  line, column)
  << CXLoc;
 
@@ -160,7 +161,7 @@
   ASTUnit *CXXUnit = cxtu::getASTUnit(TU);
 
   SourceLocation SLoc 
-= CXXUnit->getLocation(static_cast(file), offset);
+= CXXUnit->getLocation(*cxfile::getFileEntryRef(file), offset);
 
   if (SLoc.isInvalid())
 return clang_getNullLocation();
@@ -251,7 +252,7 @@
   }
   
   if (file)
-*file = const_cast(SM.getFileEntryForSLocEntry(sloc));
+*file = cxfile::makeCXFile(SM.getFileEntryRefForID(fileID));
   if (line)
 *line = SM.getExpansionLineNumber(ExpansionLoc);
   if (column)
@@ -328,7 +329,7 @@
 return createNullLocation(file, line, column, offset);
   
   if (file)
-*file = const_cast(SM.getFileEntryForID(FID));
+*file = cxfile::makeCXFile(SM.getFileEntryRefForID(FID));
   if (line)
 *line = SM.getLineNumber(FID, FileOffset);
   if (column)
@@ -364,7 +365,7 @@
 return createNullLocation(file, li

[PATCH] D153008: [RISCV] Allow slash-star comments in instruction operands

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

It had been reported by one of Esperanto's customers that slash-start
comments ("/*") within inline assembly were only allowed before the
first instruction operand or at the end of the lines. However, those
comments were not allowed when interleaved within the operands.

An example follows:

  unsigned long int dst;
  __asm__ __volatile__(
"li /* this is fine */ %[dst], /* this was NOT fine */ 0x1234\n"
"add zero, %[dst], %[dst]\n"
: [ dst ] "=r"(dst)
:
:);

A code review of the top level parser (AsmParser class) showed that
when comments are place before the instruction operand or at end of
a line, then they are gracefully handled irrespective of the backend.
When the comments are interleaved within the instruction operands it
is the backend's responsibility to handle the comments.

Explicitly handling the comments in the RISC-V backend is not a too
invasive patch and fixes the issue.

Thanks to David Spikett from Arm's community for pointing out where to
start looking within the LLVM code base.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153008

Files:
  clang/test/CodeGen/RISCV/riscv-inline-asm-gcc-commenting.c
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp


Index: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
===
--- llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -2573,14 +2573,26 @@
   if (parseOperand(Operands, Name))
 return true;
 
+  // Silently ignore comments after the first operand for compatibility with 
gcc
+  while (getLexer().is(AsmToken::Comment))
+getLexer().Lex();
+
   // Parse until end of statement, consuming commas between operands
   while (getLexer().is(AsmToken::Comma)) {
 // Consume comma token
 getLexer().Lex();
 
+// Silently ignore comments before operand for compatibility with gcc
+while (getLexer().is(AsmToken::Comment))
+  getLexer().Lex();
+
 // Parse next operand
 if (parseOperand(Operands, Name))
   return true;
+
+// Silently ignore comments after operand for compatibility with gcc
+while (getLexer().is(AsmToken::Comment))
+  getLexer().Lex();
   }
 
   if (getParser().parseEOL("unexpected token")) {
Index: clang/test/CodeGen/RISCV/riscv-inline-asm-gcc-commenting.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/riscv-inline-asm-gcc-commenting.c
@@ -0,0 +1,31 @@
+// RUN: %clang -fPIC --target=riscv64-unknown-elf -mabi=lp64f -O3 -o - -S %s | 
FileCheck %s
+
+unsigned long int f1() {
+  unsigned long int dst;
+  __asm__ __volatile__("li %[dst], 0x1234 /* this is fine */ \n"
+   "add zero, %[dst], %[dst]\n"
+   : [ dst ] "=r"(dst)
+   :
+   :);
+  return dst;
+}
+
+unsigned long int f2() {
+  unsigned long int dst;
+  __asm__ __volatile__("li /* this is fine */ %[dst], /* this should also be 
fine */ 0x1234\n"
+   "add zero, %[dst], %[dst]\n"
+   : [ dst ] "=r"(dst)
+   :
+   :);
+  return dst;
+}
+// CHECK: f1:
+// CHECK:  lui a0, 1
+// CHECK-NEXT: addiw   a0, a0, 564
+// CHECK-NEXT: add zero, a0, a0
+// CHECK:  ret
+// CHECK: f2:
+// CHECK:  lui a0, 1
+// CHECK-NEXT: addiw   a0, a0, 564
+// CHECK-NEXT: add zero, a0, a0
+// CHECK:  ret


Index: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
===
--- llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -2573,14 +2573,26 @@
   if (parseOperand(Operands, Name))
 return true;
 
+  // Silently ignore comments after the first operand for compatibility with gcc
+  while (getLexer().is(AsmToken::Comment))
+getLexer().Lex();
+
   // Parse until end of statement, consuming commas between operands
   while (getLexer().is(AsmToken::Comma)) {
 // Consume comma token
 getLexer().Lex();
 
+// Silently ignore comments before operand for compatibility with gcc
+while (getLexer().is(AsmToken::Comment))
+  getLexer().Lex();
+
 // Parse next operand
 if (parseOperand(Operands, Name))
   return true;

[PATCH] D153003: [ODRHash] Fix ODR hashing of template names

2023-06-15 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D153003#4424004 , @Hahnfeld wrote:

> In D153003#4423926 , @ChuanqiXu 
> wrote:
>
>> This looks not so good. In this way, we can't disambiguate other template 
>> types. At least we added the kind and a TODO here.
>
> Which template name types would we need to disambiguate? We could also 
> normalize the `Kind`, for example from `QualifiedTemplate` to `Template` 
> (which is the case I care about).

For example, the template name with QualifiedTemplate kind has different hash 
name with the name with DependentTemplate kind. But it is not true after the 
patch.

>> BTW, the attached test case is in fact in correct. See 
>> https://eel.is/c++draft/basic.def.odr#14.3, such mergeable declarations 
>> shouldn't be attached to named modules. (And this is also a defect that now 
>> we don't diagnose it correctly).
>
> I'm not sure I understand, could you elaborate? "correct" as in "the merge 
> error is right" or "should work as written". Also there are a number of 
> `export struct` in the tests, but you are saying this should not be included 
> in the modules? How would this work?

I mean the error is correct. The test case itself is invalid. We shouldn't 
declare it as `expected-no-diagnostics`. The link above says the reason. The 
same declaration in multiple module purview is invalid.

>> Even if you put them into the global module fragment, I think we should try 
>> to look other places like `isSameEntity` to solve this.
>
> Sure, but this first requires the hash to be identical, no? My understanding 
> is that two (structurally) identical Decls must always hash to the same 
> value, but the same value does not imply that `isSameEntity` and friends 
> eventually agree (due to hash collisions).

Yeah, it will be better to be identical. I think the major problem is that the 
patch misses information instead of adding more information.

> , but the same value does not imply that `isSameEntity` ...

No. IsSameEntity is a weaker check. It simply checks whether two named decls 
refers to the same `name`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153003

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


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

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

Remove `let hasSideEffects = 0;` under
VPseudoBinaryNoMaskRoundingMode, VPseudoBinaryNoMaskTURoundingMode, and 
VPseudoBinaryMaskPolicyRoundingMode.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151397

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

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


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

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

Recover, the previous update should happen under D151396 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151397

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

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


[PATCH] D153008: [RISCV] Allow slash-star comments in instruction operands

2023-06-15 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added a reviewer: DavidSpickett.
DavidSpickett added a comment.

Is the comment here relevant? 
https://discourse.llvm.org/t/interleaving-several-c-style-comments-in-the-same-inline-assembly-line/71353/8
 Does this patch do that already?

Also is it a problem that the ignored comments are not seen in the output? 
Perhaps you are just not checking for those bits. For comments on the end, 
those are propagated to the assembly output I know that much.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153008

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


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

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

Bump CI.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151397

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

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


[clang] 28f3edd - AMDGPU: Add llvm.amdgcn.exp2 intrinsic

2023-06-15 Thread Matt Arsenault via cfe-commits

Author: Matt Arsenault
Date: 2023-06-15T07:00:07-04:00
New Revision: 28f3edd2be2a27b9dc7739d137147007c5fd9e41

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

LOG: AMDGPU: Add llvm.amdgcn.exp2 intrinsic

Provide direct access to v_exp_f32 and v_exp_f16, so we can start
correctly lowering the generic exp intrinsics.

Unfortunately have to break from the usual naming convention of
matching the instruction name and stripping the v_ prefix. exp is
already taken by the export intrinsic. On the clang builtin side, we
have a choice of maintaining the convention to the instruction name,
or following the intrinsic name.

Added: 
llvm/test/CodeGen/AMDGPU/llvm.amdgcn.exp2.ll

Modified: 
clang/include/clang/Basic/BuiltinsAMDGPU.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGenOpenCL/builtins-amdgcn.cl
llvm/docs/AMDGPUUsage.rst
llvm/docs/ReleaseNotes.rst
llvm/include/llvm/IR/IntrinsicsAMDGPU.td
llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp
llvm/lib/Target/AMDGPU/AMDGPUISelLowering.h
llvm/lib/Target/AMDGPU/AMDGPUInstrInfo.td
llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
llvm/lib/Target/AMDGPU/R600Instructions.td
llvm/lib/Target/AMDGPU/VOP1Instructions.td

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def 
b/clang/include/clang/Basic/BuiltinsAMDGPU.def
index 0ccdc30ad386b..29aa9ca7552ed 100644
--- a/clang/include/clang/Basic/BuiltinsAMDGPU.def
+++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def
@@ -101,6 +101,7 @@ BUILTIN(__builtin_amdgcn_rsq_clampf, "ff", "nc")
 BUILTIN(__builtin_amdgcn_sinf, "ff", "nc")
 BUILTIN(__builtin_amdgcn_cosf, "ff", "nc")
 BUILTIN(__builtin_amdgcn_logf, "ff", "nc")
+BUILTIN(__builtin_amdgcn_exp2f, "ff", "nc")
 BUILTIN(__builtin_amdgcn_log_clampf, "ff", "nc")
 BUILTIN(__builtin_amdgcn_ldexp, "ddi", "nc")
 BUILTIN(__builtin_amdgcn_ldexpf, "ffi", "nc")

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 421c3d2e66ddb..4939392f5d148 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -17173,6 +17173,8 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned 
BuiltinID,
 return EmitAMDGPUDispatchPtr(*this, E);
   case AMDGPU::BI__builtin_amdgcn_logf:
 return emitUnaryBuiltin(*this, E, Intrinsic::amdgcn_log);
+  case AMDGPU::BI__builtin_amdgcn_exp2f:
+return emitUnaryBuiltin(*this, E, Intrinsic::amdgcn_exp2);
   case AMDGPU::BI__builtin_amdgcn_log_clampf:
 return emitUnaryBuiltin(*this, E, Intrinsic::amdgcn_log_clamp);
   case AMDGPU::BI__builtin_amdgcn_ldexp:

diff  --git a/clang/test/CodeGenOpenCL/builtins-amdgcn.cl 
b/clang/test/CodeGenOpenCL/builtins-amdgcn.cl
index 3900a8cacd930..f611bc6f16d15 100644
--- a/clang/test/CodeGenOpenCL/builtins-amdgcn.cl
+++ b/clang/test/CodeGenOpenCL/builtins-amdgcn.cl
@@ -179,6 +179,13 @@ void test_log_f32(global float* out, float a)
   *out = __builtin_amdgcn_logf(a);
 }
 
+// CHECK-LABEL: @test_exp2_f32
+// CHECK: call float @llvm.amdgcn.exp2.f32
+void test_exp2_f32(global float* out, float a)
+{
+  *out = __builtin_amdgcn_exp2f(a);
+}
+
 // CHECK-LABEL: @test_log_clamp_f32
 // CHECK: call float @llvm.amdgcn.log.clamp.f32
 void test_log_clamp_f32(global float* out, float a)

diff  --git a/llvm/docs/AMDGPUUsage.rst b/llvm/docs/AMDGPUUsage.rst
index 3acd83feacde8..a53c06f43868f 100644
--- a/llvm/docs/AMDGPUUsage.rst
+++ b/llvm/docs/AMDGPUUsage.rst
@@ -955,6 +955,9 @@ The AMDGPU backend implements the following LLVM IR 
intrinsics.
   llvm.amdgcn.logProvides direct access to 
v_log_f32 and v_log_f16
  (on targets with half support). 
Peforms log2 function.
 
+  llvm.amdgcn.exp2   Provides direct access to 
v_exp_f32 and v_exp_f16
+ (on targets with half support). 
Performs exp2 function.
+
   =  
==
 
 .. TODO::

diff  --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index 4d078cf42f060..2b1edd5d6ba38 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -136,6 +136,10 @@ Changes to the AMDGPU Backend
 * Added llvm.amdgcn.log.f32 intrinsic. This provides direct access to
   v_log_f32.
 
+* Added llvm.amdgcn.exp2.f32 intrinsic. This provides direct access to
+  v_exp_f32.
+
+
 Changes to the ARM Backend
 --
 

diff  --git a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td 
b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
index 0c6646c01ae22..8c0f25b088787 100644
--- a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
+++ b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
@@ -308,6 +308,15 @@ def int_amdgcn_log : Defaul

[PATCH] D152901: AMDGPU: Add llvm.amdgcn.exp2 intrinsic

2023-06-15 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm closed this revision.
arsenm added a comment.

28f3edd2be2a27b9dc7739d137147007c5fd9e41 



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

https://reviews.llvm.org/D152901

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


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

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

Bump CI.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152879

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

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


[PATCH] D153008: [RISCV] Allow slash-star comments in instruction operands

2023-06-15 Thread Abel Bernabeu via Phabricator via cfe-commits
abel-bernabeu added a comment.

For the customer who reported the problem, the comments are in the input source 
(doing their job explaining what the operands are).

Now, if that comment is not seen when compiling with "-S" it is less of a 
problem that having the compilation not succeeding. I did not see an obvious 
way to pass those coments to the AsmParser instance.

My understanding is that the ParseInstruction interface needs to be extended 
for the comments to be collected and passed to the top level parser (similarly 
to what is done with the operands).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153008

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


[PATCH] D152889: [2/2][RISCV] Model vxrm control for vsadd, vsaddu, vssub, and vssubu

2023-06-15 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 531691.
eopXD edited the summary of this revision.
eopXD added a comment.
Herald added subscribers: qcolombet, MatzeB.

Changes:

- Change value to omit vxrm write from 4 to 99
- Resolve test case failure
- Be consistent on template naming


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152889

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsaddu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssubu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsaddu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vssub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vssubu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vsadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vsaddu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vssub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vssubu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vsadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vsaddu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vssub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vssubu.c
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/RISCVInsertReadWriteCSR.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
  llvm/test/CodeGen/RISCV/regalloc-last-chance-recoloring-failure.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tama.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tamu.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tuma.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tumu.ll
  llvm/test/CodeGen/RISCV/rvv/rvv-peephole-vmerge-vops.ll
  llvm/test/CodeGen/RISCV/rvv/unmasked-tu.ll
  llvm/test/CodeGen/RISCV/rvv/vsadd-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vsadd-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vsaddu-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vsaddu-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vssub-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vssub-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vssubu-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vssubu-rv64.ll

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


[PATCH] D152813: [clang][dataflow] Create `Value`s for integer literals.

2023-06-15 Thread Martin Böhme via Phabricator via cfe-commits
mboehme updated this revision to Diff 531694.
mboehme added a comment.

Always return the same `Value` for the same integer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152813

Files:
  clang/include/clang/Analysis/FlowSensitive/Arena.h
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
  clang/lib/Analysis/FlowSensitive/Arena.cpp
  clang/lib/Analysis/FlowSensitive/Transfer.cpp
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -811,6 +811,31 @@
   });
 }
 
+TEST(TransferTest, BinaryOperatorAssignIntegerLiteral) {
+  std::string Code = R"(
+void target() {
+  int Foo = 1;
+  // [[before]]
+  Foo = 2;
+  // [[after]]
+}
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+const Environment &Before =
+getEnvironmentAtAnnotation(Results, "before");
+const Environment &After = getEnvironmentAtAnnotation(Results, "after");
+
+const auto &ValBefore =
+getValueForDecl(ASTCtx, Before, "Foo");
+const auto &ValAfter =
+getValueForDecl(ASTCtx, After, "Foo");
+EXPECT_NE(&ValBefore, &ValAfter);
+  });
+}
+
 TEST(TransferTest, VarDeclInitAssign) {
   std::string Code = R"(
 void target() {
@@ -3441,6 +3466,24 @@
   });
 }
 
+TEST(TransferTest, IntegerLiteralEquality) {
+  std::string Code = R"(
+void target() {
+  bool equal = (42 == 42);
+  // [[p]]
+}
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+const Environment &Env = getEnvironmentAtAnnotation(Results, "p");
+
+auto &Equal = getValueForDecl(ASTCtx, Env, "equal");
+EXPECT_TRUE(Env.flowConditionImplies(Equal));
+  });
+}
+
 TEST(TransferTest, CorrelatedBranches) {
   std::string Code = R"(
 void target(bool B, bool C) {
Index: clang/lib/Analysis/FlowSensitive/Transfer.cpp
===
--- clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -48,9 +48,15 @@
 
 static BoolValue &evaluateBooleanEquality(const Expr &LHS, const Expr &RHS,
   Environment &Env) {
-  if (auto *LHSValue = dyn_cast_or_null(Env.getValueStrict(LHS)))
-if (auto *RHSValue = dyn_cast_or_null(Env.getValueStrict(RHS)))
-  return Env.makeIff(*LHSValue, *RHSValue);
+  Value *LHSValue = Env.getValueStrict(LHS);
+  Value *RHSValue = Env.getValueStrict(RHS);
+
+  if (LHSValue == RHSValue)
+return Env.getBoolLiteralValue(true);
+
+  if (auto *LHSBool = dyn_cast_or_null(LHSValue))
+if (auto *RHSBool = dyn_cast_or_null(RHSValue))
+  return Env.makeIff(*LHSBool, *RHSBool);
 
   return Env.makeAtomicBoolValue();
 }
@@ -775,6 +781,10 @@
 Env.setValueStrict(*S, Env.getBoolLiteralValue(S->getValue()));
   }
 
+  void VisitIntegerLiteral(const IntegerLiteral *S) {
+Env.setValueStrict(*S, Env.getIntLiteralValue(S->getValue()));
+  }
+
   void VisitParenExpr(const ParenExpr *S) {
 // The CFG does not contain `ParenExpr` as top-level statements in basic
 // blocks, however manual traversal to sub-expressions may encounter them.
Index: clang/lib/Analysis/FlowSensitive/Arena.cpp
===
--- clang/lib/Analysis/FlowSensitive/Arena.cpp
+++ clang/lib/Analysis/FlowSensitive/Arena.cpp
@@ -68,4 +68,12 @@
   return *Res.first->second;
 }
 
+IntegerValue &Arena::makeIntLiteral(llvm::APInt Value) {
+  auto [It, Inserted] = IntegerLiterals.try_emplace(Value, nullptr);
+
+  if (Inserted)
+It->second = &create();
+  return *It->second;
+}
+
 } // namespace clang::dataflow
Index: clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
===
--- clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
+++ clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
@@ -448,6 +448,12 @@
 return DACtx->arena().create(std::forward(args)...);
   }
 
+  /// Returns a symbolic integer value that models an integer literal equal to
+  /// `Value`
+  IntegerValue &getIntLiteralValue(llvm::APInt Value) const {
+return DACtx->arena().makeIntLiteral(Value);
+  }
+
   /// Returns a symbolic boolean value that models a boolean literal equal to
   /// `Value`
   AtomicBoolValue &getBoolLiteralValue(bool Value) const {
Index: clang/include/clang/Analysis/FlowSensitive/Arena.h
===
--- clang/include/clang/Analysis/Flo

[PATCH] D152813: [clang][dataflow] Create `Value`s for integer literals.

2023-06-15 Thread Martin Böhme via Phabricator via cfe-commits
mboehme added a comment.

PTAL


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152813

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


[PATCH] D148827: -fsanitize=function: support C

2023-06-15 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added a comment.

Hi,

A question: it seems like this messes with alignment on functions?
So with input program al.c:

  __attribute__((aligned(64)))
  void alignedfn(void) {
__asm("nop");
  }
  void alignedfn2(void) {
__asm("nop");
  }
  int main(void){}

if we compile with -fsanitize=function we get:

  -> clang al.c -o al.o -c -fsanitize=function
  -> nm al.o
  0008 T alignedfn
  0018 T alignedfn2
  0028 T main

So alignedfn and alignedfn2 doesn't seem to be aligned as we said.
Without -fsanitize=function:

  -> clang al.c -o al.o -c 
  -> nm al.o
   T alignedfn
  0010 T alignedfn2
  0020 T main

I guess the data put before the functions get aligned but not the functions 
themselves. Should I write a ticket about this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148827

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


[clang] 976d8b4 - [clang][Interp] Virtual function calls

2023-06-15 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-06-15T13:33:43+02:00
New Revision: 976d8b40cccf4678fe8c414210ce82170049b715

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

LOG: [clang][Interp] Virtual function calls

Add a CallVirt opcode and implement virtual function calls this way.

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

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeExprGen.cpp
clang/lib/AST/Interp/Context.cpp
clang/lib/AST/Interp/Context.h
clang/lib/AST/Interp/Descriptor.cpp
clang/lib/AST/Interp/Function.h
clang/lib/AST/Interp/Interp.h
clang/lib/AST/Interp/InterpState.h
clang/lib/AST/Interp/Opcodes.td
clang/lib/AST/Interp/Pointer.h
clang/test/AST/Interp/records.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index 1be131be66e3b..94db8b868758e 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1711,12 +1711,24 @@ bool ByteCodeExprGen::VisitCallExpr(const 
CallExpr *E) {
 
 assert(HasRVO == Func->hasRVO());
 
+bool HasQualifier = false;
+if (const auto *ME = dyn_cast(E->getCallee()))
+  HasQualifier = ME->hasQualifier();
+
+bool IsVirtual = false;
+if (const auto *MD = dyn_cast(FuncDecl))
+  IsVirtual = MD->isVirtual();
+
 // In any case call the function. The return value will end up on the stack
 // and if the function has RVO, we already have the pointer on the stack to
 // write the result into.
-if (!this->emitCall(Func, E))
-  return false;
-
+if (IsVirtual && !HasQualifier) {
+  if (!this->emitCallVirt(Func, E))
+return false;
+} else {
+  if (!this->emitCall(Func, E))
+return false;
+}
   } else {
 // Indirect call. Visit the callee, which will leave a FunctionPointer on
 // the stack. Cleanup of the returned value if necessary will be done after

diff  --git a/clang/lib/AST/Interp/Context.cpp 
b/clang/lib/AST/Interp/Context.cpp
index ed7ed41b1b24d..67fb69e663382 100644
--- a/clang/lib/AST/Interp/Context.cpp
+++ b/clang/lib/AST/Interp/Context.cpp
@@ -158,3 +158,38 @@ bool Context::Check(State &Parent, llvm::Expected 
&&Flag) {
   });
   return false;
 }
+
+// TODO: Virtual bases?
+const CXXMethodDecl *
+Context::getOverridingFunction(const CXXRecordDecl *DynamicDecl,
+   const CXXRecordDecl *StaticDecl,
+   const CXXMethodDecl *InitialFunction) const {
+
+  const CXXRecordDecl *CurRecord = DynamicDecl;
+  const CXXMethodDecl *FoundFunction = InitialFunction;
+  for (;;) {
+const CXXMethodDecl *Overrider =
+FoundFunction->getCorrespondingMethodDeclaredInClass(CurRecord, false);
+if (Overrider)
+  return Overrider;
+
+// Common case of only one base class.
+if (CurRecord->getNumBases() == 1) {
+  CurRecord = CurRecord->bases_begin()->getType()->getAsCXXRecordDecl();
+  continue;
+}
+
+// Otherwise, go to the base class that will lead to the StaticDecl.
+for (const CXXBaseSpecifier &Spec : CurRecord->bases()) {
+  const CXXRecordDecl *Base = Spec.getType()->getAsCXXRecordDecl();
+  if (Base == StaticDecl || Base->isDerivedFrom(StaticDecl)) {
+CurRecord = Base;
+break;
+  }
+}
+  }
+
+  llvm_unreachable(
+  "Couldn't find an overriding function in the class hierarchy?");
+  return nullptr;
+}

diff  --git a/clang/lib/AST/Interp/Context.h b/clang/lib/AST/Interp/Context.h
index cbae7fcf2860a..107bb75a46247 100644
--- a/clang/lib/AST/Interp/Context.h
+++ b/clang/lib/AST/Interp/Context.h
@@ -63,6 +63,11 @@ class Context final {
   /// Classifies an expression.
   std::optional classify(QualType T) const;
 
+  const CXXMethodDecl *
+  getOverridingFunction(const CXXRecordDecl *DynamicDecl,
+const CXXRecordDecl *StaticDecl,
+const CXXMethodDecl *InitialFunction) const;
+
 private:
   /// Runs a function.
   bool Run(State &Parent, Function *Func, APValue &Result);

diff  --git a/clang/lib/AST/Interp/Descriptor.cpp 
b/clang/lib/AST/Interp/Descriptor.cpp
index a6bef77bf8c16..565c4b2003847 100644
--- a/clang/lib/AST/Interp/Descriptor.cpp
+++ b/clang/lib/AST/Interp/Descriptor.cpp
@@ -274,6 +274,8 @@ QualType Descriptor::getType() const {
 return E->getType();
   if (auto *D = asValueDecl())
 return D->getType();
+  if (auto *T = dyn_cast(asDecl()))
+return QualType(T->getTypeForDecl(), 0);
   llvm_unreachable("Invalid descriptor type");
 }
 

diff  --git a/clang/lib/AST/Interp/Function.h b/clang/lib/AST/Interp/Function.h
index 005cda7379c2d..6fde5a616dec0 100644
--- a/clang/lib/AST/Interp/Function.h
+++ b/clang/lib/AST/Interp/Functi

[PATCH] D142630: [clang][Interp] Implement virtual function calls

2023-06-15 Thread Timm Bäder via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG976d8b40cccf: [clang][Interp] Virtual function calls 
(authored by tbaeder).

Changed prior to commit:
  https://reviews.llvm.org/D142630?vs=527336&id=531697#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142630

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/Context.cpp
  clang/lib/AST/Interp/Context.h
  clang/lib/AST/Interp/Descriptor.cpp
  clang/lib/AST/Interp/Function.h
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/InterpState.h
  clang/lib/AST/Interp/Opcodes.td
  clang/lib/AST/Interp/Pointer.h
  clang/test/AST/Interp/records.cpp

Index: clang/test/AST/Interp/records.cpp
===
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -1,8 +1,10 @@
 // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify %s
 // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -std=c++14 -verify %s
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -std=c++20 -verify %s
 // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -triple i686 -verify %s
 // RUN: %clang_cc1 -verify=ref %s
 // RUN: %clang_cc1 -verify=ref -std=c++14 %s
+// RUN: %clang_cc1 -verify=ref -std=c++20 %s
 // RUN: %clang_cc1 -verify=ref -triple i686 %s
 
 struct BoolPair {
@@ -380,6 +382,7 @@
 };
 
 namespace DeriveFailures {
+#if __cplusplus < 202002L
   struct Base { // ref-note 2{{declared here}} expected-note {{declared here}}
 int Val;
   };
@@ -397,10 +400,12 @@
// ref-note {{declared here}} \
// expected-error {{must be initialized by a constant expression}} \
// expected-note {{in call to 'Derived(12)'}}
+
   static_assert(D.Val == 0, ""); // ref-error {{not an integral constant expression}} \
  // ref-note {{initializer of 'D' is not a constant expression}} \
  // expected-error {{not an integral constant expression}} \
  // expected-note {{read of object outside its lifetime}}
+#endif
 
   struct AnotherBase {
 int Val;
@@ -488,3 +493,201 @@
   //static_assert(b.a.m == 100, "");
   //static_assert(b.a.f == 100, "");
 }
+
+#if __cplusplus >= 202002L
+namespace VirtualCalls {
+namespace Obvious {
+
+  class A {
+  public:
+constexpr A(){}
+constexpr virtual int foo() {
+  return 3;
+}
+  };
+  class B : public A {
+  public:
+constexpr int foo() override {
+  return 6;
+}
+  };
+
+  constexpr int getFooB(bool b) {
+A *a;
+A myA;
+B myB;
+
+if (b)
+  a = &myA;
+else
+  a = &myB;
+
+return a->foo();
+  }
+  static_assert(getFooB(true) == 3, "");
+  static_assert(getFooB(false) == 6, "");
+}
+
+namespace MultipleBases {
+  class A {
+  public:
+constexpr virtual int getInt() const { return 10; }
+  };
+  class B {
+  public:
+  };
+  class C : public A, public B {
+  public:
+constexpr int getInt() const override { return 20; }
+  };
+
+  constexpr int callGetInt(const A& a) { return a.getInt(); }
+  static_assert(callGetInt(C()) == 20, "");
+  static_assert(callGetInt(A()) == 10, "");
+}
+
+namespace Destructors {
+  class Base {
+  public:
+int i;
+constexpr Base(int &i) : i(i) {i++;}
+constexpr virtual ~Base() {i--;}
+  };
+
+  class Derived : public Base {
+  public:
+constexpr Derived(int &i) : Base(i) {}
+constexpr virtual ~Derived() {i--;}
+  };
+
+  constexpr int test() {
+int i = 0;
+Derived d(i);
+return i;
+  }
+  static_assert(test() == 1);
+}
+
+
+namespace VirtualDtors {
+  class A {
+  public:
+unsigned &v;
+constexpr A(unsigned &v) : v(v) {}
+constexpr virtual ~A() {
+  v |= (1 << 0);
+}
+  };
+  class B : public A {
+  public:
+constexpr B(unsigned &v) : A(v) {}
+constexpr virtual ~B() {
+  v |= (1 << 1);
+}
+  };
+  class C : public B {
+  public:
+constexpr C(unsigned &v) : B(v) {}
+constexpr virtual ~C() {
+  v |= (1 << 2);
+}
+  };
+
+  constexpr bool foo() {
+unsigned a = 0;
+{
+  C c(a);
+}
+return ((a & (1 << 0)) && (a & (1 << 1)) && (a & (1 << 2)));
+  }
+
+  static_assert(foo());
+
+
+};
+
+namespace QualifiedCalls {
+  class A {
+  public:
+  constexpr virtual int foo() const {
+  return 5;
+  }
+  };
+  class B : public A {};
+  class C : public B {
+  public:
+  constexpr int foo() const override {
+  return B::foo(); // B doesn't have a foo(), so this should call A::foo().
+  }
+  constexpr int foo2() const {
+return this->A::foo();
+  }
+  };
+  constexpr C c;
+  static_assert(c.foo() == 5);
+  static_assert(c.foo2() == 5);
+
+
+  struct S {
+int _c = 0;
+virtual constexpr int

[PATCH] D152548: [Clang][Interp] Diagnose uninitialized ctor of global record arrays

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



Comment at: clang/test/AST/Interp/cxx20.cpp:177
+ // ref-note {{subobject 'f' is not initialized}}
+
 

We usually have a space after the `;` and keep the comments aligned on the `//`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152548

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


[clang] 0f6110a - No longer diagnose (functionally) empty structures under -Wuninitialized

2023-06-15 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2023-06-15T07:43:31-04:00
New Revision: 0f6110a4a4250f3d684e166b2d3279fbe4a1f239

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

LOG: No longer diagnose (functionally) empty structures under -Wuninitialized

An empty structure in C has no way to be initialized, so triggering a
-Wuninitialized warning for a variable of empty structure type is not
actionable for users. This silences the false positive warning, which
matches the behavior of GCC as well.

We no longer diagnose if the structure has no members, or has only
zero-sized members (unnamed bit-fields, zero-sized bit-fields, empty
structure types).

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Analysis/UninitializedValues.cpp
clang/test/Sema/uninit-variables.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3cfacb07bbaa1..451835f8bb39a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -347,6 +347,9 @@ Improvements to Clang's diagnostics
 - When diagnosing a constant expression where an enum without a fixed 
underlying
   type is set to a value outside the range of the enum's values, clang will now
   print the name of the enum in question.
+- Clang no longer diagnoses a read of an empty structure as use of an
+  uninitialized variable.
+  (`#26842: `_)
 
 Bug Fixes in This Version
 -

diff  --git a/clang/lib/Analysis/UninitializedValues.cpp 
b/clang/lib/Analysis/UninitializedValues.cpp
index 87765db0c5b2f..3c097f44761f1 100644
--- a/clang/lib/Analysis/UninitializedValues.cpp
+++ b/clang/lib/Analysis/UninitializedValues.cpp
@@ -40,13 +40,31 @@ using namespace clang;
 
 #define DEBUG_LOGGING 0
 
+static bool recordIsNotEmpty(const RecordDecl *RD) {
+  // We consider a record decl to be empty if it contains only unnamed bit-
+  // fields, zero-width fields, and fields of empty record type.
+  for (const auto *FD : RD->fields()) {
+if (FD->isUnnamedBitfield())
+  continue;
+if (FD->isZeroSize(FD->getASTContext()))
+  continue;
+// The only case remaining to check is for a field declaration of record
+// type and whether that record itself is empty.
+if (const auto *FieldRD = FD->getType()->getAsRecordDecl();
+!FieldRD || recordIsNotEmpty(FieldRD))
+  return true;
+  }
+  return false;
+}
+
 static bool isTrackedVar(const VarDecl *vd, const DeclContext *dc) {
   if (vd->isLocalVarDecl() && !vd->hasGlobalStorage() &&
-  !vd->isExceptionVariable() && !vd->isInitCapture() &&
-  !vd->isImplicit() && vd->getDeclContext() == dc) {
+  !vd->isExceptionVariable() && !vd->isInitCapture() && !vd->isImplicit() 
&&
+  vd->getDeclContext() == dc) {
 QualType ty = vd->getType();
-return ty->isScalarType() || ty->isVectorType() || ty->isRecordType() ||
-   ty->isRVVType();
+if (const auto *RD = ty->getAsRecordDecl())
+  return recordIsNotEmpty(RD);
+return ty->isScalarType() || ty->isVectorType() || ty->isRVVType();
   }
   return false;
 }

diff  --git a/clang/test/Sema/uninit-variables.c 
b/clang/test/Sema/uninit-variables.c
index fa471499a4375..cba8ee7b19989 100644
--- a/clang/test/Sema/uninit-variables.c
+++ b/clang/test/Sema/uninit-variables.c
@@ -532,3 +532,22 @@ void test_analyzer_noreturn_2(int y) {
   }
   ++x; // no-warning
 }
+
+// Do not diagnose (functionally) empty structures as being uninitalized
+// variables; see GH26842
+struct empty {};
+struct full_of_empty {
+  int : 0;
+  int : 12;
+  struct empty e;
+};
+
+struct empty empty_test_1(void) {
+  struct empty e;
+  return e; // no-warning
+}
+
+struct full_of_empty empty_test_2(void) {
+  struct full_of_empty e;
+  return e; // no-warning
+}



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


[PATCH] D153013: [clang-tidy] Correct the include-cleaner-check diagnostic message for missing-includes.

2023-06-15 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: VitaNuo.
Herald added subscribers: PiotrZSL, kadircet, carlosgalvezp, arphaman, 
xazax.hun.
Herald added a reviewer: njames93.
Herald added a project: All.
hokein requested review of this revision.
Herald added a project: clang-tools-extra.

We should print the symbol name rather than the header name in the
message.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153013

Files:
  clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
  clang-tools-extra/include-cleaner/lib/Types.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp
@@ -10,8 +10,8 @@
 // CHECK-FIXES: {{^}}
 int BarResult = bar();
 int BazResult = baz();
-// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: no header providing "baz.h" is directly included [misc-include-cleaner]
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: no header providing "baz" is directly included [misc-include-cleaner]
 std::string HelloString;
-// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: no header providing  is directly included [misc-include-cleaner]
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: no header providing "std::string" is directly included [misc-include-cleaner]
 int FooBarResult = foobar();
-// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: no header providing "public.h" is directly included [misc-include-cleaner]
+// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: no header providing "foobar" is directly included [misc-include-cleaner]
Index: clang-tools-extra/include-cleaner/lib/Types.cpp
===
--- clang-tools-extra/include-cleaner/lib/Types.cpp
+++ clang-tools-extra/include-cleaner/lib/Types.cpp
@@ -15,6 +15,17 @@
 
 namespace clang::include_cleaner {
 
+std::string Symbol::name() const {
+  switch (kind()) {
+  case include_cleaner::Symbol::Macro:
+return macro().Name->getName().str();
+  case include_cleaner::Symbol::Declaration:
+return llvm::dyn_cast(&declaration())
+->getQualifiedNameAsString();
+  }
+  llvm_unreachable("Unknown symbol kind");
+}
+
 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Symbol &S) {
   switch (S.kind()) {
   case Symbol::Declaration:
Index: clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
===
--- clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
+++ clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
@@ -67,6 +67,7 @@
 
   const Decl &declaration() const { return *std::get(Storage); }
   struct Macro macro() const { return std::get(Storage); }
+  std::string name() const;
 
 private:
   // Order must match Kind enum!
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -144,17 +144,6 @@
   llvm_unreachable("Unknown header kind");
 }
 
-std::string getSymbolName(const include_cleaner::Symbol &Sym) {
-  switch (Sym.kind()) {
-  case include_cleaner::Symbol::Macro:
-return Sym.macro().Name->getName().str();
-  case include_cleaner::Symbol::Declaration:
-return llvm::dyn_cast(&Sym.declaration())
-->getQualifiedNameAsString();
-  }
-  llvm_unreachable("Unknown symbol kind");
-}
-
 std::vector generateMissingIncludeDiagnostics(
 ParsedAST &AST, llvm::ArrayRef MissingIncludes,
 llvm::StringRef Code, HeaderFilter IgnoreHeaders) {
@@ -199,7 +188,7 @@
 Diag &D = Result.emplace_back();
 D.Message =
 llvm::formatv("No header providing \"{0}\" is directly included",
-  getSymbolName(SymbolWithMissingInclude.Symbol));
+  SymbolWithMissingInclude.Symbol.name());
 D.Name = "missing-includes";
 D.Source = Diag::DiagSource::Clangd;
 D.File = AST.tuPath();
Index: clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
@@ -46,6 +46,7 @@
 namespace {
 struct MissingIncludeInfo {
   SourceLocation SymRefLocation;
+  include_cleaner::Symbol Sym;
   include_cleaner::Header Missing;
 };
 } // namespace
@@ -115,27 +116,27 @@
   }
   // FIXME: Find a way to have less code duplication between include-cleaner
   // analysis implementation and the below code.
-  walkUsed(MainFileDecls, RecordedPreprocessor.MacroReferenc

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

2023-06-15 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 531701.
eopXD edited the summary of this revision.
eopXD added a comment.

Resolve test case failures.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152996

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/include/clang/Basic/riscv_vector_common.td
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Sema/SemaRISCVVectorLookup.cpp
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vfadd.c
  clang/utils/TableGen/RISCVVEmitter.cpp
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
  llvm/lib/Target/RISCV/RISCVInsertReadWriteCSR.cpp
  llvm/lib/Target/RISCV/RISCVInstrFormats.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
  llvm/test/CodeGen/RISCV/rvv/vfadd.ll

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


[PATCH] D152263: [clang][CFG] Add support for partitioning CFG into intervals.

2023-06-15 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 531702.
ymandel added a comment.

Expand comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152263

Files:
  clang/include/clang/Analysis/Analyses/IntervalPartition.h
  clang/lib/Analysis/CMakeLists.txt
  clang/lib/Analysis/IntervalPartition.cpp
  clang/unittests/Analysis/CMakeLists.txt
  clang/unittests/Analysis/IntervalPartitionTest.cpp

Index: clang/unittests/Analysis/IntervalPartitionTest.cpp
===
--- /dev/null
+++ clang/unittests/Analysis/IntervalPartitionTest.cpp
@@ -0,0 +1,164 @@
+//===- unittests/Analysis/IntervalPartitionTest.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Analysis/Analyses/IntervalPartition.h"
+#include "CFGBuildResult.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace analysis {
+namespace {
+
+TEST(BuildInterval, PartitionSimpleOneInterval) {
+
+  const char *Code = R"(void f() {
+  int x = 3;
+  int y = 7;
+  x = y + x;
+})";
+  BuildResult Result = BuildCFG(Code);
+  EXPECT_EQ(BuildResult::BuiltCFG, Result.getStatus());
+
+  CFG *cfg = Result.getCFG();
+
+  // Basic correctness checks.
+  ASSERT_EQ(cfg->size(), 3u);
+
+  auto &EntryBlock = cfg->getEntry();
+
+  CFGInterval I = buildInterval(EntryBlock);
+  EXPECT_EQ(I.Blocks.size(), 3u);
+}
+
+TEST(BuildInterval, PartitionIfThenOneInterval) {
+
+  const char *Code = R"(void f() {
+  int x = 3;
+  if (x > 3)
+x = 2;
+  else
+x = 7;
+  x = x + x;
+})";
+  BuildResult Result = BuildCFG(Code);
+  EXPECT_EQ(BuildResult::BuiltCFG, Result.getStatus());
+
+  CFG *cfg = Result.getCFG();
+
+  // Basic correctness checks.
+  ASSERT_EQ(cfg->size(), 6u);
+
+  auto &EntryBlock = cfg->getEntry();
+
+  CFGInterval I = buildInterval(EntryBlock);
+  EXPECT_EQ(I.Blocks.size(), 6u);
+}
+
+using ::testing::UnorderedElementsAre;
+
+TEST(BuildInterval, PartitionWhileMultipleIntervals) {
+
+  const char *Code = R"(void f() {
+  int x = 3;
+  while (x >= 3)
+--x;
+  x = x + x;
+})";
+  BuildResult Result = BuildCFG(Code);
+  ASSERT_EQ(BuildResult::BuiltCFG, Result.getStatus());
+
+  CFG *cfg = Result.getCFG();
+  ASSERT_EQ(cfg->size(), 7u);
+
+  auto *EntryBlock = &cfg->getEntry();
+  CFGBlock *InitXBlock = *EntryBlock->succ_begin();
+  CFGBlock *LoopHeadBlock = *InitXBlock->succ_begin();
+
+  CFGInterval I1 = buildInterval(*EntryBlock);
+  EXPECT_THAT(I1.Blocks, UnorderedElementsAre(EntryBlock, InitXBlock));
+
+  CFGInterval I2 = buildInterval(*LoopHeadBlock);
+  EXPECT_EQ(I2.Blocks.size(), 5u);
+}
+
+TEST(PartitionIntoIntervals, PartitionIfThenOneInterval) {
+  const char *Code = R"(void f() {
+  int x = 3;
+  if (x > 3)
+x = 2;
+  else
+x = 7;
+  x = x + x;
+})";
+  BuildResult Result = BuildCFG(Code);
+  ASSERT_EQ(BuildResult::BuiltCFG, Result.getStatus());
+
+  CFG *cfg = Result.getCFG();
+  ASSERT_EQ(cfg->size(), 6u);
+
+  auto Intervals = partitionIntoIntervals(*cfg);
+  EXPECT_EQ(Intervals.size(), 1u);
+}
+
+TEST(PartitionIntoIntervals, PartitionWhileTwoIntervals) {
+  const char *Code = R"(void f() {
+  int x = 3;
+  while (x >= 3)
+--x;
+  x = x + x;
+})";
+  BuildResult Result = BuildCFG(Code);
+  ASSERT_EQ(BuildResult::BuiltCFG, Result.getStatus());
+
+  CFG *cfg = Result.getCFG();
+  ASSERT_EQ(cfg->size(), 7u);
+
+  auto Intervals = partitionIntoIntervals(*cfg);
+  EXPECT_EQ(Intervals.size(), 2u);
+}
+
+TEST(PartitionIntoIntervals, PartitionNestedWhileThreeIntervals) {
+  const char *Code = R"(void f() {
+  int x = 3;
+  while (x >= 3) {
+--x;
+int y = x;
+while (y > 0) --y;
+  }
+  x = x + x;
+})";
+  BuildResult Result = BuildCFG(Code);
+  ASSERT_EQ(BuildResult::BuiltCFG, Result.getStatus());
+
+  CFG *cfg = Result.getCFG();
+  auto Int

[clang] e96bec9 - [OpenMP] Correctly diagnose conflicting target identifierers for AMDGPU

2023-06-15 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2023-06-15T07:06:44-05:00
New Revision: e96bec9cd8e14ee2174490c0ce09cedfcd6be79e

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

LOG: [OpenMP] Correctly diagnose conflicting target identifierers for AMDGPU

There are static checks on the target identifiers allowed in a single
TU. Previously theses checks were only applied to HIP even though they
should be the same for OpenMP targeting AMDGPU. Simply enable these
checks for OpenMP.

Reviewed By: JonChesterfield, yaxunl

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

Added: 


Modified: 
clang/lib/Driver/Driver.cpp
clang/test/Driver/amdgpu-openmp-toolchain.c

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 8f92606960b3a..9fc62be357a60 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -4313,8 +4313,8 @@ static StringRef getCanonicalArchString(Compilation &C,
 /// incompatible pair if a conflict occurs.
 static std::optional>
 getConflictOffloadArchCombination(const llvm::DenseSet &Archs,
-  Action::OffloadKind Kind) {
-  if (Kind != Action::OFK_HIP)
+  llvm::Triple Triple) {
+  if (!Triple.isAMDGPU())
 return std::nullopt;
 
   std::set ArchSet;
@@ -4399,7 +4399,8 @@ Driver::getOffloadArchs(Compilation &C, const 
llvm::opt::DerivedArgList &Args,
 }
   }
 
-  if (auto ConflictingArchs = getConflictOffloadArchCombination(Archs, Kind)) {
+  if (auto ConflictingArchs =
+  getConflictOffloadArchCombination(Archs, TC->getTriple())) {
 C.getDriver().Diag(clang::diag::err_drv_bad_offload_arch_combo)
 << ConflictingArchs->first << ConflictingArchs->second;
 C.setContainsError();

diff  --git a/clang/test/Driver/amdgpu-openmp-toolchain.c 
b/clang/test/Driver/amdgpu-openmp-toolchain.c
index 08ad3a011347d..9a14f4594cfb5 100644
--- a/clang/test/Driver/amdgpu-openmp-toolchain.c
+++ b/clang/test/Driver/amdgpu-openmp-toolchain.c
@@ -66,3 +66,7 @@
 // RUN: %clang -### -target x86_64-pc-linux-gnu -fopenmp 
--offload-arch=gfx90a:sramecc-:xnack+ \
 // RUN:   -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-TARGET-ID
 // CHECK-TARGET-ID: 
clang-offload-packager{{.*}}arch=gfx90a,kind=openmp,feature=-sramecc,feature=+xnack
+
+// RUN: not %clang -### -target x86_64-pc-linux-gnu -fopenmp 
--offload-arch=gfx90a,gfx90a:xnack+ \
+// RUN:   -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-TARGET-ID-ERROR
+// CHECK-TARGET-ID-ERROR: error: invalid offload arch combinations: 'gfx90a' 
and 'gfx90a:xnack+'



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


[PATCH] D152965: [OpenMP] Correctly diagnose conflicting target identifierers for AMDGPU

2023-06-15 Thread Joseph Huber via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe96bec9cd8e1: [OpenMP] Correctly diagnose conflicting target 
identifierers for AMDGPU (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152965

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/amdgpu-openmp-toolchain.c


Index: clang/test/Driver/amdgpu-openmp-toolchain.c
===
--- clang/test/Driver/amdgpu-openmp-toolchain.c
+++ clang/test/Driver/amdgpu-openmp-toolchain.c
@@ -66,3 +66,7 @@
 // RUN: %clang -### -target x86_64-pc-linux-gnu -fopenmp 
--offload-arch=gfx90a:sramecc-:xnack+ \
 // RUN:   -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-TARGET-ID
 // CHECK-TARGET-ID: 
clang-offload-packager{{.*}}arch=gfx90a,kind=openmp,feature=-sramecc,feature=+xnack
+
+// RUN: not %clang -### -target x86_64-pc-linux-gnu -fopenmp 
--offload-arch=gfx90a,gfx90a:xnack+ \
+// RUN:   -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-TARGET-ID-ERROR
+// CHECK-TARGET-ID-ERROR: error: invalid offload arch combinations: 'gfx90a' 
and 'gfx90a:xnack+'
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -4313,8 +4313,8 @@
 /// incompatible pair if a conflict occurs.
 static std::optional>
 getConflictOffloadArchCombination(const llvm::DenseSet &Archs,
-  Action::OffloadKind Kind) {
-  if (Kind != Action::OFK_HIP)
+  llvm::Triple Triple) {
+  if (!Triple.isAMDGPU())
 return std::nullopt;
 
   std::set ArchSet;
@@ -4399,7 +4399,8 @@
 }
   }
 
-  if (auto ConflictingArchs = getConflictOffloadArchCombination(Archs, Kind)) {
+  if (auto ConflictingArchs =
+  getConflictOffloadArchCombination(Archs, TC->getTriple())) {
 C.getDriver().Diag(clang::diag::err_drv_bad_offload_arch_combo)
 << ConflictingArchs->first << ConflictingArchs->second;
 C.setContainsError();


Index: clang/test/Driver/amdgpu-openmp-toolchain.c
===
--- clang/test/Driver/amdgpu-openmp-toolchain.c
+++ clang/test/Driver/amdgpu-openmp-toolchain.c
@@ -66,3 +66,7 @@
 // RUN: %clang -### -target x86_64-pc-linux-gnu -fopenmp --offload-arch=gfx90a:sramecc-:xnack+ \
 // RUN:   -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-TARGET-ID
 // CHECK-TARGET-ID: clang-offload-packager{{.*}}arch=gfx90a,kind=openmp,feature=-sramecc,feature=+xnack
+
+// RUN: not %clang -### -target x86_64-pc-linux-gnu -fopenmp --offload-arch=gfx90a,gfx90a:xnack+ \
+// RUN:   -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-TARGET-ID-ERROR
+// CHECK-TARGET-ID-ERROR: error: invalid offload arch combinations: 'gfx90a' and 'gfx90a:xnack+'
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -4313,8 +4313,8 @@
 /// incompatible pair if a conflict occurs.
 static std::optional>
 getConflictOffloadArchCombination(const llvm::DenseSet &Archs,
-  Action::OffloadKind Kind) {
-  if (Kind != Action::OFK_HIP)
+  llvm::Triple Triple) {
+  if (!Triple.isAMDGPU())
 return std::nullopt;
 
   std::set ArchSet;
@@ -4399,7 +4399,8 @@
 }
   }
 
-  if (auto ConflictingArchs = getConflictOffloadArchCombination(Archs, Kind)) {
+  if (auto ConflictingArchs =
+  getConflictOffloadArchCombination(Archs, TC->getTriple())) {
 C.getDriver().Diag(clang::diag::err_drv_bad_offload_arch_combo)
 << ConflictingArchs->first << ConflictingArchs->second;
 C.setContainsError();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D152995: Remove clang/ModuleInfo.txt

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

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152995

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


[PATCH] D144004: [DebugMetadata][DwarfDebug] Fix DWARF emisson of function-local imported entities (3/7)

2023-06-15 Thread Vladislav Dzhidzhoev 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 rGd04452d54829: [DebugMetadata][DwarfDebug] Fix DWARF emisson 
of function-local imported… (authored by dzhidzhoev).

Changed prior to commit:
  https://reviews.llvm.org/D144004?vs=529098&id=531708#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144004

Files:
  clang/test/CodeGenCXX/debug-info-namespace.cpp
  llvm/include/llvm/IR/DIBuilder.h
  llvm/lib/Bitcode/Reader/MetadataLoader.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
  llvm/lib/CodeGen/AsmPrinter/DwarfFile.h
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
  llvm/lib/IR/DIBuilder.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Linker/IRMover.cpp
  llvm/test/Bitcode/DIModule-fortran-external-module.ll
  llvm/test/Bitcode/upgrade-cu-locals.ll
  llvm/test/Bitcode/upgrade-cu-locals.ll.bc
  llvm/test/CodeGen/Generic/DbgValueAggregate.ll
  llvm/test/DebugInfo/Generic/import-inlined-declaration.ll
  llvm/test/DebugInfo/Generic/imported-name-inlined.ll
  llvm/test/DebugInfo/Generic/namespace.ll
  llvm/test/DebugInfo/Generic/split-dwarf-local-import.ll
  llvm/test/DebugInfo/Generic/split-dwarf-local-import2.ll
  llvm/test/DebugInfo/Generic/split-dwarf-local-import3.ll
  llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll
  llvm/test/DebugInfo/X86/dimodule-external-fortran.ll
  llvm/test/DebugInfo/X86/dwarfdump-DIImportedEntity_elements.ll
  llvm/test/DebugInfo/X86/fission-inline.ll
  llvm/test/DebugInfo/X86/fission-local-import.ll
  llvm/test/DebugInfo/X86/fission-no-inline-gsym.ll
  llvm/test/DebugInfo/X86/lexical-block-file-inline.ll
  llvm/test/DebugInfo/X86/namelist2.ll
  llvm/test/DebugInfo/omit-empty.ll
  llvm/test/Linker/pr26037.ll
  llvm/test/ThinLTO/X86/debuginfo-cu-import.ll

Index: llvm/test/ThinLTO/X86/debuginfo-cu-import.ll
===
--- llvm/test/ThinLTO/X86/debuginfo-cu-import.ll
+++ llvm/test/ThinLTO/X86/debuginfo-cu-import.ll
@@ -5,15 +5,13 @@
 ; RUN: opt -module-summary %p/Inputs/debuginfo-cu-import.ll -o %t2.bc
 ; RUN: llvm-lto -thinlto-action=thinlink -o %t.index.bc %t1.bc %t2.bc
 
-; Don't import enums, macros, retainedTypes or globals lists.
-; Only import local scope imported entities.
+; Don't import enums, macros, retainedTypes, globals or imports lists.
 ; RUN: llvm-lto -thinlto-action=import %t2.bc -thinlto-index=%t.index.bc -o - | llvm-dis -o - | FileCheck %s
 ; CHECK-NOT: DICompileUnit{{.*}} enums:
 ; CHECK-NOT: DICompileUnit{{.*}} macros:
 ; CHECK-NOT: DICompileUnit{{.*}} retainedTypes:
 ; CHECK-NOT: DICompileUnit{{.*}} globals:
-; CHECK: DICompileUnit{{.*}} imports: ![[IMP:[0-9]+]]
-; CHECK: ![[IMP]] = !{!{{[0-9]+}}}
+; CHECK-NOT: DICompileUnit{{.*}} imports:
 
 ; ModuleID = 'debuginfo-cu-import.c'
 source_filename = "debuginfo-cu-import.c"
@@ -50,14 +48,14 @@
 !8 = !{!9}
 !9 = !DIGlobalVariableExpression(var: !10, expr: !DIExpression())
 !10 = !DIGlobalVariable(name: "version", scope: !4, file: !1, line: 2, type: !7, isLocal: false, isDefinition: true)
-!11 = !{!12, !16}
+!11 = !{!12}
 !12 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !4, entity: !13, file: !1, line: 8)
 !13 = distinct !DISubprogram(name: "a", linkageName: "_ZN1A1aEv", scope: !4, file: !1, line: 7, type: !14, isLocal: false, isDefinition: true, scopeLine: 7, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !5)
 !14 = !DISubroutineType(types: !15)
 !15 = !{null}
 !16 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !17, entity: !19, file: !1, line: 8)
 !17 = distinct !DILexicalBlock(scope: !18, file: !1, line: 9, column: 8)
-!18 = distinct !DISubprogram(name: "c", linkageName: "_ZN1A1cEv", scope: !4, file: !1, line: 9, type: !14, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !5)
+!18 = distinct !DISubprogram(name: "c", linkageName: "_ZN1A1cEv", scope: !4, file: !1, line: 9, type: !14, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !33)
 !19 = distinct !DILexicalBlock(scope: !20, file: !1, line: 10, column: 8)
 !20 = distinct !DISubprogram(name: "d", linkageName: "_ZN1A1dEv", scope: !4, file: !1, line: 10, type: !14, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !5)
 !21 = !{!22}
@@ -72,4 +70,4 @@
 !30 = !DILocation(line: 7, column: 12, scope: !13)
 !31 = distinct !DISubprogram(name: "b", linkageName: "_ZN1A1bEv", scope: !4, file: !1, line: 8, type: !14, isLocal: true, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyp

[clang] d04452d - [DebugMetadata][DwarfDebug] Fix DWARF emisson of function-local imported entities (3/7)

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

Author: Vladislav Dzhidzhoev
Date: 2023-06-15T14:29:03+02:00
New Revision: d04452d54829cd7af5b43d670325ffa755ab0030

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

LOG: [DebugMetadata][DwarfDebug] Fix DWARF emisson of function-local imported 
entities (3/7)

RFC 
https://discourse.llvm.org/t/rfc-dwarfdebug-fix-and-improve-handling-imported-entities-types-and-static-local-in-subprogram-and-lexical-block-scopes/68544

Fixed PR51501 (tests from D112337).

1. Reuse of DISubprogram's 'retainedNodes' to track other function-local
   entities together with local variables and labels (this patch cares about
   function-local import while D144006 and D144008 use the same approach for
   local types and static variables). So, effectively this patch moves ownership
   of tracking local import from DICompileUnit's 'imports' field to 
DISubprogram's
   'retainedNodes' and adjusts DWARF emitter for the new layout. The old layout
   is considered unsupported (DwarfDebug would assert on such debug metadata).

   DICompileUnit's 'imports' field is supposed to track global imported
   declarations as it does before.

   This addresses various FIXMEs and simplifies the next part of the patch.

2. Postpone emission of function-local imported entities from
   `DwarfDebug::endFunctionImpl()` to `DwarfDebug::endModule()`.
   While in `DwarfDebug::endFunctionImpl()` we do not have all the
   information about a parent subprogram or a referring subprogram
   (whether a subprogram inlined or not), so we can't guarantee we emit
   an imported entity correctly and place it in a proper subprogram tree.
   So now, we just gather needed details about the import itself and its
   parent entity (either a Subprogram or a LexicalBlock) during
   processing in `DwarfDebug::endFunctionImpl()`, but all the real work is
   done in `DwarfDebug::endModule()` when we have all the required
   information to make proper emission.

Authored-by: Kristina Bessonova 

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

Added: 
llvm/test/Bitcode/upgrade-cu-locals.ll
llvm/test/Bitcode/upgrade-cu-locals.ll.bc
llvm/test/DebugInfo/Generic/import-inlined-declaration.ll
llvm/test/DebugInfo/Generic/split-dwarf-local-import.ll
llvm/test/DebugInfo/Generic/split-dwarf-local-import2.ll
llvm/test/DebugInfo/Generic/split-dwarf-local-import3.ll

Modified: 
clang/test/CodeGenCXX/debug-info-namespace.cpp
llvm/include/llvm/IR/DIBuilder.h
llvm/lib/Bitcode/Reader/MetadataLoader.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
llvm/lib/CodeGen/AsmPrinter/DwarfFile.h
llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
llvm/lib/IR/DIBuilder.cpp
llvm/lib/IR/Verifier.cpp
llvm/lib/Linker/IRMover.cpp
llvm/test/Bitcode/DIModule-fortran-external-module.ll
llvm/test/CodeGen/Generic/DbgValueAggregate.ll
llvm/test/DebugInfo/Generic/imported-name-inlined.ll
llvm/test/DebugInfo/Generic/namespace.ll
llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll
llvm/test/DebugInfo/X86/dimodule-external-fortran.ll
llvm/test/DebugInfo/X86/dwarfdump-DIImportedEntity_elements.ll
llvm/test/DebugInfo/X86/fission-inline.ll
llvm/test/DebugInfo/X86/fission-local-import.ll
llvm/test/DebugInfo/X86/fission-no-inline-gsym.ll
llvm/test/DebugInfo/X86/lexical-block-file-inline.ll
llvm/test/DebugInfo/X86/namelist2.ll
llvm/test/DebugInfo/omit-empty.ll
llvm/test/Linker/pr26037.ll
llvm/test/ThinLTO/X86/debuginfo-cu-import.ll

Removed: 




diff  --git a/clang/test/CodeGenCXX/debug-info-namespace.cpp 
b/clang/test/CodeGenCXX/debug-info-namespace.cpp
index be88feda1112f..e3cf6507e1611 100644
--- a/clang/test/CodeGenCXX/debug-info-namespace.cpp
+++ b/clang/test/CodeGenCXX/debug-info-namespace.cpp
@@ -81,44 +81,43 @@ void C::c() {}
 // CHECK: !DINamespace(scope: null)
 // CHECK: [[CU:![0-9]+]] = distinct !DICompileUnit(
 // CHECK-SAME:imports: [[MODULES:![0-9]*]]
-// CHECK: [[MODULES]] = !{[[M1:![0-9]+]], [[M2:![0-9]+]], [[M3:![0-9]+]], 
[[M4:![0-9]+]], [[M5:![0-9]+]], [[M6:![0-9]+]], [[M7:![0-9]+]], [[M8:![0-9]+]], 
[[M9:![0-9]+]], [[M10:![0-9]+]], [[M11:![0-9]+]], [[M12:![0-9]+]], 
[[M13:![0-9]+]], [[M14:![0-9]+]], [[M15:![0-9]+]], [[M16:![0-9]+]], 
[[M17:![0-9]+]]
+// CHECK: [[MODULES]] = !{[[M1:![0-9]+]], [[M2:![0-9]+]], [[M3:![0-9]+]], 
[[M4:![0-9]+]]}
 // CHECK: [[M1]] = !DIImportedEntity(tag: DW_TAG_imported_module, scope: 
[[CTXT]], entity: [[NS]], file: [[FOOCPP]], line: 15)
-
 // CHECK: [[M2]] = !DIImportedEntity(tag: DW_TAG_imported_module, scope: 
[[C

[clang] a7e7d34 - Revert "[DebugMetadata][DwarfDebug] Fix DWARF emisson of function-local imported entities (3/7)"

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

Author: Vladislav Dzhidzhoev
Date: 2023-06-15T14:35:54+02:00
New Revision: a7e7d34dc1ce35afdcd813348a7254ddfe13698a

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

LOG: Revert "[DebugMetadata][DwarfDebug] Fix DWARF emisson of function-local 
imported entities (3/7)"

This reverts commit d04452d54829cd7af5b43d670325ffa755ab0030 since
test llvm-project/llvm/test/Bitcode/DIImportedEntity_backward.ll is broken.

Added: 


Modified: 
clang/test/CodeGenCXX/debug-info-namespace.cpp
llvm/include/llvm/IR/DIBuilder.h
llvm/lib/Bitcode/Reader/MetadataLoader.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
llvm/lib/CodeGen/AsmPrinter/DwarfFile.h
llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
llvm/lib/IR/DIBuilder.cpp
llvm/lib/IR/Verifier.cpp
llvm/lib/Linker/IRMover.cpp
llvm/test/Bitcode/DIModule-fortran-external-module.ll
llvm/test/CodeGen/Generic/DbgValueAggregate.ll
llvm/test/DebugInfo/Generic/imported-name-inlined.ll
llvm/test/DebugInfo/Generic/namespace.ll
llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll
llvm/test/DebugInfo/X86/dimodule-external-fortran.ll
llvm/test/DebugInfo/X86/dwarfdump-DIImportedEntity_elements.ll
llvm/test/DebugInfo/X86/fission-inline.ll
llvm/test/DebugInfo/X86/fission-local-import.ll
llvm/test/DebugInfo/X86/fission-no-inline-gsym.ll
llvm/test/DebugInfo/X86/lexical-block-file-inline.ll
llvm/test/DebugInfo/X86/namelist2.ll
llvm/test/DebugInfo/omit-empty.ll
llvm/test/Linker/pr26037.ll
llvm/test/ThinLTO/X86/debuginfo-cu-import.ll

Removed: 
llvm/test/Bitcode/upgrade-cu-locals.ll
llvm/test/Bitcode/upgrade-cu-locals.ll.bc
llvm/test/DebugInfo/Generic/import-inlined-declaration.ll
llvm/test/DebugInfo/Generic/split-dwarf-local-import.ll
llvm/test/DebugInfo/Generic/split-dwarf-local-import2.ll
llvm/test/DebugInfo/Generic/split-dwarf-local-import3.ll



diff  --git a/clang/test/CodeGenCXX/debug-info-namespace.cpp 
b/clang/test/CodeGenCXX/debug-info-namespace.cpp
index e3cf6507e1611..be88feda1112f 100644
--- a/clang/test/CodeGenCXX/debug-info-namespace.cpp
+++ b/clang/test/CodeGenCXX/debug-info-namespace.cpp
@@ -81,43 +81,44 @@ void C::c() {}
 // CHECK: !DINamespace(scope: null)
 // CHECK: [[CU:![0-9]+]] = distinct !DICompileUnit(
 // CHECK-SAME:imports: [[MODULES:![0-9]*]]
-// CHECK: [[MODULES]] = !{[[M1:![0-9]+]], [[M2:![0-9]+]], [[M3:![0-9]+]], 
[[M4:![0-9]+]]}
+// CHECK: [[MODULES]] = !{[[M1:![0-9]+]], [[M2:![0-9]+]], [[M3:![0-9]+]], 
[[M4:![0-9]+]], [[M5:![0-9]+]], [[M6:![0-9]+]], [[M7:![0-9]+]], [[M8:![0-9]+]], 
[[M9:![0-9]+]], [[M10:![0-9]+]], [[M11:![0-9]+]], [[M12:![0-9]+]], 
[[M13:![0-9]+]], [[M14:![0-9]+]], [[M15:![0-9]+]], [[M16:![0-9]+]], 
[[M17:![0-9]+]]
 // CHECK: [[M1]] = !DIImportedEntity(tag: DW_TAG_imported_module, scope: 
[[CTXT]], entity: [[NS]], file: [[FOOCPP]], line: 15)
+
 // CHECK: [[M2]] = !DIImportedEntity(tag: DW_TAG_imported_module, scope: 
[[CU]], entity: [[CTXT]],
 // CHECK: [[M3]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, name: 
"E", scope: [[CU]], entity: [[CTXT]], file: [[FOOCPP]], line: 19)
-// CHECK: [[M4]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: 
[[CTXT]], entity: [[I]]
-// CHECK: [[F1:![0-9]+]] = distinct !DISubprogram(name: "f1",{{.*}} line: 4
-// CHECK-SAME:   DISPFlagDefinition
-// CHECK: [[FUNC:![0-9]+]] = distinct !DISubprogram(name: "func",{{.*}} 
DISPFlagDefinition
-// CHECK-SAME: retainedNodes: 
[[FUNC_NODES:![0-9]*]]
-// CHECK: [[FUNC_NODES]] = !{[[M5:![0-9]+]], [[M6:![0-9]+]], [[M7:![0-9]+]], 
[[M8:![0-9]+]], [[M9:![0-9]+]], [[M10:![0-9]+]], [[M11:![0-9]+]], 
[[M12:![0-9]+]], [[M13:![0-9]+]], [[M14:![0-9]+]], [[M15:![0-9]+]], 
[[M16:![0-9]+]], [[M17:![0-9]+]]}
-// CHECK: [[M5]] = !DIImportedEntity(tag: DW_TAG_imported_module, scope: 
[[LEX2:![0-9]+]], entity: [[NS]], file: [[FOOCPP]], line: 23)
+// CHECK: [[M4]] = !DIImportedEntity(tag: DW_TAG_imported_module, scope: 
[[LEX2:![0-9]+]], entity: [[NS]], file: [[FOOCPP]], line: 23)
 // CHECK: [[LEX2]] = distinct !DILexicalBlock(scope: [[LEX1:![0-9]+]], file: 
[[FOOCPP]],
 // CHECK: [[LEX1]] = distinct !DILexicalBlock(scope: [[FUNC:![0-9]+]], file: 
[[FOOCPP]],
-// CHECK: [[M6]] = !DIImportedEntity(tag: DW_TAG_imported_module, scope: 
[[FUNC]], entity: [[CTXT]],
-// CHECK: [[M7]] = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: 
[[FUNC]], entity: [[FOO:![0-9]+]], file: [[FOOCPP]], line: 27)
+
+// CHECK: [[FUNC:![0-9]+]] = distinct !DISubprogram(name: "f

[PATCH] D153008: [RISCV] Allow slash-star comments in instruction operands

2023-06-15 Thread Roger Ferrer Ibanez via Phabricator via cfe-commits
rogfer01 added a comment.

Hi @abel-bernabeu, I did a quick experiment replacing all the calls to 
`getLexer().Lex()` with `getParser().Lex()` and now your testcase is accepted 
and looks like this in the output

  f2:
addisp, sp, -32
sd  ra, 24(sp)
sd  s0, 16(sp)
addis0, sp, 32
#APP
lui a0, 1   # this is fine  # this should also be fine 
addiw   a0, a0, 564
add zero, a0, a0
  
#NO_APP

I understand this is the best we can do within assembly syntax.

I'm not suggesting we should change all of them. There are ~20 occurrences of 
`getLexer.Lex()` so I think it should not be too onerous to review each one.

What do you think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153008

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


[PATCH] D153015: [clangd] Skip function parameter decls when evaluating variables on hover.

2023-06-15 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo created this revision.
Herald added subscribers: kadircet, arphaman.
Herald added a project: All.
VitaNuo requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153015

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


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -3722,6 +3722,18 @@
   EXPECT_EQ(*HI->Value, "&bar");
 }
 
+TEST(Hover, FunctionParameterDefaulValueNotEvaluated) {
+  Annotations T(R"cpp(
+  void foo(int p^aram = 5);
+  )cpp");
+
+  TestTU TU = TestTU::withCode(T.code());
+  auto AST = TU.build();
+  auto HI = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
+  ASSERT_TRUE(HI);
+  ASSERT_FALSE(HI->Value);
+}
+
 TEST(Hover, DisableShowAKA) {
   Annotations T(R"cpp(
 using m_int = int;
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -659,7 +659,8 @@
 HI.Type = printType(TAT->getTemplatedDecl()->getUnderlyingType(), Ctx, PP);
 
   // Fill in value with evaluated initializer if possible.
-  if (const auto *Var = dyn_cast(D)) {
+  const auto *Var = dyn_cast(D);
+  if (Var != nullptr && !llvm::isa(Var)) {
 if (const Expr *Init = Var->getInit())
   HI.Value = printExprValue(Init, Ctx);
   } else if (const auto *ECD = dyn_cast(D)) {


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -3722,6 +3722,18 @@
   EXPECT_EQ(*HI->Value, "&bar");
 }
 
+TEST(Hover, FunctionParameterDefaulValueNotEvaluated) {
+  Annotations T(R"cpp(
+  void foo(int p^aram = 5);
+  )cpp");
+
+  TestTU TU = TestTU::withCode(T.code());
+  auto AST = TU.build();
+  auto HI = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
+  ASSERT_TRUE(HI);
+  ASSERT_FALSE(HI->Value);
+}
+
 TEST(Hover, DisableShowAKA) {
   Annotations T(R"cpp(
 using m_int = int;
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -659,7 +659,8 @@
 HI.Type = printType(TAT->getTemplatedDecl()->getUnderlyingType(), Ctx, PP);
 
   // Fill in value with evaluated initializer if possible.
-  if (const auto *Var = dyn_cast(D)) {
+  const auto *Var = dyn_cast(D);
+  if (Var != nullptr && !llvm::isa(Var)) {
 if (const Expr *Init = Var->getInit())
   HI.Value = printExprValue(Init, Ctx);
   } else if (const auto *ECD = dyn_cast(D)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D152977: [NFC] Fix potential dereferencing of null return value.

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

LGTM with the think-o fixed.




Comment at: clang/lib/Frontend/FrontendActions.cpp:461
 
+assert(NamedCtx, "NamedCtx cannot be null");
+

This doesn't build. ;-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152977

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


[PATCH] D147218: [OpenMP][Flang][MLIR] Lowering of OpenMP requires directive from parse tree to MLIR

2023-06-15 Thread Sergio Afonso via Phabricator via cfe-commits
skatrak updated this revision to Diff 531717.
skatrak added a comment.

Rebasde to fix build error.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147218

Files:
  flang/include/flang/Lower/OpenMP.h
  flang/lib/Lower/Bridge.cpp
  flang/lib/Lower/OpenMP.cpp
  flang/test/Lower/OpenMP/requires-notarget.f90
  flang/test/Lower/OpenMP/requires.f90

Index: flang/test/Lower/OpenMP/requires.f90
===
--- /dev/null
+++ flang/test/Lower/OpenMP/requires.f90
@@ -0,0 +1,13 @@
+! RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | FileCheck %s
+
+! This test checks the lowering of requires into MLIR
+
+!CHECK:  module attributes {
+!CHECK-SAME: omp.requires = #omp
+program requires
+  !$omp requires unified_shared_memory reverse_offload atomic_default_mem_order(seq_cst)
+end program requires
+
+subroutine f
+  !$omp declare target
+end subroutine f
Index: flang/test/Lower/OpenMP/requires-notarget.f90
===
--- /dev/null
+++ flang/test/Lower/OpenMP/requires-notarget.f90
@@ -0,0 +1,11 @@
+! RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | FileCheck %s
+
+! This test checks that requires lowering into MLIR skips creating the
+! omp.requires attribute with target-related clauses if there are no device
+! functions in the compilation unit
+
+!CHECK:  module attributes {
+!CHECK-NOT:  omp.requires
+program requires
+  !$omp requires unified_shared_memory reverse_offload atomic_default_mem_order(seq_cst)
+end program requires
Index: flang/lib/Lower/OpenMP.cpp
===
--- flang/lib/Lower/OpenMP.cpp
+++ flang/lib/Lower/OpenMP.cpp
@@ -2603,16 +2603,14 @@
   converter.bindSymbol(sym, symThreadprivateExv);
 }
 
-void handleDeclareTarget(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::pft::Evaluation &eval,
- const Fortran::parser::OpenMPDeclareTargetConstruct
- &declareTargetConstruct) {
-  llvm::SmallVector,
-0>
-  symbolAndClause;
-  mlir::ModuleOp mod = converter.getFirOpBuilder().getModule();
-
+/// Extract the list of function and variable symbols affected by the given
+/// 'declare target' directive and return the intended device type for them.
+static mlir::omp::DeclareTargetDeviceType getDeclareTargetInfo(
+Fortran::lower::pft::Evaluation &eval,
+const Fortran::parser::OpenMPDeclareTargetConstruct &declareTargetConstruct,
+SmallVectorImpl> &symbolAndClause) {
+  // Gather the symbols and clauses
   auto findFuncAndVarSyms = [&](const Fortran::parser::OmpObjectList &objList,
 mlir::omp::DeclareTargetCaptureClause clause) {
 for (const Fortran::parser::OmpObject &ompObject : objList.v) {
@@ -2637,6 +2635,7 @@
   Fortran::parser::OmpDeviceTypeClause::Type::Any;
   const auto &spec = std::get(
   declareTargetConstruct.t);
+
   if (const auto *objectList{
   Fortran::parser::Unwrap(spec.u)}) {
 // Case: declare target(func, var1, var2)
@@ -2671,6 +2670,28 @@
 }
   }
 
+  switch (deviceType) {
+  case Fortran::parser::OmpDeviceTypeClause::Type::Any:
+return mlir::omp::DeclareTargetDeviceType::any;
+  case Fortran::parser::OmpDeviceTypeClause::Type::Host:
+return mlir::omp::DeclareTargetDeviceType::host;
+  case Fortran::parser::OmpDeviceTypeClause::Type::Nohost:
+return mlir::omp::DeclareTargetDeviceType::nohost;
+  }
+}
+
+void genDeclareTarget(Fortran::lower::AbstractConverter &converter,
+  Fortran::lower::pft::Evaluation &eval,
+  const Fortran::parser::OpenMPDeclareTargetConstruct
+  &declareTargetConstruct) {
+  llvm::SmallVector,
+0>
+  symbolAndClause;
+  mlir::ModuleOp mod = converter.getFirOpBuilder().getModule();
+  mlir::omp::DeclareTargetDeviceType deviceType =
+  getDeclareTargetInfo(eval, declareTargetConstruct, symbolAndClause);
+
   for (std::pair
symClause : symbolAndClause) {
@@ -2697,35 +2718,44 @@
   converter.getCurrentLocation(),
   "Attempt to apply declare target on unsupported operation");
 
-mlir::omp::DeclareTargetDeviceType newDeviceType;
-switch (deviceType) {
-case Fortran::parser::OmpDeviceTypeClause::Type::Nohost:
-  newDeviceType = mlir::omp::DeclareTargetDeviceType::nohost;
-  break;
-case Fortran::parser::OmpDeviceTypeClause::Type::Host:
-  newDeviceType = mlir::omp::DeclareTargetDeviceType::host;
-  break;
-case Fortran::parser::OmpDeviceTypeClause::Type::Any:
-  newDeviceType = mlir::omp::DeclareTargetDeviceType::any;
-  break;
-}
-
 // The function or global already has a declare target applied to it,
 // very likely through implicit capture (usage in another 

[PATCH] D152813: [clang][dataflow] Create `Value`s for integer literals.

2023-06-15 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added inline comments.



Comment at: clang/include/clang/Analysis/FlowSensitive/Arena.h:89
+  /// `Value`. These literals are the same every time.
+  IntegerValue &makeIntLiteral(llvm::APInt Value);
+

Should we be taking the type into account? If not, why not? Please add the type 
or document why the type isn't tracked.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152813

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


[PATCH] D152977: [NFC] Fix potential dereferencing of null return value.

2023-06-15 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/PthreadLockChecker.cpp:294-295
   // UntouchedAndPossiblyDestroyed or UnlockedAndPossiblyDestroyed.
-  assert(lstate->isUntouchedAndPossiblyDestroyed() ||
- lstate->isUnlockedAndPossiblyDestroyed());
+  assert(lstate && (lstate->isUntouchedAndPossiblyDestroyed() ||
+lstate->isUnlockedAndPossiblyDestroyed()));
 




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152977

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


[PATCH] D153015: [clangd] Skip function parameter decls when evaluating variables on hover.

2023-06-15 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo updated this revision to Diff 531718.
VitaNuo added a comment.

Simplify.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153015

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


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -3722,6 +3722,15 @@
   EXPECT_EQ(*HI->Value, "&bar");
 }
 
+TEST(Hover, FunctionParameterDefaulValueNotEvaluated) {
+  Annotations T("void foo(int p^aram = 5);");
+  TestTU TU = TestTU::withCode(T.code());
+  auto AST = TU.build();
+  auto HI = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
+  ASSERT_TRUE(HI);
+  ASSERT_FALSE(HI->Value);
+}
+
 TEST(Hover, DisableShowAKA) {
   Annotations T(R"cpp(
 using m_int = int;
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -659,7 +659,8 @@
 HI.Type = printType(TAT->getTemplatedDecl()->getUnderlyingType(), Ctx, PP);
 
   // Fill in value with evaluated initializer if possible.
-  if (const auto *Var = dyn_cast(D)) {
+  const auto *Var = dyn_cast(D);
+  if (Var && !llvm::isa(Var)) {
 if (const Expr *Init = Var->getInit())
   HI.Value = printExprValue(Init, Ctx);
   } else if (const auto *ECD = dyn_cast(D)) {


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -3722,6 +3722,15 @@
   EXPECT_EQ(*HI->Value, "&bar");
 }
 
+TEST(Hover, FunctionParameterDefaulValueNotEvaluated) {
+  Annotations T("void foo(int p^aram = 5);");
+  TestTU TU = TestTU::withCode(T.code());
+  auto AST = TU.build();
+  auto HI = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
+  ASSERT_TRUE(HI);
+  ASSERT_FALSE(HI->Value);
+}
+
 TEST(Hover, DisableShowAKA) {
   Annotations T(R"cpp(
 using m_int = int;
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -659,7 +659,8 @@
 HI.Type = printType(TAT->getTemplatedDecl()->getUnderlyingType(), Ctx, PP);
 
   // Fill in value with evaluated initializer if possible.
-  if (const auto *Var = dyn_cast(D)) {
+  const auto *Var = dyn_cast(D);
+  if (Var && !llvm::isa(Var)) {
 if (const Expr *Init = Var->getInit())
   HI.Value = printExprValue(Init, Ctx);
   } else if (const auto *ECD = dyn_cast(D)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150226: [Clang] Remove ability to downgrade warning on the diagnostic for setting a non fixed enum to a value outside the range of the enumeration values

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

In D150226#4422856 , @dblaikie wrote:

> In D150226#4417539 , @aaron.ballman 
> wrote:
>
>> In D150226#4408980 , @dblaikie 
>> wrote:
>>
>>> In D150226#4408563 , @erichkeane 
>>> wrote:
>>>
 In D150226#4408381 , 
 @aaron.ballman wrote:

> In D150226#4404808 , @rupprecht 
> wrote:
>
>> I suppose including this warning in `ShowInSystemHeader` with your diff 
>> above would be a good first step anyway, right? If we're about to make 
>> it a hard error anyway, then making it a `ShowInSystemHeader` error 
>> first would ease that transition.
>
> Yes and no.
>
> If we're going to turn something into a hard error, letting folks 
> implementing system headers know about it is important, so from that 
> perspective, it makes sense to enable the diagnostic in system headers. 
> However, *users* have no choice in their system headers (oftentimes) 
> which makes the diagnostic unactionable for them as they're not going to 
> (and shouldn't have to) modify system headers, so from that perspective, 
> enabling the diagnostic in a system header introduces friction.
>
> If this diagnostic is showing up in system headers, I think we would 
> likely need to consider adding a compatibility hack to allow Clang to 
> still consume that system header while erroring when outside of that 
> system header (we've done this before to keep STL implementations 
> working, for example). Between this need and the friction it causes users 
> to have an unactionable diagnostic, I think we probably should not enable 
> `ShowInSystemHeader`.

 It seems to me that if our concern is breaking system headers, we need to 
 do that with better testing.  Some sort of 'diagnostic group' for "This is 
 going to become an error *SOON*" mixed with us/vendors running that on 
 platforms we consider significant enough to not break.  But just 
 diagnosing on arbitrary users with no choice on how to fix the headers 
 doesn't seem appropriate.
>>>
>>> I think that's the request here: 
>>> https://github.com/llvm/llvm-project/issues/63180
>>
>> +1, I think that request is a reasonable idea to help maintainers of system 
>> headers.
>>
>> It sounds like we're in agreement that we should not enable 
>> `ShowInSystemHeaders` for this, but it's not clear whether we've got 
>> agreement yet that we can land this change right now. I think it's 
>> acceptable to kick the can down the road by another release or so if we feel 
>> we need to, but there is a hard stop to that at some point (some folks won't 
>> fix their code until they're forced to do so, and there's not much we can do 
>> about those cases).
>
> FWIW, I still think it might be reasonable to `ShowInSystemHeaders` before 
> turning something into an unconditional/hard error - `ShowInSystemHeaders` is 
> strictly less intrusive than a hard error, and more intrusive than the 
> warning as-is, so seems like a reasonable part of transitioning to a feature 
> removal. (warning -> default-error -> show in system headers -> hard error) I 
> don't have enough of an investment in this area to suggest that this /must/ 
> be the way such a transition is done, but I have a hard time seeing why it 
> would be better to avoid that intermediate step.

My concern with `ShowInSystemHeaders` is that this seems like a bad user 
experience. If the system header triggers an error 1) some users aren't going 
to know how to fix that by downgrading the diagnostic, so that may cause them 
to go "Clang is buggy because  accepts this fine" (not the end 
of the world, but frustrates both us and users). 2) the only recourse users 
have is to downgrade/disable the diagnostic (otherwise they'd have to change 
system header code), which they may likely do with a command line flag rather 
than something more targeted like diagnostic pragmas around the include, which 
increases the risk of users not seeing the issues in code they can control.

That said, I see your logic and kind of agree with it. I just worry if it's 
going to cause more harm than good (and I don't know of a particularly good way 
to try to find out aside from "try it and see").


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

https://reviews.llvm.org/D150226

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


[PATCH] D146242: [ARM] Fixing ABI mismatch for packed structs passed as function arguments

2023-06-15 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson added a reviewer: stuij.
tmatheson added inline comments.



Comment at: clang/test/CodeGen/aarch64-ABI-align-packed.cpp:6
+// These tests check the ABI alignment of packed structs and packed fields
+// are consistent with the AAPCS64 document.
+extern "C" {

The filename and description do not reflect what this file is actually doing, 
which is specifically testing the alignment of the structs used for variable 
argument lists.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146242

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


[PATCH] D146242: [ARM] Fixing ABI mismatch for packed structs passed as function arguments

2023-06-15 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson added inline comments.



Comment at: clang/test/CodeGen/aarch64-ABI-align-packed.cpp:6
+// These tests check the ABI alignment of packed structs and packed fields
+// are consistent with the AAPCS64 document.
+extern "C" {

tmatheson wrote:
> The filename and description do not reflect what this file is actually doing, 
> which is specifically testing the alignment of the structs used for variable 
> argument lists.
Sorry out of date comment, ignore.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146242

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


[PATCH] D153013: [clang-tidy] Correct the include-cleaner-check diagnostic message for missing-includes.

2023-06-15 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo accepted this revision.
VitaNuo added a comment.
This revision is now accepted and ready to land.

Thanks!




Comment at: clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp:49
   SourceLocation SymRefLocation;
+  include_cleaner::Symbol Sym;
   include_cleaner::Header Missing;

Consider making the whole `include_cleaner::SymbolReference` a field instead, 
since you're already using two out of its three fields here. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153013

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


[PATCH] D152889: [2/2][RISCV] Model vxrm control for vsadd, vsaddu, vssub, and vssubu

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

Fixed incorrect pattern that caused test case failure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152889

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsaddu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssubu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsaddu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vssub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vssubu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vsadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vsaddu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vssub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vssubu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vsadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vsaddu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vssub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vssubu.c
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/RISCVInsertReadWriteCSR.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
  llvm/test/CodeGen/RISCV/regalloc-last-chance-recoloring-failure.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tama.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tamu.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tuma.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tumu.ll
  llvm/test/CodeGen/RISCV/rvv/rvv-peephole-vmerge-vops.ll
  llvm/test/CodeGen/RISCV/rvv/unmasked-tu.ll
  llvm/test/CodeGen/RISCV/rvv/vsadd-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vsadd-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vsaddu-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vsaddu-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vssub-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vssub-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vssubu-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vssubu-rv64.ll

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


[PATCH] D152542: [clangd] Use include_cleaner spelling strategies in clangd.

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

Duplicate of https://reviews.llvm.org/D152913. Landed the other one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152542

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


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

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

Update code based on edit of parent revision.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152996

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/include/clang/Basic/riscv_vector_common.td
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Sema/SemaRISCVVectorLookup.cpp
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vfadd.c
  clang/utils/TableGen/RISCVVEmitter.cpp
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
  llvm/lib/Target/RISCV/RISCVInsertReadWriteCSR.cpp
  llvm/lib/Target/RISCV/RISCVInstrFormats.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
  llvm/test/CodeGen/RISCV/rvv/vfadd.ll

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


[PATCH] D151696: [x86] Remove CPU_SPECIFIC* MACROs and add getManglingForCPU

2023-06-15 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added inline comments.



Comment at: llvm/lib/TargetParser/X86TargetParser.cpp:15
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/ADT/StringExtras.h"
 #include 

(clang-format) - include order



Comment at: llvm/lib/TargetParser/X86TargetParser.cpp:314
+ // Empty processor. Include X87 and CMPXCHG8 for backwards compatibility.
+  { {""}, CK_None, ~0U, FeatureX87 | FeatureCMPXCHG8B, '\0', false },
+  { {"generic"}, CK_None, ~0U, FeaturesPentiumMMX & ~FeaturesPentiumMMX, 'A', 
true },

Would it be better to move all of this into X86TargetParser.def ?



Comment at: llvm/lib/TargetParser/X86TargetParser.cpp:315
+  { {""}, CK_None, ~0U, FeatureX87 | FeatureCMPXCHG8B, '\0', false },
+  { {"generic"}, CK_None, ~0U, FeaturesPentiumMMX & ~FeaturesPentiumMMX, 'A', 
true },
   // i386-generation processors.

FeaturesPentiumMMX & ~FeaturesPentiumMMX ?



Comment at: llvm/test/CodeGen/X86/cpus-intel.ll:26
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=emeraldrapids 
2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=generic 2>&1 
| FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_ii 
2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty

Keeping all the aliased cpus variants RUN together will make maintenance easier 
(e.g. pentium_mmx)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151696

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


[PATCH] D153013: [clang-tidy] Correct the include-cleaner-check diagnostic message for missing-includes.

2023-06-15 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 531725.
hokein marked an inline comment as done.
hokein added a comment.

address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153013

Files:
  clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
  clang-tools-extra/include-cleaner/lib/Types.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp
@@ -10,8 +10,8 @@
 // CHECK-FIXES: {{^}}
 int BarResult = bar();
 int BazResult = baz();
-// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: no header providing "baz.h" is directly included [misc-include-cleaner]
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: no header providing "baz" is directly included [misc-include-cleaner]
 std::string HelloString;
-// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: no header providing  is directly included [misc-include-cleaner]
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: no header providing "std::string" is directly included [misc-include-cleaner]
 int FooBarResult = foobar();
-// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: no header providing "public.h" is directly included [misc-include-cleaner]
+// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: no header providing "foobar" is directly included [misc-include-cleaner]
Index: clang-tools-extra/include-cleaner/lib/Types.cpp
===
--- clang-tools-extra/include-cleaner/lib/Types.cpp
+++ clang-tools-extra/include-cleaner/lib/Types.cpp
@@ -15,6 +15,17 @@
 
 namespace clang::include_cleaner {
 
+std::string Symbol::name() const {
+  switch (kind()) {
+  case include_cleaner::Symbol::Macro:
+return macro().Name->getName().str();
+  case include_cleaner::Symbol::Declaration:
+return llvm::dyn_cast(&declaration())
+->getQualifiedNameAsString();
+  }
+  llvm_unreachable("Unknown symbol kind");
+}
+
 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Symbol &S) {
   switch (S.kind()) {
   case Symbol::Declaration:
Index: clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
===
--- clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
+++ clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
@@ -67,6 +67,7 @@
 
   const Decl &declaration() const { return *std::get(Storage); }
   struct Macro macro() const { return std::get(Storage); }
+  std::string name() const;
 
 private:
   // Order must match Kind enum!
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -144,17 +144,6 @@
   llvm_unreachable("Unknown header kind");
 }
 
-std::string getSymbolName(const include_cleaner::Symbol &Sym) {
-  switch (Sym.kind()) {
-  case include_cleaner::Symbol::Macro:
-return Sym.macro().Name->getName().str();
-  case include_cleaner::Symbol::Declaration:
-return llvm::dyn_cast(&Sym.declaration())
-->getQualifiedNameAsString();
-  }
-  llvm_unreachable("Unknown symbol kind");
-}
-
 std::vector generateMissingIncludeDiagnostics(
 ParsedAST &AST, llvm::ArrayRef MissingIncludes,
 llvm::StringRef Code, HeaderFilter IgnoreHeaders) {
@@ -199,7 +188,7 @@
 Diag &D = Result.emplace_back();
 D.Message =
 llvm::formatv("No header providing \"{0}\" is directly included",
-  getSymbolName(SymbolWithMissingInclude.Symbol));
+  SymbolWithMissingInclude.Symbol.name());
 D.Name = "missing-includes";
 D.Source = Diag::DiagSource::Clangd;
 D.File = AST.tuPath();
Index: clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
@@ -45,7 +45,7 @@
 
 namespace {
 struct MissingIncludeInfo {
-  SourceLocation SymRefLocation;
+  include_cleaner::SymbolReference SymRef;
   include_cleaner::Header Missing;
 };
 } // namespace
@@ -134,7 +134,7 @@
  if (!Satisfied && !Providers.empty() &&
  Ref.RT == include_cleaner::RefType::Explicit &&
  !shouldIgnore(Providers.front()))
-   Missing.push_back({Ref.RefLocation, Providers.front()});
+   Missing.push_back({Ref, Providers.front()});
});
 
   std::vector Unused;
@@ -190,9 +19

[clang-tools-extra] eed4a4d - [clang-tidy] Correct the include-cleaner-check diagnostic message for missing-includes.

2023-06-15 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2023-06-15T15:26:48+02:00
New Revision: eed4a4d02e4f33cc2f2a9980466d1c7a1cf37398

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

LOG: [clang-tidy] Correct the include-cleaner-check diagnostic message for 
missing-includes.

We should print the symbol name rather than the header name in the
message.

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
clang-tools-extra/clangd/IncludeCleaner.cpp
clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
clang-tools-extra/include-cleaner/lib/Types.cpp
clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp 
b/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
index 49e7581d801d9..b9f44c96818db 100644
--- a/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
+++ b/clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
@@ -45,7 +45,7 @@ namespace clang::tidy::misc {
 
 namespace {
 struct MissingIncludeInfo {
-  SourceLocation SymRefLocation;
+  include_cleaner::SymbolReference SymRef;
   include_cleaner::Header Missing;
 };
 } // namespace
@@ -134,7 +134,7 @@ void IncludeCleanerCheck::check(const 
MatchFinder::MatchResult &Result) {
  if (!Satisfied && !Providers.empty() &&
  Ref.RT == include_cleaner::RefType::Explicit &&
  !shouldIgnore(Providers.front()))
-   Missing.push_back({Ref.RefLocation, Providers.front()});
+   Missing.push_back({Ref, Providers.front()});
});
 
   std::vector Unused;
@@ -190,9 +190,9 @@ void IncludeCleanerCheck::check(const 
MatchFinder::MatchResult &Result) {
 if (auto Replacement =
 HeaderIncludes.insert(llvm::StringRef{Spelling}.trim("\"<>"),
   Angled, tooling::IncludeDirective::Include))
-  diag(SM->getSpellingLoc(Inc.SymRefLocation),
-   "no header providing %0 is directly included")
-  << Spelling
+  diag(SM->getSpellingLoc(Inc.SymRef.RefLocation),
+   "no header providing \"%0\" is directly included")
+  << Inc.SymRef.Target.name()
   << FixItHint::CreateInsertion(
  SM->getComposedLoc(SM->getMainFileID(),
 Replacement->getOffset()),

diff  --git a/clang-tools-extra/clangd/IncludeCleaner.cpp 
b/clang-tools-extra/clangd/IncludeCleaner.cpp
index 95f6064b769a7..8f1be544bcfa1 100644
--- a/clang-tools-extra/clangd/IncludeCleaner.cpp
+++ b/clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -144,17 +144,6 @@ llvm::StringRef getResolvedPath(const 
include_cleaner::Header &SymProvider) {
   llvm_unreachable("Unknown header kind");
 }
 
-std::string getSymbolName(const include_cleaner::Symbol &Sym) {
-  switch (Sym.kind()) {
-  case include_cleaner::Symbol::Macro:
-return Sym.macro().Name->getName().str();
-  case include_cleaner::Symbol::Declaration:
-return llvm::dyn_cast(&Sym.declaration())
-->getQualifiedNameAsString();
-  }
-  llvm_unreachable("Unknown symbol kind");
-}
-
 std::vector generateMissingIncludeDiagnostics(
 ParsedAST &AST, llvm::ArrayRef MissingIncludes,
 llvm::StringRef Code, HeaderFilter IgnoreHeaders) {
@@ -200,7 +189,7 @@ std::vector generateMissingIncludeDiagnostics(
 Diag &D = Result.emplace_back();
 D.Message =
 llvm::formatv("No header providing \"{0}\" is directly included",
-  getSymbolName(SymbolWithMissingInclude.Symbol));
+  SymbolWithMissingInclude.Symbol.name());
 D.Name = "missing-includes";
 D.Source = Diag::DiagSource::Clangd;
 D.File = AST.tuPath();

diff  --git 
a/clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h 
b/clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
index 05cb96ebec1ff..39055db5a8587 100644
--- a/clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
+++ b/clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
@@ -67,6 +67,7 @@ struct Symbol {
 
   const Decl &declaration() const { return *std::get(Storage); }
   struct Macro macro() const { return std::get(Storage); }
+  std::string name() const;
 
 private:
   // Order must match Kind enum!

diff  --git a/clang-tools-extra/include-cleaner/lib/Types.cpp 
b/clang-tools-extra/include-cleaner/lib/Types.cpp
index 3d7ca9bdeb4e3..a5ba4a0d47f6c 100644
--- a/clang-tools-extra/include-cleaner/lib/Types.cpp
+++ b/clang-tools-extra/include-cleaner/lib/Types.cpp
@@ -15,6 +15,17 @@
 
 namespace clang::include_cleaner {
 
+std::string Symbol::name() const {
+  switch (kind()) {
+

[PATCH] D153013: [clang-tidy] Correct the include-cleaner-check diagnostic message for missing-includes.

2023-06-15 Thread Haojian Wu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGeed4a4d02e4f: [clang-tidy] Correct the include-cleaner-check 
diagnostic message for missing… (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153013

Files:
  clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
  clang-tools-extra/include-cleaner/lib/Types.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc/include-cleaner.cpp
@@ -10,8 +10,8 @@
 // CHECK-FIXES: {{^}}
 int BarResult = bar();
 int BazResult = baz();
-// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: no header providing "baz.h" is directly included [misc-include-cleaner]
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: no header providing "baz" is directly included [misc-include-cleaner]
 std::string HelloString;
-// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: no header providing  is directly included [misc-include-cleaner]
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: no header providing "std::string" is directly included [misc-include-cleaner]
 int FooBarResult = foobar();
-// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: no header providing "public.h" is directly included [misc-include-cleaner]
+// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: no header providing "foobar" is directly included [misc-include-cleaner]
Index: clang-tools-extra/include-cleaner/lib/Types.cpp
===
--- clang-tools-extra/include-cleaner/lib/Types.cpp
+++ clang-tools-extra/include-cleaner/lib/Types.cpp
@@ -15,6 +15,17 @@
 
 namespace clang::include_cleaner {
 
+std::string Symbol::name() const {
+  switch (kind()) {
+  case include_cleaner::Symbol::Macro:
+return macro().Name->getName().str();
+  case include_cleaner::Symbol::Declaration:
+return llvm::dyn_cast(&declaration())
+->getQualifiedNameAsString();
+  }
+  llvm_unreachable("Unknown symbol kind");
+}
+
 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Symbol &S) {
   switch (S.kind()) {
   case Symbol::Declaration:
Index: clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
===
--- clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
+++ clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
@@ -67,6 +67,7 @@
 
   const Decl &declaration() const { return *std::get(Storage); }
   struct Macro macro() const { return std::get(Storage); }
+  std::string name() const;
 
 private:
   // Order must match Kind enum!
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -144,17 +144,6 @@
   llvm_unreachable("Unknown header kind");
 }
 
-std::string getSymbolName(const include_cleaner::Symbol &Sym) {
-  switch (Sym.kind()) {
-  case include_cleaner::Symbol::Macro:
-return Sym.macro().Name->getName().str();
-  case include_cleaner::Symbol::Declaration:
-return llvm::dyn_cast(&Sym.declaration())
-->getQualifiedNameAsString();
-  }
-  llvm_unreachable("Unknown symbol kind");
-}
-
 std::vector generateMissingIncludeDiagnostics(
 ParsedAST &AST, llvm::ArrayRef MissingIncludes,
 llvm::StringRef Code, HeaderFilter IgnoreHeaders) {
@@ -200,7 +189,7 @@
 Diag &D = Result.emplace_back();
 D.Message =
 llvm::formatv("No header providing \"{0}\" is directly included",
-  getSymbolName(SymbolWithMissingInclude.Symbol));
+  SymbolWithMissingInclude.Symbol.name());
 D.Name = "missing-includes";
 D.Source = Diag::DiagSource::Clangd;
 D.File = AST.tuPath();
Index: clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/IncludeCleanerCheck.cpp
@@ -45,7 +45,7 @@
 
 namespace {
 struct MissingIncludeInfo {
-  SourceLocation SymRefLocation;
+  include_cleaner::SymbolReference SymRef;
   include_cleaner::Header Missing;
 };
 } // namespace
@@ -134,7 +134,7 @@
  if (!Satisfied && !Providers.empty() &&
  Ref.RT == include_cleaner::RefType::Explicit &&
  !shouldIgnore(Providers.front()))
-   Missing.push_back({Ref.RefLocation, 

[PATCH] D153017: [StaticAnalyzer] Fix false negative when using a nullable parameter directly without binding to a variable

2023-06-15 Thread tripleCC via Phabricator via cfe-commits
tripleCC created this revision.
Herald added subscribers: steakhal, manas, ASDenysPetrov, martong, dkrupp, 
donat.nagy, Szelethus, a.sidorin, szepet, baloghadamsoftware.
Herald added a reviewer: NoQ.
Herald added a project: All.
tripleCC requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153017

Files:
  clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
  clang/test/Analysis/nullability.mm


Index: clang/test/Analysis/nullability.mm
===
--- clang/test/Analysis/nullability.mm
+++ clang/test/Analysis/nullability.mm
@@ -145,6 +145,17 @@
   }
 }
 
+void testArgumentTrackingDirectly(Dummy *_Nonnull nonnull, Dummy *_Nullable 
nullable) {
+  switch(getRandom()) {
+  case 1: testMultiParamChecking(nonnull, nullable, nonnull); break;
+  case 2: testMultiParamChecking(nonnull, nonnull, nonnull); break;
+  case 3: testMultiParamChecking(nonnull, nullable, nullable); break; // 
expected-warning {{Nullable pointer is passed to a callee that requires a 
non-null 3rd parameter}}
+  case 4: testMultiParamChecking(nullable, nullable, nonnull); // 
expected-warning {{Nullable pointer is passed to a callee that requires a 
non-null 1st parameter}}
+  case 5: testMultiParamChecking(nullable, nullable, nullable); // 
expected-warning {{Nullable pointer is passed to a callee that requires a 
non-null 1st parameter}}
+  case 6: testMultiParamChecking((Dummy *_Nonnull)0, nullable, nonnull); break;
+  }
+}
+
 Dummy *_Nonnull testNullableReturn(Dummy *_Nullable a) {
   Dummy *p = a;
   return p; // expected-warning {{Nullable pointer is returned from a function 
that is expected to return a non-null value}}
Index: clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
@@ -26,12 +26,13 @@
 
 #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
 
+#include "clang/Analysis/AnyCall.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
-#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h"
-#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h"
 
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/Path.h"
@@ -81,7 +82,8 @@
 : public Checker,
  check::PostCall, check::PostStmt,
  check::PostObjCMessage, check::DeadSymbols, eval::Assume,
- check::Location, check::Event> {
+ check::Location, check::Event,
+ check::BeginFunction> {
 
 public:
   // If true, the checker will not diagnose nullabilility issues for calls
@@ -102,6 +104,7 @@
   void checkEvent(ImplicitNullDerefEvent Event) const;
   void checkLocation(SVal Location, bool IsLoad, const Stmt *S,
  CheckerContext &C) const;
+  void checkBeginFunction(CheckerContext &Ctx) const;
   ProgramStateRef evalAssume(ProgramStateRef State, SVal Cond,
  bool Assumption) const;
 
@@ -563,6 +566,33 @@
   }
 }
 
+void NullabilityChecker::checkBeginFunction(CheckerContext &C) const {
+  const LocationContext *LCtx = C.getLocationContext();
+  auto AbstractCall = AnyCall::forDecl(LCtx->getDecl());
+  if (!AbstractCall)
+return;
+
+  ProgramStateRef State = C.getState();
+  for (auto Parameter : AbstractCall->parameters()) {
+if (!isValidPointerType(Parameter->getType()))
+  continue;
+
+Nullability RequiredNullability =
+getNullabilityAnnotation(Parameter->getType());
+if (RequiredNullability != Nullability::Nullable)
+  continue;
+
+const VarRegion *ParamRegion = State->getRegion(Parameter, LCtx);
+auto StoredVal = State->getSVal(ParamRegion).getAs();
+if (!StoredVal)
+  continue;
+
+State = C.getState()->set(
+StoredVal->getRegion(), NullabilityState(RequiredNullability));
+C.addTransition(State);
+  }
+}
+
 // Whenever we see a load from a typed memory region that's been annotated as
 // 'nonnull', we want to trust the user on that and assume that it is is indeed
 // non-null.


Index: clang/test/Analysis/nullability.mm
===
--- clang/test/Analysis/nullability.mm
+++ clang/test/Analysis/nullability.mm
@@ -145,6 +145,17 @@
   }
 }
 
+void testArgumentTrackingDirectly(Dummy *_Nonnull nonnull, Dummy *_Nullable nullable) {
+  switch(getRandom()) {
+  case 1: testMultiParamChecking(nonnull,

[PATCH] D153018: [include-cleaner] Reorder SymbolReference fields to avoid padding space, NFC

2023-06-15 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: VitaNuo.
Herald added subscribers: kadircet, arphaman.
Herald added a project: All.
hokein requested review of this revision.
Herald added a project: clang-tools-extra.

This will bring down the size from 40 bytes to 32 bytes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153018

Files:
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
  clang-tools-extra/include-cleaner/lib/Analysis.cpp
  clang-tools-extra/include-cleaner/lib/HTMLReport.cpp
  clang-tools-extra/include-cleaner/lib/Record.cpp
  clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp

Index: clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
@@ -182,13 +182,14 @@
   Symbol Answer2 =
   Macro{&Idents.get("ANSWER"), SM.getComposedLoc(HdrID, Hdr.point())};
   EXPECT_THAT(
-  offsetToProviders(AST, SM,
-{SymbolReference{SM.getComposedLoc(SM.getMainFileID(),
-   Code.point("1")),
- Answer1, RefType::Explicit},
- SymbolReference{SM.getComposedLoc(SM.getMainFileID(),
-   Code.point("2")),
- Answer2, RefType::Explicit}}),
+  offsetToProviders(
+  AST, SM,
+  {SymbolReference{
+   Answer1, SM.getComposedLoc(SM.getMainFileID(), Code.point("1")),
+   RefType::Explicit},
+   SymbolReference{
+   Answer2, SM.getComposedLoc(SM.getMainFileID(), Code.point("2")),
+   RefType::Explicit}}),
   UnorderedElementsAre(
   Pair(Code.point("1"), UnorderedElementsAre(HdrFile)),
   Pair(Code.point("2"), UnorderedElementsAre(HdrFile)),
Index: clang-tools-extra/include-cleaner/lib/Record.cpp
===
--- clang-tools-extra/include-cleaner/lib/Record.cpp
+++ clang-tools-extra/include-cleaner/lib/Record.cpp
@@ -134,9 +134,9 @@
   RefType RT = RefType::Explicit) {
 if (MI.isBuiltinMacro())
   return; // __FILE__ is not a reference.
-Recorded.MacroReferences.push_back(SymbolReference{
-Tok.getLocation(),
-Macro{Tok.getIdentifierInfo(), MI.getDefinitionLoc()}, RT});
+Recorded.MacroReferences.push_back(
+SymbolReference{Macro{Tok.getIdentifierInfo(), MI.getDefinitionLoc()},
+Tok.getLocation(), RT});
   }
 
   bool Active = false;
Index: clang-tools-extra/include-cleaner/lib/HTMLReport.cpp
===
--- clang-tools-extra/include-cleaner/lib/HTMLReport.cpp
+++ clang-tools-extra/include-cleaner/lib/HTMLReport.cpp
@@ -521,7 +521,7 @@
 walkAST(*Root, [&](SourceLocation Loc, const NamedDecl &D, RefType T) {
   if(!SM.isWrittenInMainFile(SM.getSpellingLoc(Loc)))
 return;
-  R.addRef(SymbolReference{Loc, D, T});
+  R.addRef(SymbolReference{D, Loc, T});
 });
   for (const SymbolReference &Ref : MacroRefs) {
 if (!SM.isWrittenInMainFile(SM.getSpellingLoc(Ref.RefLocation)))
Index: clang-tools-extra/include-cleaner/lib/Analysis.cpp
===
--- clang-tools-extra/include-cleaner/lib/Analysis.cpp
+++ clang-tools-extra/include-cleaner/lib/Analysis.cpp
@@ -45,7 +45,7 @@
 return;
   // FIXME: Most of the work done here is repetitive. It might be useful to
   // have a cache/batching.
-  SymbolReference SymRef{Loc, ND, RT};
+  SymbolReference SymRef{ND, Loc, RT};
   return CB(SymRef, headersForSymbol(ND, SM, PI));
 });
   }
Index: clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
===
--- clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
+++ clang-tools-extra/include-cleaner/include/clang-include-cleaner/Types.h
@@ -95,10 +95,10 @@
 
 /// Indicates that a piece of code refers to a symbol.
 struct SymbolReference {
-  /// The point in the code that refers to the symbol.
-  SourceLocation RefLocation;
   /// The symbol referred to.
   Symbol Target;
+  /// The point in the code that refers to the symbol.
+  SourceLocation RefLocation;
   /// Relation type between the reference location and the target.
   RefType RT;
 };
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -370,10 +370,9 @@
   continue;
 if (auto D

[PATCH] D152986: [clang] Allow 'nomerge' attribute for function pointers

2023-06-15 Thread Eduard Zingerman via Phabricator via cfe-commits
eddyz87 created this revision.
Herald added a reviewer: aaron.ballman.
Herald added subscribers: jeroen.dobbelaere, jdoerfert.
Herald added a project: All.
eddyz87 published this revision for review.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Allow specifying 'nomerge' attribute for function pointers,
e.g. like in the following C code:

  extern void (*foo)(void) __attribute__((nomerge));
  void bar(long i) {
if (i)
  foo();
else
  foo();
  }

With the goal to attach 'nomerge' to both calls done through 'foo':

  @foo = external local_unnamed_addr global ptr, align 8
  define dso_local void @bar(i64 noundef %i) local_unnamed_addr #0 {
; ...
%0 = load ptr, ptr @foo, align 8, !tbaa !5
; ...
  if.then:
tail call void %0() #1
br label %if.end
  if.else:
tail call void %0() #1
br label %if.end
  if.end:
ret void
  }
  ; ...
  attributes #1 = { nomerge ... }

Report a warning in case if 'nomerge' is specified for a variable that
is not a function pointer, e.g.:

  t.c:2:22: warning: 'nomerge' attribute is ignored because 'j' is not a 
function pointer [-Wignored-attributes]
  2 | int j __attribute__((nomerge));
|  ^

The intended use-case is for BPF backend.

BPF provides a sort of "standard library" functions that are called
helpers. BPF also verifies usage of these helpers before program
execution. Because of limitations of verification / runtime model it
is important to keep calls to some of such helpers from merging.

An example could be found by the link [1], there input C code:

  if (data_end - data > 1024) {
  bpf_for_each_map_elem(&map1, cb, &cb_data, 0);
  } else {
  bpf_for_each_map_elem(&map2, cb, &cb_data, 0);
  }

Is converted to bytecode equivalent to:

  if (data_end - data > 1024)
tmp = &map1;
  else
tmp = &map2;
  bpf_for_each_map_elem(tmp, cb, &cb_data, 0);

However, BPF verification/runtime requires to use the same map address
for each particular `bpf_for_each_map_elem()` call.

The 'nomerge' attribute is a perfect match for this situation, but
unfortunately BPF helpers are declared as pointers to functions:

  static long (*bpf_for_each_map_elem)(void *map, ...) = (void *) 164;

Hence, this commit, allowing to use 'nomerge' for function pointers.

[1] https://lore.kernel.org/bpf/03bdf90f-f374-1e67-69d6-76dd9c831...@meta.com/


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152986

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/attr-nomerge.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Parser/stmt-attributes.c
  clang/test/Parser/stmt-attributes.cpp
  clang/test/Parser/stmt-attributes.m
  clang/test/Sema/attr-nomerge-ast.cpp
  clang/test/Sema/attr-nomerge.cpp

Index: clang/test/Sema/attr-nomerge.cpp
===
--- clang/test/Sema/attr-nomerge.cpp
+++ clang/test/Sema/attr-nomerge.cpp
@@ -8,10 +8,14 @@
   int x;
   [[clang::nomerge]] x = 10; // expected-warning {{'nomerge' attribute is ignored because there exists no call expression inside the statement}}
 
-  [[clang::nomerge]] label: bar(); // expected-error {{'nomerge' attribute only applies to functions and statements}}
+  [[clang::nomerge]] label: bar(); // expected-error {{'nomerge' attribute only applies to functions, statements and variables}}
 
 }
 
 [[clang::nomerge]] int f();
 
-[[clang::nomerge]] static int i = f(); // expected-error {{'nomerge' attribute only applies to functions and statements}}
+[[clang::nomerge]] static int i = f(); // expected-warning {{'nomerge' attribute is ignored because 'i' is not a function pointer}}
+
+[[clang::nomerge]] void (*j)(void);
+
+struct [[clang::nomerge]] buz {}; // expected-error {{'nomerge' attribute only applies to functions, statements and variables}}
Index: clang/test/Sema/attr-nomerge-ast.cpp
===
--- clang/test/Sema/attr-nomerge-ast.cpp
+++ clang/test/Sema/attr-nomerge-ast.cpp
@@ -4,6 +4,7 @@
 [[clang::nomerge]] void func();
 void func();
 [[clang::nomerge]] void func() {}
+[[clang::nomerge]] void (*var)(void);
 
 // CHECK: FunctionDecl {{.*}} func 'void ()'
 // CHECK-NEXT: NoMergeAttr
@@ -14,3 +15,6 @@
 // CHECK-NEXT: FunctionDecl {{.*}} func 'void ()'
 // CHECK-NEXT: CompoundStmt
 // CHECK-NEXT: NoMergeAttr
+
+// CHECK-NEXT: VarDecl {{.*}} var 'void (*)()'
+// CHECK-NEXT: NoMergeAttr
Index: clang/test/Parser/stmt-attributes.m
===
--- clang/test/Parser/stmt-attributes.m
+++ clang/test/Parser/stmt-attributes.m
@@ -19,7 +19,7 @@
 
 @implementation Test
 - (void)foo __attribute__((nomerge)) {
-  // expected-error@-1 {{'nomerge' attribute only applies to function

[PATCH] D152986: [clang] Allow 'nomerge' attribute for function pointers

2023-06-15 Thread Eduard Zingerman via Phabricator via cfe-commits
eddyz87 added reviewers: rnk, yonghong-song.
eddyz87 added a subscriber: rnk.
eddyz87 added a comment.

Hi @aaron.ballman, @rnk,

I see that you were involved in the discussion when `nomerge` attribute was 
added in D79121 .
Could you please take a look at this proposed change?
It would be useful for BPF back-end and I tried to explain the use-case in the 
revision description.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152986

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


[PATCH] D152986: [clang] Allow 'nomerge' attribute for function pointers

2023-06-15 Thread Eduard Zingerman via Phabricator via cfe-commits
eddyz87 added subscribers: dfaust, jemarch.
eddyz87 added a comment.

Hi @jemarch, @dfaust,

You might be interested in this discussion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152986

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


[PATCH] D146777: [clang] Preliminary fat-lto-object support

2023-06-15 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added inline comments.



Comment at: clang/lib/CodeGen/BackendUtil.cpp:1065
+  if (CodeGenOpts.FatLTO) {
+// Set EnableSplitLTOUnit, since the config above won't
+if (!TheModule->getModuleFlag("EnableSplitLTOUnit"))

Can you expand the comment a bit - specifically why it won't end up in the 
above handling? I assume the Action type is different for FatLTO?



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:622
 CmdArgs.push_back(Args.MakeArgString(Twine(PluginPrefix) + Plugin));
+  }else{
+// For LLD we need to enable fat object support

nit: missing spaces



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:625
+if (Args.hasArg(options::OPT_ffat_lto_objects))
+  CmdArgs.push_back("-fat-lto-objects");
   }

Needs a test



Comment at: clang/test/CodeGen/embed-lto-fatlto.c:2
+// RUN: %clang -cc1 -triple x86_64-unknown-linux-gnu -S -flto=full 
-ffat-lto-objects -emit-llvm < %s  | FileCheck %s
+// RUN: %clang -cc1 -triple x86_64-unknown-linux-gnu -S -flto=full 
-ffat-lto-objects -emit-llvm < %s  | FileCheck %s
+//

Can you also test -flto=thin, with and without LTO splitting enabled?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146777

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


[PATCH] D153015: [clangd] Skip function parameter decls when evaluating variables on hover.

2023-06-15 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

thanks.




Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:3726
+TEST(Hover, FunctionParameterDefaulValueNotEvaluated) {
+  Annotations T("void foo(int p^aram = 5);");
+  TestTU TU = TestTU::withCode(T.code());

I believe this case should trigger a crash, but I don't see the crash with a 
trunk-built clangd, do we miss something here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153015

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


[PATCH] D153006: [clang][dataflow] Perform deep copies in copy and move operations.

2023-06-15 Thread Martin Böhme via Phabricator via cfe-commits
mboehme updated this revision to Diff 531734.
mboehme added a comment.

Avoid including llvm/Testing/Support/Error.h in 
clang/unittests/Analysis/FlowSensitive/TestingSupport.h.

This can lead to version conflicts in projects that want to include
TestingSupport.h but use a different version of gtest than the one vendored with
LLVM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153006

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
  clang/include/clang/Analysis/FlowSensitive/RecordOps.h
  clang/include/clang/Analysis/FlowSensitive/StorageLocation.h
  clang/include/clang/Analysis/FlowSensitive/Value.h
  clang/lib/Analysis/FlowSensitive/CMakeLists.txt
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/RecordOps.cpp
  clang/lib/Analysis/FlowSensitive/Transfer.cpp
  clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
  clang/unittests/Analysis/FlowSensitive/RecordOpsTest.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -12,7 +12,7 @@
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Analysis/FlowSensitive/DataflowAnalysisContext.h"
 #include "clang/Analysis/FlowSensitive/DataflowEnvironment.h"
-#include "clang/Analysis/FlowSensitive/NoopAnalysis.h"
+#include "clang/Analysis/FlowSensitive/RecordOps.h"
 #include "clang/Analysis/FlowSensitive/StorageLocation.h"
 #include "clang/Analysis/FlowSensitive/Value.h"
 #include "clang/Basic/LangStandard.h"
@@ -38,59 +38,22 @@
 using ::testing::NotNull;
 using ::testing::UnorderedElementsAre;
 
-using BuiltinOptions = DataflowAnalysisContext::Options;
-
-template 
-llvm::Error
-runDataflowReturnError(llvm::StringRef Code, Matcher Match,
-   DataflowAnalysisOptions Options,
-   LangStandard::Kind Std = LangStandard::lang_cxx17,
-   llvm::StringRef TargetFun = "target") {
-  using ast_matchers::hasName;
-  llvm::SmallVector ASTBuildArgs = {
-  // -fnodelayed-template-parsing is the default everywhere but on Windows.
-  // Set it explicitly so that tests behave the same on Windows as on other
-  // platforms.
-  "-fsyntax-only", "-fno-delayed-template-parsing",
-  "-std=" +
-  std::string(LangStandard::getLangStandardForKind(Std).getName())};
-  AnalysisInputs AI(
-  Code, hasName(TargetFun),
-  [UseBuiltinModel = Options.BuiltinOpts.has_value()](ASTContext &C,
-  Environment &Env) {
-return NoopAnalysis(
-C,
-DataflowAnalysisOptions{
-UseBuiltinModel ? Env.getDataflowAnalysisContext().getOptions()
-: std::optional()});
-  });
-  AI.ASTBuildArgs = ASTBuildArgs;
-  if (Options.BuiltinOpts)
-AI.BuiltinOptions = *Options.BuiltinOpts;
-  return checkDataflow(
-  std::move(AI),
-  /*VerifyResults=*/
-  [&Match](
-  const llvm::StringMap> &Results,
-  const AnalysisOutputs &AO) { Match(Results, AO.ASTCtx); });
-}
-
-template 
-void runDataflow(llvm::StringRef Code, Matcher Match,
+template 
+void runDataflow(llvm::StringRef Code, VerifyResultsT VerifyResults,
  DataflowAnalysisOptions Options,
  LangStandard::Kind Std = LangStandard::lang_cxx17,
  llvm::StringRef TargetFun = "target") {
   ASSERT_THAT_ERROR(
-  runDataflowReturnError(Code, Match, Options, Std, TargetFun),
+  runDataflowReturnError(Code, VerifyResults, Options, Std, TargetFun),
   llvm::Succeeded());
 }
 
-template 
-void runDataflow(llvm::StringRef Code, Matcher Match,
+template 
+void runDataflow(llvm::StringRef Code, VerifyResultsT VerifyResults,
  LangStandard::Kind Std = LangStandard::lang_cxx17,
  bool ApplyBuiltinTransfer = true,
  llvm::StringRef TargetFun = "target") {
-  runDataflow(Code, std::move(Match),
+  runDataflow(Code, std::move(VerifyResults),
   {ApplyBuiltinTransfer ? BuiltinOptions{}
 : std::optional()},
   Std, TargetFun);
@@ -1987,22 +1950,20 @@
 };
 
 void target() {
-  A Foo;
-  A Bar;
-  (void)Foo.Baz;
+  A Foo = { 1 };
+  A Bar = { 2 };
   // [[p1]]
   Foo = Bar;
   // [[p2]]
+  int val = 3;
+  Foo.Baz = val;
+  // [[p3]]
 }
   )";
   runDataflow(
   Code,
   [](const llvm::StringMap> &Results,
  ASTContext &ASTCtx) {
-ASSERT_THAT(Results.keys(), UnorderedElementsAre("p1", "p2"));
-const

[PATCH] D153008: [RISCV] Allow slash-star comments in instruction operands

2023-06-15 Thread Abel Bernabeu via Phabricator via cfe-commits
abel-bernabeu updated this revision to Diff 531735.
abel-bernabeu added a comment.

  [RISCV] Allow slash-star comments in instruction operands
  
  It has been reported by one of Esperanto's customers that slash-start
  comments ("/*") within inline assembly were only allowed before the
  first instruction operand or at the end of the lines. Those comments
  were, however, not allowed when interleaved within the operands.
  
  An example follows:
  
  unsigned long int dst;
  __asm__ __volatile__(
"li /* this was fine */ %[dst], /* this was NOT fine */ 0x1234\n"
"add zero, %[dst], %[dst]\n"
: [ dst ] "=r"(dst)
:
:);
  
  A code review of the top level parser (AsmParser class) showed that
  when comments were placed before the instruction operand or at end of
  a line, then they were gracefully handled irrespective of the backend.
  When the comments were interleaved within the instruction operands it
  was the backend's responsibility to handle the comments.
  
  RISC-V's backend did not handle the comments in any way.
  
  Beyond the obvious solution of explicitly handling the comments within
  the RISC-V backend, another, easier to maintain solution was suggested
  by Sergei Barannikov in a Discourse discussion thread:
  
  
https://discourse.llvm.org/t/interleaving-several-c-style-comments-in-the-same-inline-assembly-line/71353/8
  
  In summary, all backends, including the RISC-V's, should switch
  from getLexer().Lex() to getParser().Lex() in their ParseInstruction
  implementation.
  
  The getLexer().Lex() approach relies on the user to explicitly handle
  the comments, whereas the suggested getParser().Lex() alternive already
  handles the comments in the same way as done for non-target-specific
  assembly directives.
  
  Here we just do the RISC-V work. Other backends should also do their own
  review.
  
  In addition to Sergei Barannikov, I would also we thank David Spikett
  from Arm's community for pointing out where to start looking within the
  LLVM code base, and also the patch reviewers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153008

Files:
  clang/test/CodeGen/RISCV/riscv-inline-asm-gcc-commenting.c
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp

Index: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
===
--- llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -1617,7 +1617,7 @@
   Operands.push_back(RISCVOperand::createToken("(", FirstS));
 SMLoc S = getLoc();
 SMLoc E = SMLoc::getFromPointer(S.getPointer() + Name.size());
-getLexer().Lex();
+getParser().Lex();
 Operands.push_back(RISCVOperand::createReg(RegNo, S, E));
   }
 
@@ -1978,11 +1978,11 @@
 return MatchOperand_Success;
   case AsmToken::Plus:
 Opcode = MCBinaryExpr::Add;
-getLexer().Lex();
+getParser().Lex();
 break;
   case AsmToken::Minus:
 Opcode = MCBinaryExpr::Sub;
-getLexer().Lex();
+getParser().Lex();
 break;
   }
 
@@ -2131,11 +2131,11 @@
   MaskAgnostic))
 return MatchOperand_NoMatch;
 
-  getLexer().Lex();
+  getParser().Lex();
 
   while (getLexer().is(AsmToken::Comma)) {
 // Consume comma.
-getLexer().Lex();
+getParser().Lex();
 
 if (getLexer().isNot(AsmToken::Identifier))
   break;
@@ -2146,7 +2146,7 @@
 MaskAgnostic))
   break;
 
-getLexer().Lex();
+getParser().Lex();
   }
 
   if (getLexer().is(AsmToken::EndOfStatement) && State == VTypeState_Done) {
@@ -2186,7 +2186,7 @@
 return MatchOperand_NoMatch;
   SMLoc S = getLoc();
   SMLoc E = SMLoc::getFromPointer(S.getPointer() + Name.size());
-  getLexer().Lex();
+  getParser().Lex();
   Operands.push_back(RISCVOperand::createReg(RegNo, S, E));
   return MatchOperand_Success;
 }
@@ -2202,7 +2202,7 @@
 return MatchOperand_NoMatch;
   SMLoc S = getLoc();
   SMLoc E = SMLoc::getFromPointer(S.getPointer() + Name.size());
-  getLexer().Lex();
+  getParser().Lex();
   Operands.push_back(RISCVOperand::createReg(
   RegNo, S, E, !getSTI().hasFeature(RISCV::FeatureStdExtF)));
   return MatchOperand_Success;
@@ -2391,11 +2391,11 @@
 Error(getLoc(), "register list must start from 'ra' or 'x1'");
 return MatchOperand_ParseFail;
   }
-  getLexer().Lex();
+  getParser().Lex();
 
   // parse case like ,s0
   if (getLexer().is(AsmToken::Comma)) {
-getLexer().Lex();
+getParser().Lex();
 if (getLexer().isNot(AsmToken::Identifier)) {
   Error(getLoc(), "invalid register");
   return MatchOperand_ParseFail;
@@ -2410,12 +2410,12 @@
   Error(getLoc(), "continuous register list must start from 's0' or 'x8'");
   return MatchOperand_ParseFail;
 }
-getLexer().Lex(); // eat reg
+getParser().Lex(); // eat reg
   }
 
   // parse case like -s1
   if (getLex

[clang] b1aba4a - [clang][Diagnostics] Don't expand label fixit to the next line

2023-06-15 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-06-15T15:58:23+02:00
New Revision: b1aba4a1009937aca920539f7737b1973f908dbd

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

LOG: [clang][Diagnostics] Don't expand label fixit to the next line

Now that we print >1 line of code snippet, we printed another line of
code for now reason, because the source range we created for the fixit
expanded to the next line, if the next token was there. Don't do that.

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaDecl.cpp
clang/test/FixIt/fixit-newline-style.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 451835f8bb39a..336bd5b6aa2e1 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -350,6 +350,9 @@ Improvements to Clang's diagnostics
 - Clang no longer diagnoses a read of an empty structure as use of an
   uninitialized variable.
   (`#26842: `_)
+- The Fix-It emitted for unused labels used to expand to the next line, which 
caused
+  visual oddities now that Clang shows more than one line of code snippet. 
This has
+  been fixed and the Fix-It now only spans to the end of the ``:``.
 
 Bug Fixes in This Version
 -

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index b1436ba50892a..757c4c310be3d 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -2096,7 +2096,7 @@ static void GenerateFixForUnusedDecl(const NamedDecl *D, 
ASTContext &Ctx,
   if (isa(D)) {
 SourceLocation AfterColon = Lexer::findLocationAfterToken(
 D->getEndLoc(), tok::colon, Ctx.getSourceManager(), Ctx.getLangOpts(),
-true);
+/*SkipTrailingWhitespaceAndNewline=*/false);
 if (AfterColon.isInvalid())
   return;
 Hint = FixItHint::CreateRemoval(

diff  --git a/clang/test/FixIt/fixit-newline-style.c 
b/clang/test/FixIt/fixit-newline-style.c
index 091b79426bcdf..06cb262691ea0 100644
--- a/clang/test/FixIt/fixit-newline-style.c
+++ b/clang/test/FixIt/fixit-newline-style.c
@@ -5,6 +5,7 @@
 // CHECK: warning: unused label 'ddd'
 // CHECK-NEXT: {{^  ddd:}}
 // CHECK-NEXT: {{^  \^~~~$}}
+// CHECK-NOT: {{^  ;}}
 void f(void) {
   ddd:
   ;



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


[PATCH] D152525: [clang][Diagnostics] Don't expand label fixit to the next line

2023-06-15 Thread Timm Bäder via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb1aba4a10099: [clang][Diagnostics] Don't expand label 
fixit to the next line (authored by tbaeder).

Changed prior to commit:
  https://reviews.llvm.org/D152525?vs=529922&id=531737#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152525

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDecl.cpp
  clang/test/FixIt/fixit-newline-style.c


Index: clang/test/FixIt/fixit-newline-style.c
===
--- clang/test/FixIt/fixit-newline-style.c
+++ clang/test/FixIt/fixit-newline-style.c
@@ -5,6 +5,7 @@
 // CHECK: warning: unused label 'ddd'
 // CHECK-NEXT: {{^  ddd:}}
 // CHECK-NEXT: {{^  \^~~~$}}
+// CHECK-NOT: {{^  ;}}
 void f(void) {
   ddd:
   ;
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -2096,7 +2096,7 @@
   if (isa(D)) {
 SourceLocation AfterColon = Lexer::findLocationAfterToken(
 D->getEndLoc(), tok::colon, Ctx.getSourceManager(), Ctx.getLangOpts(),
-true);
+/*SkipTrailingWhitespaceAndNewline=*/false);
 if (AfterColon.isInvalid())
   return;
 Hint = FixItHint::CreateRemoval(
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -350,6 +350,9 @@
 - Clang no longer diagnoses a read of an empty structure as use of an
   uninitialized variable.
   (`#26842: `_)
+- The Fix-It emitted for unused labels used to expand to the next line, which 
caused
+  visual oddities now that Clang shows more than one line of code snippet. 
This has
+  been fixed and the Fix-It now only spans to the end of the ``:``.
 
 Bug Fixes in This Version
 -


Index: clang/test/FixIt/fixit-newline-style.c
===
--- clang/test/FixIt/fixit-newline-style.c
+++ clang/test/FixIt/fixit-newline-style.c
@@ -5,6 +5,7 @@
 // CHECK: warning: unused label 'ddd'
 // CHECK-NEXT: {{^  ddd:}}
 // CHECK-NEXT: {{^  \^~~~$}}
+// CHECK-NOT: {{^  ;}}
 void f(void) {
   ddd:
   ;
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -2096,7 +2096,7 @@
   if (isa(D)) {
 SourceLocation AfterColon = Lexer::findLocationAfterToken(
 D->getEndLoc(), tok::colon, Ctx.getSourceManager(), Ctx.getLangOpts(),
-true);
+/*SkipTrailingWhitespaceAndNewline=*/false);
 if (AfterColon.isInvalid())
   return;
 Hint = FixItHint::CreateRemoval(
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -350,6 +350,9 @@
 - Clang no longer diagnoses a read of an empty structure as use of an
   uninitialized variable.
   (`#26842: `_)
+- The Fix-It emitted for unused labels used to expand to the next line, which caused
+  visual oddities now that Clang shows more than one line of code snippet. This has
+  been fixed and the Fix-It now only spans to the end of the ``:``.
 
 Bug Fixes in This Version
 -
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D153008: [RISCV] Allow slash-star comments in instruction operands

2023-06-15 Thread Abel Bernabeu via Phabricator via cfe-commits
abel-bernabeu updated this revision to Diff 531740.
abel-bernabeu added a comment.

[RISCV] Allow slash-star comments in instruction operands

It has been reported by one of Esperanto's customers that slash-start
comments ("/*") within inline assembly were only allowed before the
first instruction operand or at the end of the lines. Those comments
were, however, not allowed when interleaved within the operands.

An example follows:

  unsigned long int dst;
  __asm__ __volatile__(
"li /* this was fine */ %[dst], /* this was NOT fine */ 0x1234\n"
"add zero, %[dst], %[dst]\n"
: [ dst ] "=r"(dst)
:
:);

A code review of the top level parser (AsmParser class) showed that
when comments were placed before the instruction operand or at end of
a line, then they were gracefully handled irrespective of the backend.
When the comments were interleaved within the instruction operands it
was the backend's responsibility to handle the comments.

RISC-V's backend did not handle the comments in any way.

Beyond the obvious solution of explicitly handling the comments within
the RISC-V backend, another, easier to maintain solution was suggested
by Sergei Barannikov in a Discourse discussion thread:

https://discourse.llvm.org/t/interleaving-several-c-style-comments-in-the-same-inline-assembly-line/71353/8

In summary, all backends, including the RISC-V's, should switch
from getLexer().Lex() to getParser().Lex() in their ParseInstruction
implementation.

The getLexer().Lex() approach relies on the user to explicitly handle
the comments, whereas the suggested getParser().Lex() alternive already
handles the comments in the same way as done for non-target-specific
assembly directives.

Here we just do the RISC-V work. Other backends should also do their own
review.

In addition to Sergei Barannikov, I would also we thank David Spikett
from Arm's community for pointing out where to start looking within the
LLVM code base, and also the patch reviewers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153008

Files:
  clang/test/CodeGen/RISCV/riscv-inline-asm-gcc-commenting.c
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp

Index: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
===
--- llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -1617,7 +1617,7 @@
   Operands.push_back(RISCVOperand::createToken("(", FirstS));
 SMLoc S = getLoc();
 SMLoc E = SMLoc::getFromPointer(S.getPointer() + Name.size());
-getLexer().Lex();
+getParser().Lex();
 Operands.push_back(RISCVOperand::createReg(RegNo, S, E));
   }
 
@@ -1978,11 +1978,11 @@
 return MatchOperand_Success;
   case AsmToken::Plus:
 Opcode = MCBinaryExpr::Add;
-getLexer().Lex();
+getParser().Lex();
 break;
   case AsmToken::Minus:
 Opcode = MCBinaryExpr::Sub;
-getLexer().Lex();
+getParser().Lex();
 break;
   }
 
@@ -2131,11 +2131,11 @@
   MaskAgnostic))
 return MatchOperand_NoMatch;
 
-  getLexer().Lex();
+  getParser().Lex();
 
   while (getLexer().is(AsmToken::Comma)) {
 // Consume comma.
-getLexer().Lex();
+getParser().Lex();
 
 if (getLexer().isNot(AsmToken::Identifier))
   break;
@@ -2146,7 +2146,7 @@
 MaskAgnostic))
   break;
 
-getLexer().Lex();
+getParser().Lex();
   }
 
   if (getLexer().is(AsmToken::EndOfStatement) && State == VTypeState_Done) {
@@ -2186,7 +2186,7 @@
 return MatchOperand_NoMatch;
   SMLoc S = getLoc();
   SMLoc E = SMLoc::getFromPointer(S.getPointer() + Name.size());
-  getLexer().Lex();
+  getParser().Lex();
   Operands.push_back(RISCVOperand::createReg(RegNo, S, E));
   return MatchOperand_Success;
 }
@@ -2202,7 +2202,7 @@
 return MatchOperand_NoMatch;
   SMLoc S = getLoc();
   SMLoc E = SMLoc::getFromPointer(S.getPointer() + Name.size());
-  getLexer().Lex();
+  getParser().Lex();
   Operands.push_back(RISCVOperand::createReg(
   RegNo, S, E, !getSTI().hasFeature(RISCV::FeatureStdExtF)));
   return MatchOperand_Success;
@@ -2391,11 +2391,11 @@
 Error(getLoc(), "register list must start from 'ra' or 'x1'");
 return MatchOperand_ParseFail;
   }
-  getLexer().Lex();
+  getParser().Lex();
 
   // parse case like ,s0
   if (getLexer().is(AsmToken::Comma)) {
-getLexer().Lex();
+getParser().Lex();
 if (getLexer().isNot(AsmToken::Identifier)) {
   Error(getLoc(), "invalid register");
   return MatchOperand_ParseFail;
@@ -2410,12 +2410,12 @@
   Error(getLoc(), "continuous register list must start from 's0' or 'x8'");
   return MatchOperand_ParseFail;
 }
-getLexer().Lex(); // eat reg
+getParser().Lex(); // eat reg
   }
 
   // parse case like -s1
   if (getLexer().is(AsmToken::Minus)) {
-getLexer().Lex();
+getParser().Lex();

[PATCH] D153008: [RISCV] Allow slash-star comments in instruction operands

2023-06-15 Thread Abel Bernabeu via Phabricator via cfe-commits
abel-bernabeu added a comment.

I was a bit reluctant to start a discussion on migrating getLexer().Lex() to 
getParser().Lex(), but I guess it makes sense to do it now rather than 
deferring.

It is cleaner now, I agree.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153008

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


[PATCH] D153008: [RISCV] Allow slash-star comments in instruction operands

2023-06-15 Thread Abel Bernabeu via Phabricator via cfe-commits
abel-bernabeu updated this revision to Diff 531741.
abel-bernabeu added a comment.

  [RISCV] Allow slash-star comments in instruction operands
  
  It has been reported by one of Esperanto's customers that slash-start
  comments ("/*") within inline assembly were only allowed before the
  first instruction operand or at the end of the lines. Those comments
  were, however, not allowed when interleaved within the operands.
  
  An example follows:
  
  ```
  unsigned long int dst;
  __asm__ __volatile__(
"li /* this was fine */ %[dst], /* this was NOT fine */ 0x1234\n"
"add zero, %[dst], %[dst]\n"
: [ dst ] "=r"(dst)
:
:);
  ```
  
  A code review of the top level parser (AsmParser class) showed that
  when comments were placed before the instruction operand or at end of
  a line, then they were gracefully handled irrespective of the backend.
  When the comments were interleaved within the instruction operands it
  was the backend's responsibility to handle the comments.
  
  RISC-V's backend did not handle the comments in any way.
  
  Beyond the obvious solution of explicitly handling the comments within
  the RISC-V backend, another, easier to maintain solution was suggested
  by Sergei Barannikov in a Discourse discussion thread:
  
  
https://discourse.llvm.org/t/interleaving-several-c-style-comments-in-the-same-inline-assembly-line/71353/8
  
  In summary, all backends, including the RISC-V's, should switch
  from getLexer().Lex() to getParser().Lex() in their ParseInstruction
  implementation.
  
  The getLexer().Lex() approach relies on the user to explicitly handle
  the comments, whereas the suggested getParser().Lex() alternive already
  handles the comments in the same way as done for non-target-specific
  assembly directives.
  
  Here we just do the RISC-V work. Other backends should also do their own
  review.
  
  In addition to Sergei Barannikov, I would also like to thank David Spikett
  from Arm's community for pointing out where to start looking within the
  LLVM code base, and also the patch reviewers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153008

Files:
  clang/test/CodeGen/RISCV/riscv-inline-asm-gcc-commenting.c
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp

Index: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
===
--- llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -1617,7 +1617,7 @@
   Operands.push_back(RISCVOperand::createToken("(", FirstS));
 SMLoc S = getLoc();
 SMLoc E = SMLoc::getFromPointer(S.getPointer() + Name.size());
-getLexer().Lex();
+getParser().Lex();
 Operands.push_back(RISCVOperand::createReg(RegNo, S, E));
   }
 
@@ -1978,11 +1978,11 @@
 return MatchOperand_Success;
   case AsmToken::Plus:
 Opcode = MCBinaryExpr::Add;
-getLexer().Lex();
+getParser().Lex();
 break;
   case AsmToken::Minus:
 Opcode = MCBinaryExpr::Sub;
-getLexer().Lex();
+getParser().Lex();
 break;
   }
 
@@ -2131,11 +2131,11 @@
   MaskAgnostic))
 return MatchOperand_NoMatch;
 
-  getLexer().Lex();
+  getParser().Lex();
 
   while (getLexer().is(AsmToken::Comma)) {
 // Consume comma.
-getLexer().Lex();
+getParser().Lex();
 
 if (getLexer().isNot(AsmToken::Identifier))
   break;
@@ -2146,7 +2146,7 @@
 MaskAgnostic))
   break;
 
-getLexer().Lex();
+getParser().Lex();
   }
 
   if (getLexer().is(AsmToken::EndOfStatement) && State == VTypeState_Done) {
@@ -2186,7 +2186,7 @@
 return MatchOperand_NoMatch;
   SMLoc S = getLoc();
   SMLoc E = SMLoc::getFromPointer(S.getPointer() + Name.size());
-  getLexer().Lex();
+  getParser().Lex();
   Operands.push_back(RISCVOperand::createReg(RegNo, S, E));
   return MatchOperand_Success;
 }
@@ -2202,7 +2202,7 @@
 return MatchOperand_NoMatch;
   SMLoc S = getLoc();
   SMLoc E = SMLoc::getFromPointer(S.getPointer() + Name.size());
-  getLexer().Lex();
+  getParser().Lex();
   Operands.push_back(RISCVOperand::createReg(
   RegNo, S, E, !getSTI().hasFeature(RISCV::FeatureStdExtF)));
   return MatchOperand_Success;
@@ -2391,11 +2391,11 @@
 Error(getLoc(), "register list must start from 'ra' or 'x1'");
 return MatchOperand_ParseFail;
   }
-  getLexer().Lex();
+  getParser().Lex();
 
   // parse case like ,s0
   if (getLexer().is(AsmToken::Comma)) {
-getLexer().Lex();
+getParser().Lex();
 if (getLexer().isNot(AsmToken::Identifier)) {
   Error(getLoc(), "invalid register");
   return MatchOperand_ParseFail;
@@ -2410,12 +2410,12 @@
   Error(getLoc(), "continuous register list must start from 's0' or 'x8'");
   return MatchOperand_ParseFail;
 }
-getLexer().Lex(); // eat reg
+getParser().Lex(); // eat reg
   }
 
   // parse case like 

[PATCH] D151696: [x86] Remove CPU_SPECIFIC* MACROs and add getManglingForCPU

2023-06-15 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe added inline comments.



Comment at: llvm/lib/TargetParser/X86TargetParser.cpp:314
+ // Empty processor. Include X87 and CMPXCHG8 for backwards compatibility.
+  { {""}, CK_None, ~0U, FeatureX87 | FeatureCMPXCHG8B, '\0', false },
+  { {"generic"}, CK_None, ~0U, FeaturesPentiumMMX & ~FeaturesPentiumMMX, 'A', 
true },

RKSimon wrote:
> Would it be better to move all of this into X86TargetParser.def ?
Feels so. My next step plan it to furtherly combine the feature list table in 
X86.td together.



Comment at: llvm/lib/TargetParser/X86TargetParser.cpp:315
+  { {""}, CK_None, ~0U, FeatureX87 | FeatureCMPXCHG8B, '\0', false },
+  { {"generic"}, CK_None, ~0U, FeaturesPentiumMMX & ~FeaturesPentiumMMX, 'A', 
true },
   // i386-generation processors.

RKSimon wrote:
> FeaturesPentiumMMX & ~FeaturesPentiumMMX ?
I think I was to initialize a null feature list but failed... Will refine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151696

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


[PATCH] D153008: [RISCV] Allow slash-star comments in instruction operands

2023-06-15 Thread Abel Bernabeu via Phabricator via cfe-commits
abel-bernabeu updated this revision to Diff 531746.
abel-bernabeu added a comment.

[RISCV] Allow slash-star comments in instruction operands

It has been reported by one of Esperanto's customers that slash-start
comments ("/*") within inline assembly were only allowed before the
first instruction operand or at the end of the lines. Those comments
were, however, not allowed when interleaved within the operands.

An example follows:

  unsigned long int dst;
  __asm__ __volatile__(
"li /* this was fine */ %[dst], /* this was NOT fine */ 0x1234\n"
"add zero, %[dst], %[dst]\n"
: [ dst ] "=r"(dst)
:
:);

A code review of the top level parser (AsmParser class) showed that
when comments were placed before the instruction operand or at end of
a line, then they were gracefully handled irrespective of the backend.
When the comments were interleaved within the instruction operands it
was the backend's responsibility to handle the comments.

RISC-V's backend did not handle the comments in any way.

Beyond the obvious solution of explicitly handling the comments within
the RISC-V backend, another, easier to maintain, was suggested by Sergei
Barannikov in a Discourse discussion thread:

https://discourse.llvm.org/t/interleaving-several-c-style-comments-in-the-same-inline-assembly-line/71353/8

In summary, all backends, including the RISC-V's, should switch
from getLexer().Lex() to getParser().Lex() in their ParseInstruction
implementation.

The getLexer().Lex() approach relies on the user to explicitly handle
the comments, whereas the suggested getParser().Lex() alternive already
handles the comments in the same way as done for non-target-specific
assembly directives.

Here we just do the RISC-V work. Other backends should also do their own
review.

In addition to Sergei Barannikov, I would also like to thank David Spikett
from Arm's community for pointing out where to start looking within the
LLVM code base, and also the patch reviewers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153008

Files:
  clang/test/CodeGen/RISCV/riscv-inline-asm-gcc-commenting.c
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp

Index: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
===
--- llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -1617,7 +1617,7 @@
   Operands.push_back(RISCVOperand::createToken("(", FirstS));
 SMLoc S = getLoc();
 SMLoc E = SMLoc::getFromPointer(S.getPointer() + Name.size());
-getLexer().Lex();
+getParser().Lex();
 Operands.push_back(RISCVOperand::createReg(RegNo, S, E));
   }
 
@@ -1978,11 +1978,11 @@
 return MatchOperand_Success;
   case AsmToken::Plus:
 Opcode = MCBinaryExpr::Add;
-getLexer().Lex();
+getParser().Lex();
 break;
   case AsmToken::Minus:
 Opcode = MCBinaryExpr::Sub;
-getLexer().Lex();
+getParser().Lex();
 break;
   }
 
@@ -2131,11 +2131,11 @@
   MaskAgnostic))
 return MatchOperand_NoMatch;
 
-  getLexer().Lex();
+  getParser().Lex();
 
   while (getLexer().is(AsmToken::Comma)) {
 // Consume comma.
-getLexer().Lex();
+getParser().Lex();
 
 if (getLexer().isNot(AsmToken::Identifier))
   break;
@@ -2146,7 +2146,7 @@
 MaskAgnostic))
   break;
 
-getLexer().Lex();
+getParser().Lex();
   }
 
   if (getLexer().is(AsmToken::EndOfStatement) && State == VTypeState_Done) {
@@ -2186,7 +2186,7 @@
 return MatchOperand_NoMatch;
   SMLoc S = getLoc();
   SMLoc E = SMLoc::getFromPointer(S.getPointer() + Name.size());
-  getLexer().Lex();
+  getParser().Lex();
   Operands.push_back(RISCVOperand::createReg(RegNo, S, E));
   return MatchOperand_Success;
 }
@@ -2202,7 +2202,7 @@
 return MatchOperand_NoMatch;
   SMLoc S = getLoc();
   SMLoc E = SMLoc::getFromPointer(S.getPointer() + Name.size());
-  getLexer().Lex();
+  getParser().Lex();
   Operands.push_back(RISCVOperand::createReg(
   RegNo, S, E, !getSTI().hasFeature(RISCV::FeatureStdExtF)));
   return MatchOperand_Success;
@@ -2391,11 +2391,11 @@
 Error(getLoc(), "register list must start from 'ra' or 'x1'");
 return MatchOperand_ParseFail;
   }
-  getLexer().Lex();
+  getParser().Lex();
 
   // parse case like ,s0
   if (getLexer().is(AsmToken::Comma)) {
-getLexer().Lex();
+getParser().Lex();
 if (getLexer().isNot(AsmToken::Identifier)) {
   Error(getLoc(), "invalid register");
   return MatchOperand_ParseFail;
@@ -2410,12 +2410,12 @@
   Error(getLoc(), "continuous register list must start from 's0' or 'x8'");
   return MatchOperand_ParseFail;
 }
-getLexer().Lex(); // eat reg
+getParser().Lex(); // eat reg
   }
 
   // parse case like -s1
   if (getLexer().is(AsmToken::Minus)) {
-getLexer().Lex();
+getParser().Lex();
 St

[PATCH] D152924: [libLTO][AIX] Respect `-f[no]-integrated-as` on AIX

2023-06-15 Thread Qiongsi Wu via Phabricator via cfe-commits
qiongsiwu1 added inline comments.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:700
+CmdArgs.push_back(Args.MakeArgString(
+Twine(PluginOptPrefix) + "-no-integrated-as=" + NoIntegratedAs));
+  else if (!UseIntegratedAs) {

shchenz wrote:
> Seems other options leverage the default value in the back end, for example 
> the default value for `DisableIntegratedAS` in backend is false, so when the 
> front end requires integrated-as, maybe we can save the option here?
Ah thanks for the comment! 

> maybe we can save the option here?

Could you help me understand what we mean by "the option"? Do we mean saving 
(or using?) the value of `-f[no]-integrated-as` explicitly here somehow instead 
of relying on `ToolChain.useIntegratedAs()`? How do we intend to use the saved 
option value? My understanding is that `DisableIntegratedAS` takes its value 
from the option `-no-integrated-as` if `-no-integrated-as` is specified. As 
pointed out eariler, `DisableIntegratedAS` is false by default. This code 
explicitly sets `-no-integrated-as` to `0` or `1`, so for the LTO use case, we 
overwrite the back end default since the option is always present. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152924

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


[clang] ed578f0 - [DebugMetadata][DwarfDebug] Fix DWARF emisson of function-local imported entities (3/7)

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

Author: Vladislav Dzhidzhoev
Date: 2023-06-15T16:15:39+02:00
New Revision: ed578f02cf44a52adde16647150e7421f3ef70f3

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

LOG: [DebugMetadata][DwarfDebug] Fix DWARF emisson of function-local imported 
entities (3/7)

RFC 
https://discourse.llvm.org/t/rfc-dwarfdebug-fix-and-improve-handling-imported-entities-types-and-static-local-in-subprogram-and-lexical-block-scopes/68544

Fixed PR51501 (tests from D112337).

1. Reuse of DISubprogram's 'retainedNodes' to track other function-local
   entities together with local variables and labels (this patch cares about
   function-local import while D144006 and D144008 use the same approach for
   local types and static variables). So, effectively this patch moves ownership
   of tracking local import from DICompileUnit's 'imports' field to 
DISubprogram's
   'retainedNodes' and adjusts DWARF emitter for the new layout. The old layout
   is considered unsupported (DwarfDebug would assert on such debug metadata).

   DICompileUnit's 'imports' field is supposed to track global imported
   declarations as it does before.

   This addresses various FIXMEs and simplifies the next part of the patch.

2. Postpone emission of function-local imported entities from
   `DwarfDebug::endFunctionImpl()` to `DwarfDebug::endModule()`.
   While in `DwarfDebug::endFunctionImpl()` we do not have all the
   information about a parent subprogram or a referring subprogram
   (whether a subprogram inlined or not), so we can't guarantee we emit
   an imported entity correctly and place it in a proper subprogram tree.
   So now, we just gather needed details about the import itself and its
   parent entity (either a Subprogram or a LexicalBlock) during
   processing in `DwarfDebug::endFunctionImpl()`, but all the real work is
   done in `DwarfDebug::endModule()` when we have all the required
   information to make proper emission.

Authored-by: Kristina Bessonova 

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

Added: 
llvm/test/Bitcode/upgrade-cu-locals.ll
llvm/test/Bitcode/upgrade-cu-locals.ll.bc
llvm/test/DebugInfo/Generic/import-inlined-declaration.ll
llvm/test/DebugInfo/Generic/split-dwarf-local-import.ll
llvm/test/DebugInfo/Generic/split-dwarf-local-import2.ll
llvm/test/DebugInfo/Generic/split-dwarf-local-import3.ll

Modified: 
clang/test/CodeGenCXX/debug-info-namespace.cpp
llvm/include/llvm/IR/DIBuilder.h
llvm/lib/Bitcode/Reader/MetadataLoader.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
llvm/lib/CodeGen/AsmPrinter/DwarfFile.h
llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
llvm/lib/IR/DIBuilder.cpp
llvm/lib/IR/Verifier.cpp
llvm/lib/Linker/IRMover.cpp
llvm/test/Bitcode/DIImportedEntity_backward.ll
llvm/test/Bitcode/DIModule-fortran-external-module.ll
llvm/test/CodeGen/Generic/DbgValueAggregate.ll
llvm/test/DebugInfo/Generic/imported-name-inlined.ll
llvm/test/DebugInfo/Generic/namespace.ll
llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll
llvm/test/DebugInfo/X86/dimodule-external-fortran.ll
llvm/test/DebugInfo/X86/dwarfdump-DIImportedEntity_elements.ll
llvm/test/DebugInfo/X86/fission-inline.ll
llvm/test/DebugInfo/X86/fission-local-import.ll
llvm/test/DebugInfo/X86/fission-no-inline-gsym.ll
llvm/test/DebugInfo/X86/lexical-block-file-inline.ll
llvm/test/DebugInfo/X86/namelist2.ll
llvm/test/DebugInfo/omit-empty.ll
llvm/test/Linker/pr26037.ll
llvm/test/ThinLTO/X86/debuginfo-cu-import.ll

Removed: 




diff  --git a/clang/test/CodeGenCXX/debug-info-namespace.cpp 
b/clang/test/CodeGenCXX/debug-info-namespace.cpp
index be88feda1112f..e3cf6507e1611 100644
--- a/clang/test/CodeGenCXX/debug-info-namespace.cpp
+++ b/clang/test/CodeGenCXX/debug-info-namespace.cpp
@@ -81,44 +81,43 @@ void C::c() {}
 // CHECK: !DINamespace(scope: null)
 // CHECK: [[CU:![0-9]+]] = distinct !DICompileUnit(
 // CHECK-SAME:imports: [[MODULES:![0-9]*]]
-// CHECK: [[MODULES]] = !{[[M1:![0-9]+]], [[M2:![0-9]+]], [[M3:![0-9]+]], 
[[M4:![0-9]+]], [[M5:![0-9]+]], [[M6:![0-9]+]], [[M7:![0-9]+]], [[M8:![0-9]+]], 
[[M9:![0-9]+]], [[M10:![0-9]+]], [[M11:![0-9]+]], [[M12:![0-9]+]], 
[[M13:![0-9]+]], [[M14:![0-9]+]], [[M15:![0-9]+]], [[M16:![0-9]+]], 
[[M17:![0-9]+]]
+// CHECK: [[MODULES]] = !{[[M1:![0-9]+]], [[M2:![0-9]+]], [[M3:![0-9]+]], 
[[M4:![0-9]+]]}
 // CHECK: [[M1]] = !DIImportedEntity(tag: DW_TAG_imported_module, scope: 
[[CTXT]], entity: [[NS]], file: [[FOOCPP]], line: 15)
-
 // CHECK: [[M2]] = !DIImpo

[PATCH] D153008: [RISCV] Allow slash-star comments in instruction operands

2023-06-15 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added inline comments.



Comment at: clang/test/CodeGen/RISCV/riscv-inline-asm-gcc-commenting.c:23
+// CHECK: f1:
+// CHECK:  lui a0, 1
+// CHECK-NEXT: addiw   a0, a0, 564

Check for the comment content here too? `# this is fine # this should also be 
fine`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153008

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


[PATCH] D153017: [StaticAnalyzer] Fix false negative when using a nullable parameter directly without binding to a variable

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

I believe, `zaks.anna` and `vsavchenko` are no longer involved in the project.
I think it makes sense to have the code owners NoQ and xazax.hun as reviewers, 
and I also tend to review quite a lot nowadays.
And we usually use the `[analyzer]` tag instead of `[StaticAnalyzer]` for the 
patches.
It's useful to use the right tags to trigger the right herald scripts to get 
the right circle notified.




Comment at: clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp:569-573
+void NullabilityChecker::checkBeginFunction(CheckerContext &C) const {
+  const LocationContext *LCtx = C.getLocationContext();
+  auto AbstractCall = AnyCall::forDecl(LCtx->getDecl());
+  if (!AbstractCall)
+return;

steakhal wrote:
> Uh, the diffing here looks terrible.
> What you probably want: Fold the `State`s, and if you are done, transition - 
> but only if we have any parameters.
> We need to have a single `addTransition()` call if we want a single execution 
> path modeled in the graph. We probably don't want one path on which the first 
> parameter's annotation is known; and a separate one where only the second, 
> etc.
Shouldn't we only do this for the analysis entrypoints only? (aka. top-level 
functions)
I assume this checker already did some modeling of the attributes, hence we 
have the warnings in the tests.



Comment at: clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp:569-594
+void NullabilityChecker::checkBeginFunction(CheckerContext &C) const {
+  const LocationContext *LCtx = C.getLocationContext();
+  auto AbstractCall = AnyCall::forDecl(LCtx->getDecl());
+  if (!AbstractCall)
+return;
+
+  ProgramStateRef State = C.getState();

Uh, the diffing here looks terrible.
What you probably want: Fold the `State`s, and if you are done, transition - 
but only if we have any parameters.
We need to have a single `addTransition()` call if we want a single execution 
path modeled in the graph. We probably don't want one path on which the first 
parameter's annotation is known; and a separate one where only the second, etc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153017

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


[PATCH] D152924: [libLTO][AIX] Respect `-f[no]-integrated-as` on AIX

2023-06-15 Thread ChenZheng via Phabricator via cfe-commits
shchenz added inline comments.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:700
+CmdArgs.push_back(Args.MakeArgString(
+Twine(PluginOptPrefix) + "-no-integrated-as=" + NoIntegratedAs));
+  else if (!UseIntegratedAs) {

qiongsiwu1 wrote:
> shchenz wrote:
> > Seems other options leverage the default value in the back end, for example 
> > the default value for `DisableIntegratedAS` in backend is false, so when 
> > the front end requires integrated-as, maybe we can save the option here?
> Ah thanks for the comment! 
> 
> > maybe we can save the option here?
> 
> Could you help me understand what we mean by "the option"? Do we mean saving 
> (or using?) the value of `-f[no]-integrated-as` explicitly here somehow 
> instead of relying on `ToolChain.useIntegratedAs()`? How do we intend to use 
> the saved option value? My understanding is that `DisableIntegratedAS` takes 
> its value from the option `-no-integrated-as` if `-no-integrated-as` is 
> specified. As pointed out eariler, `DisableIntegratedAS` is false by default. 
> This code explicitly sets `-no-integrated-as` to `0` or `1`, so for the LTO 
> use case, we overwrite the back end default since the option is always 
> present. 
For example, if front-end requires to use integrated-assembler which is same 
with back-end's default value, we don't need to pass `-no-integrated-as=0`? We 
only pass the option `-no-integrated-as=1` when `if (IsOSAIX && 
!UseIntegratedAs)`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152924

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


[PATCH] D153008: [RISCV] Allow slash-star comments in instruction operands

2023-06-15 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added a comment.
Herald added a subscriber: wangpc.

Does the test have to be a C source? Why not just plain asm (fed into llvm-mc)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153008

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


[PATCH] D152924: [libLTO][AIX] Respect `-f[no]-integrated-as` on AIX

2023-06-15 Thread Qiongsi Wu via Phabricator via cfe-commits
qiongsiwu1 added inline comments.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:700
+CmdArgs.push_back(Args.MakeArgString(
+Twine(PluginOptPrefix) + "-no-integrated-as=" + NoIntegratedAs));
+  else if (!UseIntegratedAs) {

shchenz wrote:
> qiongsiwu1 wrote:
> > shchenz wrote:
> > > Seems other options leverage the default value in the back end, for 
> > > example the default value for `DisableIntegratedAS` in backend is false, 
> > > so when the front end requires integrated-as, maybe we can save the 
> > > option here?
> > Ah thanks for the comment! 
> > 
> > > maybe we can save the option here?
> > 
> > Could you help me understand what we mean by "the option"? Do we mean 
> > saving (or using?) the value of `-f[no]-integrated-as` explicitly here 
> > somehow instead of relying on `ToolChain.useIntegratedAs()`? How do we 
> > intend to use the saved option value? My understanding is that 
> > `DisableIntegratedAS` takes its value from the option `-no-integrated-as` 
> > if `-no-integrated-as` is specified. As pointed out eariler, 
> > `DisableIntegratedAS` is false by default. This code explicitly sets 
> > `-no-integrated-as` to `0` or `1`, so for the LTO use case, we overwrite 
> > the back end default since the option is always present. 
> For example, if front-end requires to use integrated-assembler which is same 
> with back-end's default value, we don't need to pass `-no-integrated-as=0`? 
> We only pass the option `-no-integrated-as=1` when `if (IsOSAIX && 
> !UseIntegratedAs)`.
Ah I see! Thanks for the clarification! 

@w2yehia and I discussed this and we preferred setting the option explicitly 
regardless of the backend's default. The reason was that we did not want to 
leave a hanging case where the option was not passed to the backend, a case in 
which we would rely on a non-local option(`DisableIntegratedAS`)'s default 
value to control the backend. In other words, always passing in the option 
allowed us to reason about this code locally within this file. @w2yehia feel 
free to chime in if I am not describing our discussion correctly. 

Could you help me understand the benefit of not passing in the option for the 
default case? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152924

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


[PATCH] D152882: [LinkerWrapper] Support device binaries in multiple link jobs

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

Hopefully fixing test on Windows. I think it's fine to let the packager bundle
mutliple of these now since it's caught in `clang`. So if the user really wants
to force it we should allow them to since the bundler format is just a simple
fatbinary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152882

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/amdgpu-openmp-toolchain.c
  clang/test/Driver/linker-wrapper.c
  clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
  clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td
  llvm/include/llvm/Object/OffloadBinary.h

Index: llvm/include/llvm/Object/OffloadBinary.h
===
--- llvm/include/llvm/Object/OffloadBinary.h
+++ llvm/include/llvm/Object/OffloadBinary.h
@@ -17,6 +17,7 @@
 #ifndef LLVM_OBJECT_OFFLOADBINARY_H
 #define LLVM_OBJECT_OFFLOADBINARY_H
 
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Object/Binary.h"
@@ -155,12 +156,22 @@
 /// owns its memory.
 class OffloadFile : public OwningBinary {
 public:
+  /// An ordered pair of the target triple and the architecture.
   using TargetID = std::pair;
 
   OffloadFile(std::unique_ptr Binary,
   std::unique_ptr Buffer)
   : OwningBinary(std::move(Binary), std::move(Buffer)) {}
 
+  Expected copy() const {
+std::unique_ptr Buffer = MemoryBuffer::getMemBufferCopy(
+getBinary()->getMemoryBufferRef().getBuffer());
+auto NewBinaryOrErr = OffloadBinary::create(*Buffer);
+if (!NewBinaryOrErr)
+  return NewBinaryOrErr.takeError();
+return OffloadFile(std::move(*NewBinaryOrErr), std::move(Buffer));
+  }
+
   /// We use the Triple and Architecture pair to group linker inputs together.
   /// This conversion function lets us use these inputs in a hash-map.
   operator TargetID() const {
@@ -168,6 +179,28 @@
   }
 };
 
+/// Queries if the target \p LHS is compatible with \p RHS for linking purposes.
+inline bool areTargetsCompatible(const OffloadFile::TargetID LHS,
+ const OffloadFile::TargetID RHS) {
+  if (LHS == RHS)
+return true;
+
+  // If the target is AMD we check the target IDs for compatibility. A target id
+  // is a string conforming to the folowing BNF syntax:
+  //
+  //  target-id ::= ' ( :  ( '+' | '-' ) )*'
+  //
+  // This is used to link mutually compatible architectures together.
+  llvm::Triple T(LHS.first);
+  if (!T.isAMDGPU())
+return false;
+
+  // The targets are compatible if the architecture is a subset of the other.
+  if (RHS.second.contains(LHS.second))
+return true;
+  return false;
+}
+
 /// Extracts embedded device offloading code from a memory \p Buffer to a list
 /// of \p Binaries.
 Error extractOffloadBinaries(MemoryBufferRef Buffer,
Index: clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td
===
--- clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td
+++ clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td
@@ -67,6 +67,9 @@
 def arch_EQ : Joined<["--"], "arch=">,
   Flags<[DeviceOnlyOption, HelpHidden]>, MetaVarName<"">,
   HelpText<"The device subarchitecture">;
+def full_arch_EQ : Joined<["--"], "full-arch=">,
+  Flags<[DeviceOnlyOption, HelpHidden]>, MetaVarName<"">,
+  HelpText<"The fully qualifier device subarchitecture for AMD's target ID">;
 def triple_EQ : Joined<["--"], "triple=">,
   Flags<[DeviceOnlyOption, HelpHidden]>, MetaVarName<"">,
   HelpText<"The device target triple">;
Index: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
===
--- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -969,9 +969,13 @@
   for (Arg *A : Args)
 DAL.append(A);
 
-  // Set the subarchitecture and target triple for this compilation.
+  // Set the subarchitecture and target triple for this compilation. The input
+  // may be an AMDGPU target-id so we split off anything before the colon.
   const OptTable &Tbl = getOptTable();
   DAL.AddJoinedArg(nullptr, Tbl.getOption(OPT_arch_EQ),
+   Args.MakeArgString(
+   Input.front().getBinary()->getArch().split(':').first));
+  DAL.AddJoinedArg(nullptr, Tbl.getOption(OPT_full_arch_EQ),
Args.MakeArgString(Input.front().getBinary()->getArch()));
   DAL.AddJoinedArg(nullptr, Tbl.getOption(OPT_triple_EQ),
Args.MakeArgString(Input.front().getBinary()->getTriple()));
@@ -1001,23 +1005,13 @@
 /// Transforms all the extracted offloading input files into an image that can
 /// be registered by the runtime.
 Expected>
-linkAndWrapDeviceFiles(SmallVectorImpl &LinkerInputFiles,
+linkAndWrapD

  1   2   3   >