[PATCH] D149904: Generic selection expressions that accept a type operand

2023-05-05 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

I observe there is no documentation or release notes yet :)




Comment at: clang/include/clang/AST/Expr.h:5930
+  /// argument.
+  bool isExprPredicate() const { return IsExprPredicate; }
+  /// Whether this generic selection uses a type as its controlling argument.

nitpick: wouldn't `PredicateIsExpr()` make more sense?



Comment at: clang/include/clang/AST/Expr.h:5970
   ArrayRef getAssocExprs() const {
 return {reinterpret_cast(getTrailingObjects() +
+
getIndexOfStartOfAssociatedExprs()),

Pre-existing but why not use `cast` here?



Comment at: clang/lib/Sema/SemaExpr.cpp:1704-1711
+// We relax the restriction on use of incomplete types and non-object
+// types with the type-based extension of _Generic. Allowing incomplete
+// objects means those can be used as "tags" for a type-safe way to map
+// to a value. Similarly, matching on function types rather than
+// function pointer types can be useful. However, the restriction on VM
+// types makes sense to retain as there are open questions about how
+// the selection can be made at compile time.

 Does that mean you can match on array of unknown bound? I struggle to imagine 
how this could be used.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149904

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


[PATCH] D149899: [clang-tidy] Support SystemHeaders in .clang-tidy

2023-05-05 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL accepted this revision.
PiotrZSL added a comment.
This revision is now accepted and ready to land.

From functionally point of view, LGTM.




Comment at: 
clang-tools-extra/test/clang-tidy/infrastructure/system-headers.cpp:11
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' 
-header-filter='.*' -config='SystemHeaders: false' %s -- -isystem 
%S/Inputs/system-headers 2>&1 | FileCheck -check-prefix=CHECK-NO-SYSTEM-HEADERS 
%s
+
+#include 

I missing 2 types of tests here:
- config value override, `-config='SystemHeaders: true' -system-headers=false`
- config file override, when one file has `false`, other `true`, but 
InheritConfig is used.
Both should work, but would be good to test them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149899

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


[PATCH] D146178: [Clang][Sema] Fix comparison of constraint expressions

2023-05-05 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexander-shaposhnikov added inline comments.



Comment at: clang/lib/Sema/SemaTemplateInstantiate.cpp:133
 }
 
+Response HandlePartialClassTemplateSpec(

alexander-shaposhnikov wrote:
> alexander-shaposhnikov wrote:
> > alexander-shaposhnikov wrote:
> > > HandlePartialClassTemplateSpec is from Erich's diff 
> > > (https://reviews.llvm.org/D147722)
> > @erichkeane : previously (see https://reviews.llvm.org/D147722) we were 
> > producing a real layer of arguments (if the depth is greater than 1), to 
> > the best of my knowledge this is incorrect since it'd trigger unexpected 
> > depth adjustment, we should produce retained layers instead.
> (depth adjustment during the substitution)
to make it a bit easier to reason about I've changed the names in the test case:

```
//enum class Enum { E1 };

template 
concept some_concept = true;
//inline constexpr bool some_concept = true;

template 
struct S {
  template 
  requires(some_concept)
  void func(const T2 &);
};

template 
struct S {
  template 
  requires(some_concept)
  void func(const T22 &);
};

template 
template 
requires (some_concept)
inline void S::func(const T222 &) {}
```

Previously the code was doing the following:
```
PartialClassTemplSpec->getTemplateDepth() = 1
NumRetainedOuterLevels: 0
0: <>
before subst:
ParenExpr 0x558fb90be6a8 '_Bool'
`-ConceptSpecializationExpr 0x558fb90be640 '_Bool' Concept 0x558fb909fbd8 
'some_concept'
  |-ImplicitConceptSpecializationDecl 0x558fb90be5d0 
  | `-TemplateArgument type 'type-parameter-1-0'
  |   `-TemplateTypeParmType 0x558fb90a01d0 'type-parameter-1-0' dependent 
depth 1 index 0
  `-TemplateArgument type 'T22'
`-TemplateTypeParmType 0x558fb90be590 'T22' dependent depth 1 index 0
  `-TemplateTypeParm 0x558fb90be540 'T22'
after subst:
ParenExpr 0x558fb90bf168 '_Bool'
`-ConceptSpecializationExpr 0x558fb90bf100 '_Bool' Concept 0x558fb909fbd8 
'some_concept'
  |-ImplicitConceptSpecializationDecl 0x558fb90bf090 
  | `-TemplateArgument type 'type-parameter-0-0'
  |   `-TemplateTypeParmType 0x558fb909fb50 'type-parameter-0-0' dependent 
depth 0 index 0
  `-TemplateArgument type 'T22'
`-TemplateTypeParmType 0x558fb90bf050 'T22' dependent depth 0 index 0
  `-TemplateTypeParm 0x558fb90be540 'T22'
```
(as one can see the depths have changed)

now:
```
PartialClassTemplSpec->getTemplateDepth() = 1
NumRetainedOuterLevels: 1
before subst:
ParenExpr 0x55f7813ae6a8 '_Bool'
`-ConceptSpecializationExpr 0x55f7813ae640 '_Bool' Concept 0x55f78138fbd8 
'some_concept'
  |-ImplicitConceptSpecializationDecl 0x55f7813ae5d0 
  | `-TemplateArgument type 'type-parameter-1-0'
  |   `-TemplateTypeParmType 0x55f7813901d0 'type-parameter-1-0' dependent 
depth 1 index 0
  `-TemplateArgument type 'T22'
`-TemplateTypeParmType 0x55f7813ae590 'T22' dependent depth 1 index 0
  `-TemplateTypeParm 0x55f7813ae540 'T22'
after subst:
ParenExpr 0x55f7813af138 '_Bool'
`-ConceptSpecializationExpr 0x55f7813af0d0 '_Bool' Concept 0x55f78138fbd8 
'some_concept'
  |-ImplicitConceptSpecializationDecl 0x55f7813af060 
  | `-TemplateArgument type 'type-parameter-1-0'
  |   `-TemplateTypeParmType 0x55f7813901d0 'type-parameter-1-0' dependent 
depth 1 index 0
  `-TemplateArgument type 'T22'
`-TemplateTypeParmType 0x55f7813ae590 'T22' dependent depth 1 index 0
  `-TemplateTypeParm 0x55f7813ae540 'T22'
```




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146178

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


cfe-commits@lists.llvm.org

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

In D148924#4320694 , @shafik wrote:

> The paper also uses the term constexpr compatible which has been replaced 
> with constexpr suitable and not sure if that has any practical effect here.

They seem to be different term, `constexpr-suitable` does not actually replace 
`constexpr-compatible`. The former refers to more basic checks (i.e. "not a 
coroutine", "not a ctor or dtor for a class with virtual bases"), the latter 
only pops up in context of defaulted functions.
Constexpr-compatible has been removed completely in P2448r2 
, but I 
think it's only applicable in C++23 and this change aims to implement C++20.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148924

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


[clang] e8fb478 - [clang][Interp] Don't call getSource() on functions without a body

2023-05-05 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-05-05T11:59:42+02:00
New Revision: e8fb478f2df863c744b4eed5a5aa07a36fba737d

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

LOG: [clang][Interp] Don't call getSource() on functions without a body

For builtin functions, we create a Function instance without a body or
code. When emitting diagnostics from them, we need a proper SourceInfo
to point to, but the only thing we can use is the call site of the
builtin function.

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

Added: 


Modified: 
clang/lib/AST/Interp/EvalEmitter.h
clang/lib/AST/Interp/Function.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/EvalEmitter.h 
b/clang/lib/AST/Interp/EvalEmitter.h
index 22d7b7c68d104..99933900f2921 100644
--- a/clang/lib/AST/Interp/EvalEmitter.h
+++ b/clang/lib/AST/Interp/EvalEmitter.h
@@ -71,7 +71,7 @@ class EvalEmitter : public SourceMapper {
 
   /// Returns the source location of the current opcode.
   SourceInfo getSource(const Function *F, CodePtr PC) const override {
-return F ? F->getSource(PC) : CurrentSource;
+return (F && F->hasBody()) ? F->getSource(PC) : CurrentSource;
   }
 
   /// Parameter indices.

diff  --git a/clang/lib/AST/Interp/Function.cpp 
b/clang/lib/AST/Interp/Function.cpp
index 40001faad4116..4e6d175c41b26 100644
--- a/clang/lib/AST/Interp/Function.cpp
+++ b/clang/lib/AST/Interp/Function.cpp
@@ -32,6 +32,7 @@ Function::ParamDescriptor 
Function::getParamDescriptor(unsigned Offset) const {
 SourceInfo Function::getSource(CodePtr PC) const {
   assert(PC >= getCodeBegin() && "PC does not belong to this function");
   assert(PC <= getCodeEnd() && "PC Does not belong to this function");
+  assert(hasBody() && "Function has no body");
   unsigned Offset = PC - getCodeBegin();
   using Elem = std::pair;
   auto It = llvm::lower_bound(SrcMap, Elem{Offset, {}}, llvm::less_first());



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


[PATCH] D149824: [clang][Interp] Don't call getSource() on functions without a body

2023-05-05 Thread Timm Bäder 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 rGe8fb478f2df8: [clang][Interp] Don't call getSource() on 
functions without a body (authored by tbaeder).

Changed prior to commit:
  https://reviews.llvm.org/D149824?vs=519380&id=519786#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149824

Files:
  clang/lib/AST/Interp/EvalEmitter.h
  clang/lib/AST/Interp/Function.cpp


Index: clang/lib/AST/Interp/Function.cpp
===
--- clang/lib/AST/Interp/Function.cpp
+++ clang/lib/AST/Interp/Function.cpp
@@ -32,6 +32,7 @@
 SourceInfo Function::getSource(CodePtr PC) const {
   assert(PC >= getCodeBegin() && "PC does not belong to this function");
   assert(PC <= getCodeEnd() && "PC Does not belong to this function");
+  assert(hasBody() && "Function has no body");
   unsigned Offset = PC - getCodeBegin();
   using Elem = std::pair;
   auto It = llvm::lower_bound(SrcMap, Elem{Offset, {}}, llvm::less_first());
Index: clang/lib/AST/Interp/EvalEmitter.h
===
--- clang/lib/AST/Interp/EvalEmitter.h
+++ clang/lib/AST/Interp/EvalEmitter.h
@@ -71,7 +71,7 @@
 
   /// Returns the source location of the current opcode.
   SourceInfo getSource(const Function *F, CodePtr PC) const override {
-return F ? F->getSource(PC) : CurrentSource;
+return (F && F->hasBody()) ? F->getSource(PC) : CurrentSource;
   }
 
   /// Parameter indices.


Index: clang/lib/AST/Interp/Function.cpp
===
--- clang/lib/AST/Interp/Function.cpp
+++ clang/lib/AST/Interp/Function.cpp
@@ -32,6 +32,7 @@
 SourceInfo Function::getSource(CodePtr PC) const {
   assert(PC >= getCodeBegin() && "PC does not belong to this function");
   assert(PC <= getCodeEnd() && "PC Does not belong to this function");
+  assert(hasBody() && "Function has no body");
   unsigned Offset = PC - getCodeBegin();
   using Elem = std::pair;
   auto It = llvm::lower_bound(SrcMap, Elem{Offset, {}}, llvm::less_first());
Index: clang/lib/AST/Interp/EvalEmitter.h
===
--- clang/lib/AST/Interp/EvalEmitter.h
+++ clang/lib/AST/Interp/EvalEmitter.h
@@ -71,7 +71,7 @@
 
   /// Returns the source location of the current opcode.
   SourceInfo getSource(const Function *F, CodePtr PC) const override {
-return F ? F->getSource(PC) : CurrentSource;
+return (F && F->hasBody()) ? F->getSource(PC) : CurrentSource;
   }
 
   /// Parameter indices.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D149946: [LoongArch] Define `ual` feature and override `allowsMisalignedMemoryAccesses`

2023-05-05 Thread Lu Weining via Phabricator via cfe-commits
SixWeining created this revision.
SixWeining added reviewers: xen0n, xry111, MaskRay, rengolin, benshi001, 
wangleiat.
Herald added subscribers: hiraditya, kristof.beyls.
Herald added a project: All.
SixWeining requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Some CPUs do not allow memory accesses to be unaligned, e.g. 2k1000la
who uses the la264 core on which misaligned access will trigger an
exception.

In this patch, a backend feature called `ual` is defined to decribe
whether the CPU supports unaligned memroy accesses. And this feature
can be toggled by clang options `-m[no-]unaligned-access` or the
aliases `-m[no-]strict-align`. When this feature is on,
`allowsMisalignedMemoryAccesses` sets the speed number to 1 and returns
true that allows the codegen to generate unaligned memory access insns.

Clang options `-m[no-]unaligned-access` are moved from `m_arm_Features_Group`
to `m_Group` because now more than one targets use them. In addition,
to keep compatible with gcc, a new alias `-mno-strict-align` is added
which is equal to `-munaligned-access`.

The feature name `ual` is consistent with linux kernel [1] and the
output of `lscpu` or `/proc/cpuinfo` [2].

There is an `LLT` variant of `allowsMisalignedMemoryAccesses`, but
seems that curently it is only used in GlobalISel which LoongArch
doesn't support yet. So this variant is not implemented in this patch.

[1]: 
https://github.com/torvalds/linux/blob/master/arch/loongarch/include/asm/cpu.h#L77
[2]: 
https://github.com/torvalds/linux/blob/master/arch/loongarch/kernel/proc.c#L75


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149946

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
  clang/test/Driver/loongarch-default-features.c
  clang/test/Driver/loongarch-march.c
  clang/test/Driver/loongarch-mdouble-float.c
  clang/test/Driver/loongarch-mfpu.c
  clang/test/Driver/loongarch-msingle-float.c
  clang/test/Driver/loongarch-msoft-float.c
  clang/test/Driver/loongarch-munaligned-access.c
  llvm/include/llvm/TargetParser/LoongArchTargetParser.def
  llvm/include/llvm/TargetParser/LoongArchTargetParser.h
  llvm/lib/Target/LoongArch/LoongArch.td
  llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
  llvm/lib/Target/LoongArch/LoongArchISelLowering.h
  llvm/lib/Target/LoongArch/LoongArchSubtarget.h
  llvm/test/CodeGen/LoongArch/calling-conv-lp64d.ll
  llvm/test/CodeGen/LoongArch/ir-instruction/atomicrmw-fp.ll
  llvm/test/CodeGen/LoongArch/tail-calls.ll
  llvm/test/CodeGen/LoongArch/unaligned-access.ll
  llvm/test/CodeGen/LoongArch/unaligned-memcpy-inline.ll

Index: llvm/test/CodeGen/LoongArch/unaligned-memcpy-inline.ll
===
--- /dev/null
+++ llvm/test/CodeGen/LoongArch/unaligned-memcpy-inline.ll
@@ -0,0 +1,94 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
+; RUN: llc --mtriple=loongarch32 --mattr=-ual < %s | FileCheck %s --check-prefix=LA32
+; RUN: llc --mtriple=loongarch64 --mattr=-ual < %s | FileCheck %s --check-prefix=LA64
+
+; Small (16 bytes here) unaligned memcpy() should be a function call if
+; ual is turned off.
+define void @t0(ptr %out, ptr %in) {
+; LA32-LABEL: t0:
+; LA32:   # %bb.0: # %entry
+; LA32-NEXT:addi.w $sp, $sp, -16
+; LA32-NEXT:.cfi_def_cfa_offset 16
+; LA32-NEXT:st.w $ra, $sp, 12 # 4-byte Folded Spill
+; LA32-NEXT:.cfi_offset 1, -4
+; LA32-NEXT:ori $a2, $zero, 16
+; LA32-NEXT:bl %plt(memcpy)
+; LA32-NEXT:ld.w $ra, $sp, 12 # 4-byte Folded Reload
+; LA32-NEXT:addi.w $sp, $sp, 16
+; LA32-NEXT:ret
+;
+; LA64-LABEL: t0:
+; LA64:   # %bb.0: # %entry
+; LA64-NEXT:addi.d $sp, $sp, -16
+; LA64-NEXT:.cfi_def_cfa_offset 16
+; LA64-NEXT:st.d $ra, $sp, 8 # 8-byte Folded Spill
+; LA64-NEXT:.cfi_offset 1, -8
+; LA64-NEXT:ori $a2, $zero, 16
+; LA64-NEXT:bl %plt(memcpy)
+; LA64-NEXT:ld.d $ra, $sp, 8 # 8-byte Folded Reload
+; LA64-NEXT:addi.d $sp, $sp, 16
+; LA64-NEXT:ret
+entry:
+  call void @llvm.memcpy.p0.p0.i64(ptr %out, ptr %in, i64 16, i1 false)
+  ret void
+}
+
+; Small (16 bytes here) aligned memcpy() should be inlined even if
+; ual is turned off.
+define void @t1(ptr align 8 %out, ptr align 8 %in) {
+; LA32-LABEL: t1:
+; LA32:   # %bb.0: # %entry
+; LA32-NEXT:ld.w $a2, $a1, 12
+; LA32-NEXT:st.w $a2, $a0, 12
+; LA32-NEXT:ld.w $a2, $a1, 8
+; LA32-NEXT:st.w $a2, $a0, 8
+; LA32-NEXT:ld.w $a2, $a1, 4
+; LA32-NEXT:st.w $a2, $a0, 4
+; LA32-NEXT:ld.w $a1, $a1, 0
+; LA32-NEXT:st.w $a1, $a0, 0
+; LA32-NEXT:ret
+;
+; LA64-LABEL: t1:
+; LA64:   # %bb.0: # %entry
+; LA64-NEXT:ld.d $a2, $a1, 8
+; LA64-NEXT:st.d $a2, $a0, 8
+; LA64-NEXT:ld.d $a1, $a1, 0
+; LA64-NEXT:st.d $a1, $a0, 0
+; LA64-NEXT:ret
+entry:
+  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %ou

[PATCH] D149946: [LoongArch] Define `ual` feature and override `allowsMisalignedMemoryAccesses`

2023-05-05 Thread Lu Weining via Phabricator via cfe-commits
SixWeining added a comment.

TODO: update llvm/clang release notes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149946

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


[PATCH] D149946: [LoongArch] Define `ual` feature and override `allowsMisalignedMemoryAccesses`

2023-05-05 Thread Renato Golin via Phabricator via cfe-commits
rengolin added a reviewer: peter.smith.
rengolin added a comment.

Rationale and implementation make sense to me. I'll let this one sit so that 
other folks, including Arm, can have a look, too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149946

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


[PATCH] D149948: [include-cleaner] Treat references to nested types implicit

2023-05-05 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
Herald added a project: All.
kadircet requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149948

Files:
  clang-tools-extra/include-cleaner/lib/WalkAST.cpp
  clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp


Index: clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
@@ -341,6 +341,28 @@
   testWalk("template struct $explicit^S { S(T); };", "^S s(42);");
 }
 
+TEST(WalkAST, NestedTypes) {
+  testWalk(R"cpp(
+  struct Base { typedef int $implicit^a; };
+  struct Derived : public Base {};)cpp",
+   "void fun() { Derived::^a x; }");
+  testWalk(R"cpp(
+  struct Base { using $implicit^a = int; };
+  struct Derived : public Base {};)cpp",
+   "void fun() { Derived::^a x; }");
+  testWalk(R"cpp(
+  struct ns { struct a {}; };
+  struct Base : public ns { using ns::$implicit^a; };
+  struct Derived : public Base {};)cpp",
+   "void fun() { Derived::^a x; }");
+  testWalk(R"cpp(
+  struct Base { struct $implicit^a {}; };
+  struct Derived : public Base {};)cpp",
+   "void fun() { Derived::^a x; }");
+  testWalk("struct Base { struct $implicit^a {}; };",
+   "struct Derived : public Base { ^a x; };");
+}
+
 TEST(WalkAST, MemberExprs) {
   testWalk("struct $implicit^S { static int f; };", "void foo() { S::^f; }");
   testWalk("struct B { static int f; }; struct $implicit^S : B {};",
Index: clang-tools-extra/include-cleaner/lib/WalkAST.cpp
===
--- clang-tools-extra/include-cleaner/lib/WalkAST.cpp
+++ clang-tools-extra/include-cleaner/lib/WalkAST.cpp
@@ -218,31 +218,45 @@
   }
 
   // TypeLoc visitors.
+  void reportType(SourceLocation RefLoc, NamedDecl *ND) {
+// Reporting explicit references to types nested inside classes can cause
+// issues, e.g. a type accessed through a derived class shouldn't require
+// inclusion of the base.
+// Hence we report all such references as implicit. The code must spell the
+// outer type-location somewhere, which will trigger an explicit reference
+// and per IWYS, it's that spelling's responsibility to bring in necessary
+// declarations.
+RefType RT = llvm::isa(ND->getDeclContext())
+ ? RefType::Implicit
+ : RefType::Explicit;
+return report(RefLoc, ND, RT);
+  }
+
   bool VisitUsingTypeLoc(UsingTypeLoc TL) {
-report(TL.getNameLoc(), TL.getFoundDecl());
+reportType(TL.getNameLoc(), TL.getFoundDecl());
 return true;
   }
 
   bool VisitTagTypeLoc(TagTypeLoc TTL) {
-report(TTL.getNameLoc(), TTL.getDecl());
+reportType(TTL.getNameLoc(), TTL.getDecl());
 return true;
   }
 
   bool VisitTypedefTypeLoc(TypedefTypeLoc TTL) {
-report(TTL.getNameLoc(), TTL.getTypedefNameDecl());
+reportType(TTL.getNameLoc(), TTL.getTypedefNameDecl());
 return true;
   }
 
   bool VisitTemplateSpecializationTypeLoc(TemplateSpecializationTypeLoc TL) {
-report(TL.getTemplateNameLoc(),
-   getMostRelevantTemplatePattern(TL.getTypePtr()));
+reportType(TL.getTemplateNameLoc(),
+   getMostRelevantTemplatePattern(TL.getTypePtr()));
 return true;
   }
 
   bool VisitDeducedTemplateSpecializationTypeLoc(
   DeducedTemplateSpecializationTypeLoc TL) {
-report(TL.getTemplateNameLoc(),
-   getMostRelevantTemplatePattern(TL.getTypePtr()));
+reportType(TL.getTemplateNameLoc(),
+   getMostRelevantTemplatePattern(TL.getTypePtr()));
 return true;
   }
 


Index: clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
@@ -341,6 +341,28 @@
   testWalk("template struct $explicit^S { S(T); };", "^S s(42);");
 }
 
+TEST(WalkAST, NestedTypes) {
+  testWalk(R"cpp(
+  struct Base { typedef int $implicit^a; };
+  struct Derived : public Base {};)cpp",
+   "void fun() { Derived::^a x; }");
+  testWalk(R"cpp(
+  struct Base { using $implicit^a = int; };
+  struct Derived : public Base {};)cpp",
+   "void fun() { Derived::^a x; }");
+  testWalk(R"cpp(
+  struct ns { struct a {}; };
+  struct Base : public ns { using ns::$implicit^a; };
+  struct Derived : public Base {};)cpp",
+   "void fun() { Derived::^a x; }");
+  testWalk(R"cpp(
+  struct Base { struct $implicit^a {}; };
+  struct Derived : public Base {};)cpp",
+   "void fun() { Derived::^a x; }");
+  testWalk("struct Base { struc

[PATCH] D147875: [clang][Diagnostics] Show line numbers when printing code snippets

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



Comment at: clang/test/FixIt/fixit-function-call.cpp:1
-// RUN: not %clang_cc1 -fdiagnostics-parseable-fixits -x c++ %s 2> %t
+// RUN: not %clang_cc1 -fdiagnostics-parseable-fixits 
-fno-diagnostics-show-line-numbers -fcaret-diagnostics-max-lines 1 -x c++ %s 2> 
%t
 // RUN: FileCheck %s < %t

aaron.ballman wrote:
> Just to double-check, parseable diagnostic output still works even if line 
> numbers are shown, yes?
Yes, at leat we don't prepend the line numbers to the parseable fixits:
```
   21 | // CHECK-NEXT: fix-it{{.*}})
   22 | // CHECK: void f1(double *a);
   23 |   f1(a + 1);
  |  ~
  |  *(   )
fix-it:"../clang/test/FixIt/fixit-function-call.cpp":{23:6-23:6}:"*("
fix-it:"../clang/test/FixIt/fixit-function-call.cpp":{23:11-23:11}:")"
```


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

https://reviews.llvm.org/D147875

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


[PATCH] D149733: [clang][USR] Prevent crashes on incomplete FunctionDecls

2023-05-05 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

> However, I'm not keen on us playing whack-a-mole with the kinds of checks 
> from this review. For starters, that's going to have a long-tail that makes 
> it hard to know if we've ever gotten to the bottom of the issue. But also, 
> each one of these checks is basically useless for the primary way in which 
> Clang is consumed (as a compiler), so this increases compile times for 
> limited benefit to "most" users.

I completely agree, that's the reason why I've stayed away from adding those 
checks to various FunctionDecl helpers (isVariadic, params, etc.).

> In this particular case, we may be fine as this is limited to libclang and so 
> it shouldn't add overhead for the common path, but I suspect we're going to 
> find cases that need fixing in more common areas of the compiler that could 
> be more troublesome.

Agreed, and I am also pretty sure this is not the only place that can be 
affected from incomplete decls/types. But this is the only one showing up quite 
frequently ever since changes to lambda parsing.
I think there's some strategy decision to be made about clang's invariants:

- whether to accept declarations/types can be inspected in the middle of 
parsing as a new constraint, declare all the existing violations as bugs and 
fix them as we go (without introducing new ones, which is quite hard) and give 
people the means to construct ast nodes "safely".
- claim that variants are WAI and it's on use cases that perform such 
inspections to figure out how to deal with consequences (e.g. in 
code-completion consumers).

But in either case, I don't think this review is the right medium to make that 
decision. Surely it contains a lot of useful pointers, and I am happy to move 
them to a discourse thread (LMK if I should do it, or you'd like to kick it off 
@aaron.ballman) to raise awareness, but in the end this review is just trying 
to fix an issue by adding extra checks to only the applications that can 
violate contracts of clang parsing. So unless we've specific concerns about the 
issue being addressed in this patch, I'd like to move forward.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149733

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


[PATCH] D149899: [clang-tidy] Support SystemHeaders in .clang-tidy

2023-05-05 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/infrastructure/system-headers.cpp:11
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' 
-header-filter='.*' -config='SystemHeaders: false' %s -- -isystem 
%S/Inputs/system-headers 2>&1 | FileCheck -check-prefix=CHECK-NO-SYSTEM-HEADERS 
%s
+
+#include 

PiotrZSL wrote:
> I missing 2 types of tests here:
> - config value override, `-config='SystemHeaders: true' -system-headers=false`
> - config file override, when one file has `false`, other `true`, but 
> InheritConfig is used.
> Both should work, but would be good to test them.
Thanks for the input! Essentially I followed the same testing pattern as 
`UseColor`, which is also a global boolean option. 

Adding the first suggestion should be trivial in the current test case, but I 
have some doubts about the proposed second test. When I look at the 
`tests/clang-tidy/infrastructure/config-files.cpp` it only takes into account 
enabled checks, no other global options are tested such that one overrides the 
other. Therefore I wonder if there is a rationale for not having such level of 
testing, perhaps easier maintenance, given that it's already tested by the unit 
tests? In that case I would propose to not add such a test here, for 
consistency. WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149899

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


[PATCH] D147875: [clang][Diagnostics] Show line numbers when printing code snippets

2023-05-05 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 519799.
tbaeder added a comment.

Add docs and a release note.


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

https://reviews.llvm.org/D147875

Files:
  
clang-tools-extra/test/clang-tidy/checkers/cert/uppercase-literal-suffix-integer.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-float16.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-floating-point-opencl-half.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-floating-point.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-hexadecimal-floating-point.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer-custom-list.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer-ms.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability/uppercase-literal-suffix-integer.cpp
  clang/docs/ReleaseNotes.rst
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/DiagnosticOptions.def
  clang/include/clang/Basic/DiagnosticOptions.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/TextDiagnostic.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/TextDiagnostic.cpp
  clang/test/Analysis/Checkers/WebKit/uncounted-lambda-captures.cpp
  clang/test/FixIt/fixit-function-call.cpp
  clang/test/FixIt/fixit-newline-style.c
  clang/test/FixIt/fixit-unicode-with-utf8-output.c
  clang/test/FixIt/fixit-unicode.c
  clang/test/Frontend/source-col-map.c
  clang/test/Lexer/header.cpp
  clang/test/Lexer/string-literal-errors.cpp
  clang/test/Misc/caret-diags-macros.c
  clang/test/Misc/caret-diags-multiline.cpp
  clang/test/Misc/diag-macro-backtrace.c
  clang/test/Misc/message-length.c
  clang/test/Misc/tabstop.c
  clang/test/Misc/unnecessary-elipses.cpp
  clang/test/Misc/unprintable.c
  clang/test/Misc/wrong-encoding.c
  clang/test/Parser/brackets.c
  clang/test/Parser/brackets.cpp
  clang/test/Preprocessor/ucn-pp-identifier.c
  clang/test/Sema/caret-diags-complex-init.cpp
  clang/test/SemaCXX/struct-class-redecl.cpp

Index: clang/test/SemaCXX/struct-class-redecl.cpp
===
--- clang/test/SemaCXX/struct-class-redecl.cpp
+++ clang/test/SemaCXX/struct-class-redecl.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -Wmismatched-tags -verify %s
-// RUN: not %clang_cc1 -fsyntax-only -Wmismatched-tags %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -fsyntax-only -Wmismatched-tags -fno-diagnostics-show-line-numbers -verify %s
+// RUN: not %clang_cc1 -fsyntax-only -Wmismatched-tags -fno-diagnostics-show-line-numbers %s 2>&1 | FileCheck %s
 class X; // expected-note 2{{here}}
 typedef struct X * X_t; // expected-warning{{previously declared}}
 union X { int x; float y; }; // expected-error{{use of 'X' with tag type that does not match previous declaration}}
Index: clang/test/Sema/caret-diags-complex-init.cpp
===
--- clang/test/Sema/caret-diags-complex-init.cpp
+++ clang/test/Sema/caret-diags-complex-init.cpp
@@ -1,4 +1,4 @@
-// RUN: not %clang_cc1 -std=c++11 -fsyntax-only -fcaret-diagnostics-max-lines 5 %s 2>&1 | FileCheck %s -strict-whitespace
+// RUN: not %clang_cc1 -std=c++11 -fsyntax-only -fno-diagnostics-show-line-numbers -fcaret-diagnostics-max-lines 5 %s 2>&1 | FileCheck %s -strict-whitespace
 
 
 //CHECK: {{.*}}: error: excess elements in scalar initializer
Index: clang/test/Preprocessor/ucn-pp-identifier.c
===
--- clang/test/Preprocessor/ucn-pp-identifier.c
+++ clang/test/Preprocessor/ucn-pp-identifier.c
@@ -112,9 +112,9 @@
 #define capital_u_\U00FC
 // expected-warning@-1 {{incomplete universal character name}} expected-note@-1 {{did you mean to use '\u'?}} expected-warning@-1 {{whitespace}}
 // CHECK: note: did you mean to use '\u'?
-// CHECK-NEXT:   #define capital_u_\U00FC
-// CHECK-NEXT: {{^   \^}}
-// CHECK-NEXT: {{^   u}}
+// CHECK-NEXT: {{^  112 | #define capital_u_\U00FC}}
+// CHECK-NEXT: {{^  |\^}}
+// CHECK-NEXT: {{^  |u}}
 
 #define \u{}   // expected-warning {{empty delimited universal character name; treating as '\' 'u' '{' '}'}} expected-error {{macro name must be an identifier}}
 #define \u1{123}   // expected-warning {{incomplete universal character name; treating as '\' followed by identifier}} expected-error {{macro name must be an identifier}}
Index: clang/test/Parser/brackets.cpp
===
--- clang/test/Parser/brackets.cpp
+++ clang/test/Parser/brackets.cpp
@@ -2,7 +2,7 @@
 // RUN: cp %s %t
 // RUN: not %clang_cc1 -fixit %t -x c++ -DFIXIT
 // RUN: %clang_cc1 -fsyntax-only %t -x c++ -DFIXIT
-// RUN: not %clang_

[PATCH] D149899: [clang-tidy] Support SystemHeaders in .clang-tidy

2023-05-05 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/infrastructure/system-headers.cpp:11
+// RUN: clang-tidy -checks='-*,google-explicit-constructor' 
-header-filter='.*' -config='SystemHeaders: false' %s -- -isystem 
%S/Inputs/system-headers 2>&1 | FileCheck -check-prefix=CHECK-NO-SYSTEM-HEADERS 
%s
+
+#include 

carlosgalvezp wrote:
> PiotrZSL wrote:
> > I missing 2 types of tests here:
> > - config value override, `-config='SystemHeaders: true' 
> > -system-headers=false`
> > - config file override, when one file has `false`, other `true`, but 
> > InheritConfig is used.
> > Both should work, but would be good to test them.
> Thanks for the input! Essentially I followed the same testing pattern as 
> `UseColor`, which is also a global boolean option. 
> 
> Adding the first suggestion should be trivial in the current test case, but I 
> have some doubts about the proposed second test. When I look at the 
> `tests/clang-tidy/infrastructure/config-files.cpp` it only takes into account 
> enabled checks, no other global options are tested such that one overrides 
> the other. Therefore I wonder if there is a rationale for not having such 
> level of testing, perhaps easier maintenance, given that it's already tested 
> by the unit tests? In that case I would propose to not add such a test here, 
> for consistency. WDYT?
I'm fine with that. I'm mainly concern about the first one, simply because I'm 
not sure about outcome, what will have higher priority, command line argument 
or config option.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149899

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


[PATCH] D149904: Generic selection expressions that accept a type operand

2023-05-05 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon added inline comments.



Comment at: clang/lib/AST/ASTImporter.cpp:7033-7036
+  if (E->isExprPredicate())
+ToControllingExpr = importChecked(Err, E->getControllingExpr());
+  else
+ToControllingType = importChecked(Err, E->getControllingType());

Just a NIT: would something like
```
  ToControllingExpr = importChecked(Err, E->isExprPredicate()? 
E->getControllingExpr() : E->getControllingType());
```
look a bit more elegant (when also formatted properly)?



Comment at: clang/lib/Parse/ParseExpr.cpp:3308
+  return ExprError();
+} else {
+  const auto *LIT = cast(ControllingType.get().get());

No `else` after return?



Comment at: clang/lib/Parse/ParseTentative.cpp:645
   isAmbiguous = true;
-
+// We are supopsed to be inside the first operand to a _Generic selection
+// expression, so if we find a comma after the declarator, we've found a




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149904

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


[PATCH] D149904: Generic selection expressions that accept a type operand

2023-05-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman marked 9 inline comments as done.
aaron.ballman added inline comments.



Comment at: clang/include/clang/AST/Expr.h:5686
   /// if and only if the generic selection expression is result-dependent.
-  unsigned NumAssocs, ResultIndex;
+  unsigned NumAssocs, ResultIndex, IsExprPredicate;
   enum : unsigned {

erichkeane wrote:
> I realize this is a rarely used type, but should these be bitfielded somehow? 
>  Particularly now that you're adding a 'bool' field?
The language which specifies that an implementation need only support 511 
identifiers with block scope declared in one block and 127 nesting levels of 
blocks is silent on how many generic selection expression associations 
we're required to support. :-D

I think we could probably assume there's < 2^15 associations in real world code 
so we can cram all of this into one 32-bit value.



Comment at: clang/include/clang/AST/Expr.h:5691
 
+  unsigned getIndexOfControllingExpression() const {
+// If controlled by an expression, the first offset into the Stmt *

erichkeane wrote:
> What is the value of these functions, if they only return 0 or 1?
I was on the fence about these -- it was a nice place to hang an assertion and 
get a "named constant", basically. I can drop them if you'd like.



Comment at: clang/include/clang/AST/Expr.h:5712
+// predicate expression.
+return (int)isExprPredicate();
+  }

erichkeane wrote:
> Should these have asserts also?  Wouldn't saying this is index '0' be 
> incorrect here if t his is the typePredicate?
Nope, these should not assert -- the selection is required to have at least one 
association (and an association is a pair of type and expr), so this is getting 
you the offset to the first association (either the expr or the type).



Comment at: clang/include/clang/AST/Expr.h:5930
+  /// argument.
+  bool isExprPredicate() const { return IsExprPredicate; }
+  /// Whether this generic selection uses a type as its controlling argument.

cor3ntin wrote:
> nitpick: wouldn't `PredicateIsExpr()` make more sense?
Hmmm, I think it would be: `isPredicateAnExpr()` and `isPredicateAType()` but 
I'm also not unhappy with the current names (I read them as "is (expression 
predicate)" and "is (type predicate)"). Your call!



Comment at: clang/include/clang/AST/Expr.h:5970
   ArrayRef getAssocExprs() const {
 return {reinterpret_cast(getTrailingObjects() +
+
getIndexOfStartOfAssociatedExprs()),

cor3ntin wrote:
> Pre-existing but why not use `cast` here?
This is casting a pointer-to-an-AST-node-pointer, so `cast<>` wouldn't work 
(that only works on AST node pointers).



Comment at: clang/include/clang/Parse/Parser.h:2551
+  bool isTypeIdForGenericSelection() {
+bool isAmbiguous;
+if (getLangOpts().CPlusPlus)

erichkeane wrote:
> slight preference to put this declaration in the 'if' condition below, the 
> split in location confused me for a bit trying to figure out where it was 
> being used.
Sure -- I was just trying to avoid curly braces as done in the next function. 
:-D I'll fix up the one in `isTypeIdUnambiguously()` as a drive-by so they 
remain consistent.



Comment at: clang/lib/AST/ASTImporter.cpp:7033-7036
+  if (E->isExprPredicate())
+ToControllingExpr = importChecked(Err, E->getControllingExpr());
+  else
+ToControllingType = importChecked(Err, E->getControllingType());

Fznamznon wrote:
> Just a NIT: would something like
> ```
>   ToControllingExpr = importChecked(Err, E->isExprPredicate()? 
> E->getControllingExpr() : E->getControllingType());
> ```
> look a bit more elegant (when also formatted properly)?
Alas, we can't -- that makes a ternary operator with no common type (`bool ? 
Expr * : TypeSourceInfo *`)



Comment at: clang/lib/Parse/ParseExpr.cpp:3308
+  return ExprError();
+} else {
+  const auto *LIT = cast(ControllingType.get().get());

Fznamznon wrote:
> No `else` after return?
Good catch!



Comment at: clang/lib/Parse/ParseTentative.cpp:645
   isAmbiguous = true;
-
+// We are supopsed to be inside the first operand to a _Generic selection
+// expression, so if we find a comma after the declarator, we've found a

Fznamznon wrote:
> 
Great catch!



Comment at: clang/lib/Sema/SemaExpr.cpp:1704-1711
+// We relax the restriction on use of incomplete types and non-object
+// types with the type-based extension of _Generic. Allowing incomplete
+// objects means those can be used as "tags" for a type-safe way to map
+// to a value. Similarly, matching on function types rather than
+// function pointer types can be useful. However, the restriction on VM
+   

[PATCH] D149872: [OpenMP][OMPIRBuilder] Migrate emitOffloadingArrays and EmitNonContiguousDescriptor from Clang

2023-05-05 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis updated this revision to Diff 519822.
TIFitis added a comment.

Changed std::function to llvm::function_ref for the callbacks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149872

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -4368,6 +4368,252 @@
 Builder.CreatePointerCast(Info.RTArgs.MappersArray, VoidPtrPtrTy);
 }
 
+void OpenMPIRBuilder::emitOffloadingArrays(
+InsertPointTy AllocaIP, InsertPointTy CodeGenIP, MapInfosTy &CombinedInfo,
+TargetDataInfo &Info, bool IsNonContiguous,
+function_ref DeviceAddrCB,
+function_ref CustomMapperCB) {
+  auto EmitNonContiguousDescriptor = [&]() {
+MapInfosTy::StructNonContiguousInfo &NonContigInfo =
+CombinedInfo.NonContigInfo;
+
+// Build an array of struct descriptor_dim and then assign it to
+// offload_args.
+//
+// struct descriptor_dim {
+//  uint64_t offset;
+//  uint64_t count;
+//  uint64_t stride
+// };
+Type *Int64Ty = Builder.getInt64Ty();
+StructType *DimTy = StructType::create(
+M.getContext(), ArrayRef({Int64Ty, Int64Ty, Int64Ty}),
+"struct.descriptor_dim");
+
+enum { OffsetFD = 0, CountFD, StrideFD };
+// We need two index variable here since the size of "Dims" is the same as
+// the size of Components, however, the size of offset, count, and stride is
+// equal to the size of base declaration that is non-contiguous.
+for (unsigned I = 0, L = 0, E = NonContigInfo.Dims.size(); I < E; ++I) {
+  // Skip emitting ir if dimension size is 1 since it cannot be
+  // non-contiguous.
+  if (NonContigInfo.Dims[I] == 1)
+continue;
+  Builder.restoreIP(AllocaIP);
+  ArrayType *ArrayTy = ArrayType::get(DimTy, NonContigInfo.Dims[I]);
+  AllocaInst *DimsAddr =
+  Builder.CreateAlloca(ArrayTy, /* ArraySize = */ nullptr, "dims");
+  Builder.restoreIP(CodeGenIP);
+  for (unsigned II = 0, EE = NonContigInfo.Dims[I]; II < EE; ++II) {
+unsigned RevIdx = EE - II - 1;
+Value *DimsLVal = Builder.CreateInBoundsGEP(
+DimsAddr->getAllocatedType(), DimsAddr,
+{Builder.getInt64(0), Builder.getInt64(II)});
+// Offset
+Value *OffsetLVal = Builder.CreateStructGEP(DimTy, DimsLVal, OffsetFD);
+Builder.CreateAlignedStore(
+NonContigInfo.Offsets[L][RevIdx], OffsetLVal,
+M.getDataLayout().getPrefTypeAlign(OffsetLVal->getType()));
+// Count
+Value *CountLVal = Builder.CreateStructGEP(DimTy, DimsLVal, CountFD);
+Builder.CreateAlignedStore(
+NonContigInfo.Counts[L][RevIdx], CountLVal,
+M.getDataLayout().getPrefTypeAlign(CountLVal->getType()));
+// Stride
+Value *StrideLVal = Builder.CreateStructGEP(DimTy, DimsLVal, StrideFD);
+Builder.CreateAlignedStore(
+NonContigInfo.Strides[L][RevIdx], StrideLVal,
+M.getDataLayout().getPrefTypeAlign(CountLVal->getType()));
+  }
+  // args[I] = &dims
+  Builder.restoreIP(CodeGenIP);
+  Value *DAddr = Builder.CreatePointerBitCastOrAddrSpaceCast(
+  DimsAddr, Builder.getInt8PtrTy());
+  Value *P = Builder.CreateConstInBoundsGEP2_32(
+  ArrayType::get(Builder.getInt8PtrTy(), Info.NumberOfPtrs),
+  Info.RTArgs.PointersArray, 0, I);
+  Builder.CreateAlignedStore(
+  DAddr, P, M.getDataLayout().getPrefTypeAlign(Builder.getInt8PtrTy()));
+  ++L;
+}
+  };
+
+  // Reset the array information.
+  Info.clearArrayInfo();
+  Info.NumberOfPtrs = CombinedInfo.BasePointers.size();
+
+  if (Info.NumberOfPtrs) {
+Builder.restoreIP(AllocaIP);
+// Detect if we have any capture size requiring runtime evaluation of the
+// size so that a constant array could be eventually used.
+ArrayType *PointerArrayType =
+ArrayType::get(Builder.getInt8PtrTy(), Info.NumberOfPtrs);
+
+Info.RTArgs.BasePointersArray = Builder.CreateAlloca(
+PointerArrayType, /* ArraySize = */ nullptr, ".offload_baseptrs");
+
+Info.RTArgs.PointersArray = Builder.CreateAlloca(
+PointerArrayType, /* ArraySize = */ nullptr, ".offload_ptrs");
+AllocaInst *MappersArray = Builder.CreateAlloca(
+PointerArrayType, /* ArraySize = */ nullptr, ".offload_mappers");
+Info.RTArgs.MappersArray = MappersArray;
+
+// If we don't have any VLA types or other types that require runtime
+// evaluation, we can use a constant array for the map sizes, otherwise we
+// need to fill up the arrays as we do for the pointers.
+Type *Int64Ty = Builder.getInt64Ty();

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

2023-05-05 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon added inline comments.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:11141-11145
 if (!Chunk.Fun.hasTrailingReturnType()) {
+  IsValid = false;
   Diag(D.getName().getBeginLoc(),
diag::err_deduction_guide_no_trailing_return_type);
   break;

rsmith wrote:
> Can we just return immediately here? I don't see a reason to keep going -- 
> this error may well indicate that the developer didn't actually mean to 
> declare a deduction guide in the first place, so the diagnostic on a function 
> body below is likely to not be useful.
NIT: You can also just do `return Diag(...)` here and in other places. This is 
equal to `return true`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149516

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


[PATCH] D149752: WIP: Debug symlink creation

2023-05-05 Thread Louis Dionne via Phabricator via cfe-commits
ldionne updated this revision to Diff 519824.
ldionne added a comment.

Use tarball


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149752

Files:
  clang/foo
  libcxx/utils/ci/buildkite-pipeline-clang.yml
  libcxx/utils/ci/generate-buildkite-pipeline
  llvm/cmake/modules/LLVMInstallSymlink.cmake


Index: llvm/cmake/modules/LLVMInstallSymlink.cmake
===
--- llvm/cmake/modules/LLVMInstallSymlink.cmake
+++ llvm/cmake/modules/LLVMInstallSymlink.cmake
@@ -17,7 +17,7 @@
   endif()
   set(outdir "${DESTDIR}${outdir}")
 
-  message(STATUS "Creating ${name}")
+  message(STATUS "Creating ${name} with ${link_or_copy}")
 
   execute_process(
 COMMAND "${CMAKE_COMMAND}" -E ${link_or_copy} "${target}" "${name}"
Index: libcxx/utils/ci/generate-buildkite-pipeline
===
--- libcxx/utils/ci/generate-buildkite-pipeline
+++ libcxx/utils/ci/generate-buildkite-pipeline
@@ -19,7 +19,7 @@
   CLANG_CHANGED=true
 fi
 
-if [[ "${CLANG_CHANGED}" == "true" && "${LIBCXX_CHANGED}" != "true" ]]; then
+if [[ "${CLANG_CHANGED}" == "true" ]]; then
   cat libcxx/utils/ci/buildkite-pipeline-clang.yml
 else
   cat libcxx/utils/ci/buildkite-pipeline.yml
Index: libcxx/utils/ci/buildkite-pipeline-clang.yml
===
--- libcxx/utils/ci/buildkite-pipeline-clang.yml
+++ libcxx/utils/ci/buildkite-pipeline-clang.yml
@@ -24,7 +24,8 @@
   # but with the number of jobs we run daily, this can result in thousands 
of GB of network I/O.
   - "cmake -S llvm -B build -G Ninja -DCMAKE_BUILD_TYPE=Release 
-DCMAKE_INSTALL_PREFIX=install -DLLVM_ENABLE_PROJECTS=\"clang;compiler-rt\""
   - "ninja -C build install-clang install-clang-resource-headers"
-  - "buildkite-agent artifact upload --debug 'install/**/*'"
+  - "tar -czvf install.tar.gz install/"
+  - "buildkite-agent artifact upload --debug install.tar.gz"
 env:
 CC: "clang-${LLVM_HEAD_VERSION}"
 CXX: "clang++-${LLVM_HEAD_VERSION}"
@@ -41,7 +42,8 @@
 
   - label: "C++03"
 commands:
-  - "buildkite-agent artifact download 'install/**' ."
+  - "buildkite-agent artifact download install.tar.gz ."
+  - "tar -xzvf install.tar.gz"
   - "export CC=$(pwd)/install/bin/clang"
   - "export CXX=$(pwd)/install/bin/clang++"
   - "chmod +x install/bin/clang install/bin/clang++"
@@ -63,7 +65,8 @@
 
   - label: "C++2b"
 commands:
-  - "buildkite-agent artifact download 'install/**' ."
+  - "buildkite-agent artifact download install.tar.gz ."
+  - "tar -xzvf install.tar.gz"
   - "export CC=$(pwd)/install/bin/clang"
   - "export CXX=$(pwd)/install/bin/clang++"
   - "chmod +x install/bin/clang install/bin/clang++"
@@ -85,7 +88,8 @@
 
   - label: "Modules"
 commands:
-  - "buildkite-agent artifact download 'install/**' ."
+  - "buildkite-agent artifact download install.tar.gz ."
+  - "tar -xzvf install.tar.gz"
   - "export CC=$(pwd)/install/bin/clang"
   - "export CXX=$(pwd)/install/bin/clang++"
   - "chmod +x install/bin/clang install/bin/clang++"


Index: llvm/cmake/modules/LLVMInstallSymlink.cmake
===
--- llvm/cmake/modules/LLVMInstallSymlink.cmake
+++ llvm/cmake/modules/LLVMInstallSymlink.cmake
@@ -17,7 +17,7 @@
   endif()
   set(outdir "${DESTDIR}${outdir}")
 
-  message(STATUS "Creating ${name}")
+  message(STATUS "Creating ${name} with ${link_or_copy}")
 
   execute_process(
 COMMAND "${CMAKE_COMMAND}" -E ${link_or_copy} "${target}" "${name}"
Index: libcxx/utils/ci/generate-buildkite-pipeline
===
--- libcxx/utils/ci/generate-buildkite-pipeline
+++ libcxx/utils/ci/generate-buildkite-pipeline
@@ -19,7 +19,7 @@
   CLANG_CHANGED=true
 fi
 
-if [[ "${CLANG_CHANGED}" == "true" && "${LIBCXX_CHANGED}" != "true" ]]; then
+if [[ "${CLANG_CHANGED}" == "true" ]]; then
   cat libcxx/utils/ci/buildkite-pipeline-clang.yml
 else
   cat libcxx/utils/ci/buildkite-pipeline.yml
Index: libcxx/utils/ci/buildkite-pipeline-clang.yml
===
--- libcxx/utils/ci/buildkite-pipeline-clang.yml
+++ libcxx/utils/ci/buildkite-pipeline-clang.yml
@@ -24,7 +24,8 @@
   # but with the number of jobs we run daily, this can result in thousands of GB of network I/O.
   - "cmake -S llvm -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install -DLLVM_ENABLE_PROJECTS=\"clang;compiler-rt\""
   - "ninja -C build install-clang install-clang-resource-headers"
-  - "buildkite-agent artifact upload --debug 'install/**/*'"
+  - "tar -czvf install.tar.gz install/"
+  - "buildkite-agent artifact upload --debug install.tar.gz"
 env:
 CC:

[clang] c7cd7a0 - [clang][test][RISCV] Pre-commit test for HasLegalHalfType patch

2023-05-05 Thread Alex Bradbury via cfe-commits

Author: Alex Bradbury
Date: 2023-05-05T13:55:20+01:00
New Revision: c7cd7a050acb98b9d1df895c4b009c7c7078d917

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

LOG: [clang][test][RISCV] Pre-commit test for HasLegalHalfType patch

This test captures the codegen difference of D145071.

Added: 
clang/test/CodeGen/RISCV/Float16-arith.c

Modified: 


Removed: 




diff  --git a/clang/test/CodeGen/RISCV/Float16-arith.c 
b/clang/test/CodeGen/RISCV/Float16-arith.c
new file mode 100644
index 0..63097de2fabb4
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/Float16-arith.c
@@ -0,0 +1,43 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 2
+// RUN: %clang_cc1 -triple riscv32 -emit-llvm %s -o - \
+// RUN:   | FileCheck -check-prefix=NOZFH %s
+// RUN: %clang_cc1 -triple riscv64 -emit-llvm %s -o - \
+// RUN:   | FileCheck -check-prefix=NOZFH %s
+// RUN: %clang_cc1 -triple riscv32 -target-feature +zfh -emit-llvm %s -o - \
+// RUN:   | FileCheck -check-prefix=ZFH %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +zfh -emit-llvm %s -o - \
+// RUN:   | FileCheck -check-prefix=ZFH %s
+
+_Float16 x, y, z;
+
+// With no native half type support (no zfh), f16 will be promoted to f32.
+// With zfh, it shouldn't be (FIXME: set HasLegalHalfType = true in order to
+// get this behaviour for zfh).
+
+// NOZFH-LABEL: define dso_local void @f16_add
+// NOZFH-SAME: () #[[ATTR0:[0-9]+]] {
+// NOZFH-NEXT:  entry:
+// NOZFH-NEXT:[[TMP0:%.*]] = load half, ptr @y, align 2
+// NOZFH-NEXT:[[EXT:%.*]] = fpext half [[TMP0]] to float
+// NOZFH-NEXT:[[TMP1:%.*]] = load half, ptr @z, align 2
+// NOZFH-NEXT:[[EXT1:%.*]] = fpext half [[TMP1]] to float
+// NOZFH-NEXT:[[ADD:%.*]] = fadd float [[EXT]], [[EXT1]]
+// NOZFH-NEXT:[[UNPROMOTION:%.*]] = fptrunc float [[ADD]] to half
+// NOZFH-NEXT:store half [[UNPROMOTION]], ptr @x, align 2
+// NOZFH-NEXT:ret void
+//
+// ZFH-LABEL: define dso_local void @f16_add
+// ZFH-SAME: () #[[ATTR0:[0-9]+]] {
+// ZFH-NEXT:  entry:
+// ZFH-NEXT:[[TMP0:%.*]] = load half, ptr @y, align 2
+// ZFH-NEXT:[[EXT:%.*]] = fpext half [[TMP0]] to float
+// ZFH-NEXT:[[TMP1:%.*]] = load half, ptr @z, align 2
+// ZFH-NEXT:[[EXT1:%.*]] = fpext half [[TMP1]] to float
+// ZFH-NEXT:[[ADD:%.*]] = fadd float [[EXT]], [[EXT1]]
+// ZFH-NEXT:[[UNPROMOTION:%.*]] = fptrunc float [[ADD]] to half
+// ZFH-NEXT:store half [[UNPROMOTION]], ptr @x, align 2
+// ZFH-NEXT:ret void
+//
+void f16_add() {
+  x = y + z;
+}



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


[clang] 560065b - [clang][RISCV] Set HasLegalHalfType to true if zfh is enabled

2023-05-05 Thread Alex Bradbury via cfe-commits

Author: Alex Bradbury
Date: 2023-05-05T13:55:43+01:00
New Revision: 560065b6ecd539862fbc61401b02a1d5faea1ad1

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

LOG: [clang][RISCV] Set HasLegalHalfType to true if zfh is enabled

The desired semantics for HasLegalHalfType are slightly unclear in that
the comment for HasLegalHalfType says "True if the backend supports
operations on the half LLVM IR type." Which operations? We get very
limited scalar operations with zfhmin, more with zfh, and vector support
with zvfh. While the comment for hasLegalHalfType() says "Determine
whether _Float16 is supported on this target."

This patch sets HasLegalHalfType to true for zfh.

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

Added: 


Modified: 
clang/lib/Basic/Targets/RISCV.cpp
clang/test/CodeGen/RISCV/Float16-arith.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index 6720fcd567ac8..bb61d75372667 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -320,6 +320,9 @@ bool 
RISCVTargetInfo::handleTargetFeatures(std::vector &Features,
   if (ABI.empty())
 ABI = ISAInfo->computeDefaultABI().str();
 
+  if (ISAInfo->hasExtension("zfh"))
+HasLegalHalfType = true;
+
   return true;
 }
 

diff  --git a/clang/test/CodeGen/RISCV/Float16-arith.c 
b/clang/test/CodeGen/RISCV/Float16-arith.c
index 63097de2fabb4..8fb3c1b146179 100644
--- a/clang/test/CodeGen/RISCV/Float16-arith.c
+++ b/clang/test/CodeGen/RISCV/Float16-arith.c
@@ -11,8 +11,7 @@
 _Float16 x, y, z;
 
 // With no native half type support (no zfh), f16 will be promoted to f32.
-// With zfh, it shouldn't be (FIXME: set HasLegalHalfType = true in order to
-// get this behaviour for zfh).
+// With zfh, it shouldn't be.
 
 // NOZFH-LABEL: define dso_local void @f16_add
 // NOZFH-SAME: () #[[ATTR0:[0-9]+]] {
@@ -30,12 +29,9 @@ _Float16 x, y, z;
 // ZFH-SAME: () #[[ATTR0:[0-9]+]] {
 // ZFH-NEXT:  entry:
 // ZFH-NEXT:[[TMP0:%.*]] = load half, ptr @y, align 2
-// ZFH-NEXT:[[EXT:%.*]] = fpext half [[TMP0]] to float
 // ZFH-NEXT:[[TMP1:%.*]] = load half, ptr @z, align 2
-// ZFH-NEXT:[[EXT1:%.*]] = fpext half [[TMP1]] to float
-// ZFH-NEXT:[[ADD:%.*]] = fadd float [[EXT]], [[EXT1]]
-// ZFH-NEXT:[[UNPROMOTION:%.*]] = fptrunc float [[ADD]] to half
-// ZFH-NEXT:store half [[UNPROMOTION]], ptr @x, align 2
+// ZFH-NEXT:[[ADD:%.*]] = fadd half [[TMP0]], [[TMP1]]
+// ZFH-NEXT:store half [[ADD]], ptr @x, align 2
 // ZFH-NEXT:ret void
 //
 void f16_add() {



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


[PATCH] D145071: [clang][RISCV] Set HasLegalHalfType to true if zfh is enabled

2023-05-05 Thread Alex Bradbury via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG560065b6ecd5: [clang][RISCV] Set HasLegalHalfType to true if 
zfh is enabled (authored by asb).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D145071?vs=501507&id=519825#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145071

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/test/CodeGen/RISCV/Float16-arith.c


Index: clang/test/CodeGen/RISCV/Float16-arith.c
===
--- clang/test/CodeGen/RISCV/Float16-arith.c
+++ clang/test/CodeGen/RISCV/Float16-arith.c
@@ -11,8 +11,7 @@
 _Float16 x, y, z;
 
 // With no native half type support (no zfh), f16 will be promoted to f32.
-// With zfh, it shouldn't be (FIXME: set HasLegalHalfType = true in order to
-// get this behaviour for zfh).
+// With zfh, it shouldn't be.
 
 // NOZFH-LABEL: define dso_local void @f16_add
 // NOZFH-SAME: () #[[ATTR0:[0-9]+]] {
@@ -30,12 +29,9 @@
 // ZFH-SAME: () #[[ATTR0:[0-9]+]] {
 // ZFH-NEXT:  entry:
 // ZFH-NEXT:[[TMP0:%.*]] = load half, ptr @y, align 2
-// ZFH-NEXT:[[EXT:%.*]] = fpext half [[TMP0]] to float
 // ZFH-NEXT:[[TMP1:%.*]] = load half, ptr @z, align 2
-// ZFH-NEXT:[[EXT1:%.*]] = fpext half [[TMP1]] to float
-// ZFH-NEXT:[[ADD:%.*]] = fadd float [[EXT]], [[EXT1]]
-// ZFH-NEXT:[[UNPROMOTION:%.*]] = fptrunc float [[ADD]] to half
-// ZFH-NEXT:store half [[UNPROMOTION]], ptr @x, align 2
+// ZFH-NEXT:[[ADD:%.*]] = fadd half [[TMP0]], [[TMP1]]
+// ZFH-NEXT:store half [[ADD]], ptr @x, align 2
 // ZFH-NEXT:ret void
 //
 void f16_add() {
Index: clang/lib/Basic/Targets/RISCV.cpp
===
--- clang/lib/Basic/Targets/RISCV.cpp
+++ clang/lib/Basic/Targets/RISCV.cpp
@@ -320,6 +320,9 @@
   if (ABI.empty())
 ABI = ISAInfo->computeDefaultABI().str();
 
+  if (ISAInfo->hasExtension("zfh"))
+HasLegalHalfType = true;
+
   return true;
 }
 


Index: clang/test/CodeGen/RISCV/Float16-arith.c
===
--- clang/test/CodeGen/RISCV/Float16-arith.c
+++ clang/test/CodeGen/RISCV/Float16-arith.c
@@ -11,8 +11,7 @@
 _Float16 x, y, z;
 
 // With no native half type support (no zfh), f16 will be promoted to f32.
-// With zfh, it shouldn't be (FIXME: set HasLegalHalfType = true in order to
-// get this behaviour for zfh).
+// With zfh, it shouldn't be.
 
 // NOZFH-LABEL: define dso_local void @f16_add
 // NOZFH-SAME: () #[[ATTR0:[0-9]+]] {
@@ -30,12 +29,9 @@
 // ZFH-SAME: () #[[ATTR0:[0-9]+]] {
 // ZFH-NEXT:  entry:
 // ZFH-NEXT:[[TMP0:%.*]] = load half, ptr @y, align 2
-// ZFH-NEXT:[[EXT:%.*]] = fpext half [[TMP0]] to float
 // ZFH-NEXT:[[TMP1:%.*]] = load half, ptr @z, align 2
-// ZFH-NEXT:[[EXT1:%.*]] = fpext half [[TMP1]] to float
-// ZFH-NEXT:[[ADD:%.*]] = fadd float [[EXT]], [[EXT1]]
-// ZFH-NEXT:[[UNPROMOTION:%.*]] = fptrunc float [[ADD]] to half
-// ZFH-NEXT:store half [[UNPROMOTION]], ptr @x, align 2
+// ZFH-NEXT:[[ADD:%.*]] = fadd half [[TMP0]], [[TMP1]]
+// ZFH-NEXT:store half [[ADD]], ptr @x, align 2
 // ZFH-NEXT:ret void
 //
 void f16_add() {
Index: clang/lib/Basic/Targets/RISCV.cpp
===
--- clang/lib/Basic/Targets/RISCV.cpp
+++ clang/lib/Basic/Targets/RISCV.cpp
@@ -320,6 +320,9 @@
   if (ABI.empty())
 ABI = ISAInfo->computeDefaultABI().str();
 
+  if (ISAInfo->hasExtension("zfh"))
+HasLegalHalfType = true;
+
   return true;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D149904: Generic selection expressions that accept a type operand

2023-05-05 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/include/clang/AST/Expr.h:5712
+// predicate expression.
+return (int)isExprPredicate();
+  }

aaron.ballman wrote:
> erichkeane wrote:
> > Should these have asserts also?  Wouldn't saying this is index '0' be 
> > incorrect here if t his is the typePredicate?
> Nope, these should not assert -- the selection is required to have at least 
> one association (and an association is a pair of type and expr), so this is 
> getting you the offset to the first association (either the expr or the type).
OH! I see, there are 2 separate lists here, 1 for types, 1 for expressions, is 
that it?  And you're storing the controlling expression/type in the 1st one (if 
it exists)?



Comment at: clang/lib/Sema/SemaExpr.cpp:19851
+bool IsExpr = GSE->isExprPredicate();
+if (IsExpr)
+  ExOrTy = GSE->getControllingExpr();

aaron.ballman wrote:
> erichkeane wrote:
> > I find myself wondering if a `getControllingOperand` here is valuable?
> This pattern only comes up once, so I don't think it's worth it, but it's 
> certainly easy enough to add if you disagree.
Yep, I think I agree, after seeing the rest of the review, I don't see as much 
value. 

On this re-read, I kind of which we instead had 2 separate 'create' functions 
here, rather than going through void*, so that this becomes:

```
if (IsExpr)
  return AnyChanged ? S.CreateGenericSelectionExpr(, 
GSE->getControllingExpr(), ...) : ExprEmpty();

  return AnyChanged ? S.CreateGenericSelectionExpr(, 
GSE->getControllingType(), ...) : ExprEmpty();
```

The `void*` version gives me the jeebies (and is perhaps a 'worse' interface?  
Particularly for libclang folks?).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149904

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


[PATCH] D149904: Generic selection expressions that accept a type operand

2023-05-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman marked 10 inline comments as done.
aaron.ballman added inline comments.



Comment at: clang/include/clang/AST/Expr.h:5712
+// predicate expression.
+return (int)isExprPredicate();
+  }

erichkeane wrote:
> aaron.ballman wrote:
> > erichkeane wrote:
> > > Should these have asserts also?  Wouldn't saying this is index '0' be 
> > > incorrect here if t his is the typePredicate?
> > Nope, these should not assert -- the selection is required to have at least 
> > one association (and an association is a pair of type and expr), so this is 
> > getting you the offset to the first association (either the expr or the 
> > type).
> OH! I see, there are 2 separate lists here, 1 for types, 1 for expressions, 
> is that it?  And you're storing the controlling expression/type in the 1st 
> one (if it exists)?
Correct! Two *almost* parallel lists where the first entry in either (but not 
both) list is potentially the controlling operand.



Comment at: clang/lib/Sema/SemaExpr.cpp:19851
+bool IsExpr = GSE->isExprPredicate();
+if (IsExpr)
+  ExOrTy = GSE->getControllingExpr();

erichkeane wrote:
> aaron.ballman wrote:
> > erichkeane wrote:
> > > I find myself wondering if a `getControllingOperand` here is valuable?
> > This pattern only comes up once, so I don't think it's worth it, but it's 
> > certainly easy enough to add if you disagree.
> Yep, I think I agree, after seeing the rest of the review, I don't see as 
> much value. 
> 
> On this re-read, I kind of which we instead had 2 separate 'create' functions 
> here, rather than going through void*, so that this becomes:
> 
> ```
> if (IsExpr)
>   return AnyChanged ? S.CreateGenericSelectionExpr(, 
> GSE->getControllingExpr(), ...) : ExprEmpty();
> 
>   return AnyChanged ? S.CreateGenericSelectionExpr(, 
> GSE->getControllingType(), ...) : ExprEmpty();
> ```
> 
> The `void*` version gives me the jeebies (and is perhaps a 'worse' interface? 
>  Particularly for libclang folks?).
That makes this one use better but at the expense of making that create 
function rather awkward.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149904

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


[PATCH] D146987: [Assignment Tracking] Enable by default

2023-05-05 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng added a comment.

Got crash for RISC-V on top of trunk:

  [kitoc@hsinchu02 build]$ cat x.c
  typedef __rvv_uint32m4_t a;
  void b() { a c; }
  [kitoc@hsinchu02 build]$ bin/clang -target riscv64-elf x.c -O -g
  clang-14: 
/home/kitoc/llvm-workspace/llvm-project/llvm/lib/IR/DebugInfo.cpp:2162: bool 
llvm::AssignmentTrackingPass::runOnFunction(llvm::Function&): Assertion 
`llvm::any_of(Markers, [DDI](DbgAssignIntrinsic *DAI) { return 
DebugVariableAggregate(DAI) == DebugVariableAggregate(DDI); })' failed.
  PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash 
backtrace, preprocessed source, and associated run script.
  Stack dump:
  0.  Program arguments: /scratch1/kitoc/llvm-workspace/build/bin/clang-14 
-cc1 -triple riscv64-unknown-unknown-elf -emit-obj -disable-free 
-clear-ast-before-backend -main-file-name x.c -mrelocation-model static 
-mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math 
-fno-verbose-asm -mconstructor-aliases -nostdsysteminc -target-cpu generic-rv64 
-target-feature +m -target-feature +a -target-feature +c -target-feature -e 
-target-feature -f -target-feature -d -target-feature -h -target-feature 
-zihintpause -target-feature -zfhmin -target-feature -zfh -target-feature 
-zfinx -target-feature -zdinx -target-feature -zhinxmin -target-feature -zhinx 
-target-feature -zba -target-feature -zbb -target-feature -zbc -target-feature 
-zbs -target-feature -zbkb -target-feature -zbkc -target-feature -zbkx 
-target-feature -zknd -target-feature -zkne -target-feature -zknh 
-target-feature -zksed -target-feature -zksh -target-feature -zkr 
-target-feature -zkn -target-feature -zks -target-feature -zkt -target-feature 
-zk -target-feature -zmmul -target-feature -v -target-feature -zvl32b 
-target-feature -zvl64b -target-feature -zvl128b -target-feature -zvl256b 
-target-feature -zvl512b -target-feature -zvl1024b -target-feature -zvl2048b 
-target-feature -zvl4096b -target-feature -zvl8192b -target-feature -zvl16384b 
-target-feature -zvl32768b -target-feature -zvl65536b -target-feature -zve32x 
-target-feature -zve32f -target-feature -zve64x -target-feature -zve64f 
-target-feature -zve64d -target-feature -zicbom -target-feature -zicboz 
-target-feature -zicbop -target-feature -zicntr -target-feature -zicsr 
-target-feature -zifencei -target-feature -zihpm -target-feature -zawrs 
-target-feature -svnapot -target-feature -svpbmt -target-feature -svinval 
-target-feature -xsfvcp -target-feature -xtheadba -target-feature -xtheadbb 
-target-feature -xtheadbs -target-feature -xtheadcmo -target-feature 
-xtheadcondmov -target-feature -xtheadfmemidx -target-feature -xtheadmac 
-target-feature -xtheadmemidx -target-feature -xtheadmempair -target-feature 
-xtheadsync -target-feature -xtheadvdot -target-feature -xventanacondops 
-target-feature -experimental-smaia -target-feature -experimental-ssaia 
-target-feature -experimental-zihintntl -target-feature -experimental-zca 
-target-feature -experimental-zcb -target-feature -experimental-zcd 
-target-feature -experimental-zcf -target-feature -experimental-zcmt 
-target-feature -experimental-zfa -target-feature -experimental-zicond 
-target-feature -experimental-zvfh -target-feature -experimental-ztso 
-target-feature -experimental-zvbb -target-feature -experimental-zvbc 
-target-feature -experimental-zvkg -target-feature -experimental-zvkn 
-target-feature -experimental-zvkned -target-feature -experimental-zvkng 
-target-feature -experimental-zvknha -target-feature -experimental-zvknhb 
-target-feature -experimental-zvks -target-feature -experimental-zvksed 
-target-feature -experimental-zvksg -target-feature -experimental-zvksh 
-target-feature -experimental-zvkt -target-feature +relax -target-feature 
-save-restore -target-abi lp64 -msmall-data-limit 8 
-debug-info-kind=constructor -dwarf-version=5 -debugger-tuning=gdb 
-fcoverage-compilation-dir=/home/kitoc/llvm-workspace/build -resource-dir 
/scratch1/kitoc/llvm-workspace/build/lib/clang/17 -internal-isystem 
/scratch1/kitoc/llvm-workspace/build/lib/clang/17/include -internal-isystem 
/scratch1/kitoc/llvm-workspace/build/bin/../lib/clang-runtimes/riscv64-elf/include
 -O1 -fdebug-compilation-dir=/home/kitoc/llvm-workspace/build -ferror-limit 19 
-fno-signed-char -fgnuc-version=4.2.1 -fcolor-diagnostics -faddrsig 
-D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/x-2feb04.o -x c x.c
  1.   parser at end of file
  2.  Optimizer
   #0 0x7fe505ca91a2 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
/home/kitoc/llvm-workspace/llvm-project/llvm/lib/Support/Unix/Signals.inc:602:22
   #1 0x7fe505ca9265 PrintStackTraceSignalHandler(void*) 
/home/kitoc/llvm-workspace/llvm-project/llvm/lib/Support/Unix/Signals.inc:675:1
   #2 0x7fe505ca6cca llvm::sys::RunSignalHandlers() 
/home/kitoc/llvm-workspace/llvm-project/llvm/lib/Support/Signals.cpp:104:20
   #3 0x7fe505ca8b0b SignalHandler(int) 
/home/kitoc/llvm-workspace/llvm-project/llvm/lib/Support/

[PATCH] D148689: [clang][Interp] Handle PredefinedExprs

2023-05-05 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 519834.

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

https://reviews.llvm.org/D148689

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


Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -std=c++11 -verify 
%s
-// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -std=c++20 -verify 
%s
-// RUN: %clang_cc1 -std=c++11 -verify=ref %s
-// RUN: %clang_cc1 -std=c++20 -verify=ref %s
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -fms-extensions 
-std=c++11 -verify %s
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -fms-extensions 
-std=c++20 -verify %s
+// RUN: %clang_cc1 -std=c++11 -fms-extensions -verify=ref %s
+// RUN: %clang_cc1 -std=c++20 -fms-extensions -verify=ref %s
 
 #define INT_MIN (~__INT_MAX__)
 #define INT_MAX __INT_MAX__
@@ -831,3 +831,27 @@
 }
 
 #endif
+
+namespace PredefinedExprs {
+#if __cplusplus >= 201402L
+  template
+  constexpr bool strings_match(const CharT *str1, const CharT *str2) {
+while (*str1 && *str2) {
+  if (*str1++ != *str2++)
+return false;
+};
+
+return *str1 == *str2;
+  }
+
+  void foo() {
+static_assert(strings_match(__FUNCDNAME__, "_ZN15PredefinedExprs3fooEv"), 
"");
+static_assert(strings_match(__FUNCSIG__, "void __cdecl 
PredefinedExprs::foo(void)"), "");
+static_assert(strings_match(L__FUNCSIG__, L"void __cdecl 
PredefinedExprs::foo(void)"), "");
+static_assert(strings_match(L__FUNCTION__, L"foo"), "0x402010");
+static_assert(strings_match(__FUNCTION__, "foo"), "");
+static_assert(strings_match(__func__, "foo"), "");
+static_assert(strings_match(__PRETTY_FUNCTION__, "void 
PredefinedExprs::foo()"), "");
+  }
+#endif
+}
Index: clang/lib/AST/Interp/ByteCodeExprGen.h
===
--- clang/lib/AST/Interp/ByteCodeExprGen.h
+++ clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -96,6 +96,7 @@
   bool VisitCompoundLiteralExpr(const CompoundLiteralExpr *E);
   bool VisitTypeTraitExpr(const TypeTraitExpr *E);
   bool VisitLambdaExpr(const LambdaExpr *E);
+  bool VisitPredefinedExpr(const PredefinedExpr *E);
 
 protected:
   bool visitExpr(const Expr *E) override;
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1004,6 +1004,14 @@
   return true;
 }
 
+template 
+bool ByteCodeExprGen::VisitPredefinedExpr(const PredefinedExpr *E) {
+  if (DiscardResult)
+return true;
+
+  return this->visit(E->getFunctionName());
+}
+
 template  bool ByteCodeExprGen::discard(const Expr *E) 
{
   if (E->containsErrors())
 return false;


Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -std=c++11 -verify %s
-// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -std=c++20 -verify %s
-// RUN: %clang_cc1 -std=c++11 -verify=ref %s
-// RUN: %clang_cc1 -std=c++20 -verify=ref %s
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -fms-extensions -std=c++11 -verify %s
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -fms-extensions -std=c++20 -verify %s
+// RUN: %clang_cc1 -std=c++11 -fms-extensions -verify=ref %s
+// RUN: %clang_cc1 -std=c++20 -fms-extensions -verify=ref %s
 
 #define INT_MIN (~__INT_MAX__)
 #define INT_MAX __INT_MAX__
@@ -831,3 +831,27 @@
 }
 
 #endif
+
+namespace PredefinedExprs {
+#if __cplusplus >= 201402L
+  template
+  constexpr bool strings_match(const CharT *str1, const CharT *str2) {
+while (*str1 && *str2) {
+  if (*str1++ != *str2++)
+return false;
+};
+
+return *str1 == *str2;
+  }
+
+  void foo() {
+static_assert(strings_match(__FUNCDNAME__, "_ZN15PredefinedExprs3fooEv"), "");
+static_assert(strings_match(__FUNCSIG__, "void __cdecl PredefinedExprs::foo(void)"), "");
+static_assert(strings_match(L__FUNCSIG__, L"void __cdecl PredefinedExprs::foo(void)"), "");
+static_assert(strings_match(L__FUNCTION__, L"foo"), "0x402010");
+static_assert(strings_match(__FUNCTION__, "foo"), "");
+static_assert(strings_match(__func__, "foo"), "");
+static_assert(strings_match(__PRETTY_FUNCTION__, "void PredefinedExprs::foo()"), "");
+  }
+#endif
+}
Index: clang/lib/AST/Interp/ByteCodeExprGen.h
===
--- clang/lib/AST/Interp/ByteCodeExprGen.h
+++ clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -96,6 +96,7 @@
   bo

[PATCH] D148689: [clang][Interp] Handle PredefinedExprs

2023-05-05 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 519835.

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

https://reviews.llvm.org/D148689

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


Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -std=c++11 -verify 
%s
-// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -std=c++20 -verify 
%s
-// RUN: %clang_cc1 -std=c++11 -verify=ref %s
-// RUN: %clang_cc1 -std=c++20 -verify=ref %s
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -fms-extensions 
-std=c++11 -verify %s
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -fms-extensions 
-std=c++20 -verify %s
+// RUN: %clang_cc1 -std=c++11 -fms-extensions -verify=ref %s
+// RUN: %clang_cc1 -std=c++20 -fms-extensions -verify=ref %s
 
 #define INT_MIN (~__INT_MAX__)
 #define INT_MAX __INT_MAX__
@@ -831,3 +831,27 @@
 }
 
 #endif
+
+namespace PredefinedExprs {
+#if __cplusplus >= 201402L
+  template
+  constexpr bool strings_match(const CharT *str1, const CharT *str2) {
+while (*str1 && *str2) {
+  if (*str1++ != *str2++)
+return false;
+};
+
+return *str1 == *str2;
+  }
+
+  void foo() {
+static_assert(strings_match(__FUNCDNAME__, "_ZN15PredefinedExprs3fooEv"), 
"");
+static_assert(strings_match(__FUNCSIG__, "void __cdecl 
PredefinedExprs::foo(void)"), "");
+static_assert(strings_match(L__FUNCSIG__, L"void __cdecl 
PredefinedExprs::foo(void)"), "");
+static_assert(strings_match(L__FUNCTION__, L"foo"), "");
+static_assert(strings_match(__FUNCTION__, "foo"), "");
+static_assert(strings_match(__func__, "foo"), "");
+static_assert(strings_match(__PRETTY_FUNCTION__, "void 
PredefinedExprs::foo()"), "");
+  }
+#endif
+}
Index: clang/lib/AST/Interp/ByteCodeExprGen.h
===
--- clang/lib/AST/Interp/ByteCodeExprGen.h
+++ clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -96,6 +96,7 @@
   bool VisitCompoundLiteralExpr(const CompoundLiteralExpr *E);
   bool VisitTypeTraitExpr(const TypeTraitExpr *E);
   bool VisitLambdaExpr(const LambdaExpr *E);
+  bool VisitPredefinedExpr(const PredefinedExpr *E);
 
 protected:
   bool visitExpr(const Expr *E) override;
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1004,6 +1004,14 @@
   return true;
 }
 
+template 
+bool ByteCodeExprGen::VisitPredefinedExpr(const PredefinedExpr *E) {
+  if (DiscardResult)
+return true;
+
+  return this->visit(E->getFunctionName());
+}
+
 template  bool ByteCodeExprGen::discard(const Expr *E) 
{
   if (E->containsErrors())
 return false;


Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -std=c++11 -verify %s
-// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -std=c++20 -verify %s
-// RUN: %clang_cc1 -std=c++11 -verify=ref %s
-// RUN: %clang_cc1 -std=c++20 -verify=ref %s
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -fms-extensions -std=c++11 -verify %s
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -fms-extensions -std=c++20 -verify %s
+// RUN: %clang_cc1 -std=c++11 -fms-extensions -verify=ref %s
+// RUN: %clang_cc1 -std=c++20 -fms-extensions -verify=ref %s
 
 #define INT_MIN (~__INT_MAX__)
 #define INT_MAX __INT_MAX__
@@ -831,3 +831,27 @@
 }
 
 #endif
+
+namespace PredefinedExprs {
+#if __cplusplus >= 201402L
+  template
+  constexpr bool strings_match(const CharT *str1, const CharT *str2) {
+while (*str1 && *str2) {
+  if (*str1++ != *str2++)
+return false;
+};
+
+return *str1 == *str2;
+  }
+
+  void foo() {
+static_assert(strings_match(__FUNCDNAME__, "_ZN15PredefinedExprs3fooEv"), "");
+static_assert(strings_match(__FUNCSIG__, "void __cdecl PredefinedExprs::foo(void)"), "");
+static_assert(strings_match(L__FUNCSIG__, L"void __cdecl PredefinedExprs::foo(void)"), "");
+static_assert(strings_match(L__FUNCTION__, L"foo"), "");
+static_assert(strings_match(__FUNCTION__, "foo"), "");
+static_assert(strings_match(__func__, "foo"), "");
+static_assert(strings_match(__PRETTY_FUNCTION__, "void PredefinedExprs::foo()"), "");
+  }
+#endif
+}
Index: clang/lib/AST/Interp/ByteCodeExprGen.h
===
--- clang/lib/AST/Interp/ByteCodeExprGen.h
+++ clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -96,6 +96,7 @@
   bool VisitCompound

[PATCH] D149922: Fix nullptr dereference found by Coverity static analysis tool

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

Looks like both ABIs that use this assume the parameter passed to 
`getMemberPointerInfo` is non-null.  While we DO check the type (in reality, we 
probably should be doing a `if (const auto *MPT = 
Ty->getAs())` instead, I think this is a problem that at 
least SHOULD be fixed somehow.

Why was this abandoned?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149922

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


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

2023-05-05 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/Sema/SemaType.cpp:2582
   } else if (ArraySize->isTypeDependent() || ArraySize->isValueDependent()) {
-T = Context.getDependentSizedArrayType(T, ArraySize, ASM, Quals, Brackets);
+if (getLangOpts().CPlusPlus) {
+  T = Context.getDependentSizedArrayType(T, ArraySize, ASM, Quals,

HerrCai0907 wrote:
> erichkeane wrote:
> > So I'm still not sure this is the 'right' away about it.  I think we should 
> > instead properly handle the `containsErrors` case and just always create a 
> > non-dependent sized array, except with the `RecoveryExpr` having the 
> > correct type.
> For CPP, dependent sized array is acceptable and necessary.
> 
> For C, I don't think SemaType is a correctly way to resolve TypoExpr, It 
> should be done by `ActOnXXX`.
Why is the dependent array necessary for C++?  I also don't get your C logic 
here... I think that Nullptr should be a RecoveryExpr of the proper type.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149612

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


[PATCH] D148370: [Clang][Flang][OpenMP] Add loadOffloadInfoMetadata and createOffloadEntriesAndInfoMetadata into OMPIRBuilder's finalize and initialize

2023-05-05 Thread Andrew Gozillon via Phabricator via cfe-commits
agozillon added a comment.

Hey @jdoerfert sorry to bother you, would it be possible to have this signed 
off on if there is no further issues with the current patch? Thank you for your 
time!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148370

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


[PATCH] D146178: [Clang][Sema] Fix comparison of constraint expressions

2023-05-05 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/Sema/SemaTemplateInstantiate.cpp:133
 }
 
+Response HandlePartialClassTemplateSpec(

alexander-shaposhnikov wrote:
> alexander-shaposhnikov wrote:
> > alexander-shaposhnikov wrote:
> > > alexander-shaposhnikov wrote:
> > > > HandlePartialClassTemplateSpec is from Erich's diff 
> > > > (https://reviews.llvm.org/D147722)
> > > @erichkeane : previously (see https://reviews.llvm.org/D147722) we were 
> > > producing a real layer of arguments (if the depth is greater than 1), to 
> > > the best of my knowledge this is incorrect since it'd trigger unexpected 
> > > depth adjustment, we should produce retained layers instead.
> > (depth adjustment during the substitution)
> to make it a bit easier to reason about I've changed the names in the test 
> case:
> 
> ```
> //enum class Enum { E1 };
> 
> template 
> concept some_concept = true;
> //inline constexpr bool some_concept = true;
> 
> template 
> struct S {
>   template 
>   requires(some_concept)
>   void func(const T2 &);
> };
> 
> template 
> struct S {
>   template 
>   requires(some_concept)
>   void func(const T22 &);
> };
> 
> template 
> template 
> requires (some_concept)
> inline void S::func(const T222 &) {}
> ```
> 
> Previously the code was doing the following:
> ```
> PartialClassTemplSpec->getTemplateDepth() = 1
> NumRetainedOuterLevels: 0
> 0: <>
> before subst:
> ParenExpr 0x558fb90be6a8 '_Bool'
> `-ConceptSpecializationExpr 0x558fb90be640 '_Bool' Concept 0x558fb909fbd8 
> 'some_concept'
>   |-ImplicitConceptSpecializationDecl 0x558fb90be5d0 
>   | `-TemplateArgument type 'type-parameter-1-0'
>   |   `-TemplateTypeParmType 0x558fb90a01d0 'type-parameter-1-0' dependent 
> depth 1 index 0
>   `-TemplateArgument type 'T22'
> `-TemplateTypeParmType 0x558fb90be590 'T22' dependent depth 1 index 0
>   `-TemplateTypeParm 0x558fb90be540 'T22'
> after subst:
> ParenExpr 0x558fb90bf168 '_Bool'
> `-ConceptSpecializationExpr 0x558fb90bf100 '_Bool' Concept 0x558fb909fbd8 
> 'some_concept'
>   |-ImplicitConceptSpecializationDecl 0x558fb90bf090 
>   | `-TemplateArgument type 'type-parameter-0-0'
>   |   `-TemplateTypeParmType 0x558fb909fb50 'type-parameter-0-0' dependent 
> depth 0 index 0
>   `-TemplateArgument type 'T22'
> `-TemplateTypeParmType 0x558fb90bf050 'T22' dependent depth 0 index 0
>   `-TemplateTypeParm 0x558fb90be540 'T22'
> ```
> (as one can see the depths have changed)
> 
> now:
> ```
> PartialClassTemplSpec->getTemplateDepth() = 1
> NumRetainedOuterLevels: 1
> before subst:
> ParenExpr 0x55f7813ae6a8 '_Bool'
> `-ConceptSpecializationExpr 0x55f7813ae640 '_Bool' Concept 0x55f78138fbd8 
> 'some_concept'
>   |-ImplicitConceptSpecializationDecl 0x55f7813ae5d0 
>   | `-TemplateArgument type 'type-parameter-1-0'
>   |   `-TemplateTypeParmType 0x55f7813901d0 'type-parameter-1-0' dependent 
> depth 1 index 0
>   `-TemplateArgument type 'T22'
> `-TemplateTypeParmType 0x55f7813ae590 'T22' dependent depth 1 index 0
>   `-TemplateTypeParm 0x55f7813ae540 'T22'
> after subst:
> ParenExpr 0x55f7813af138 '_Bool'
> `-ConceptSpecializationExpr 0x55f7813af0d0 '_Bool' Concept 0x55f78138fbd8 
> 'some_concept'
>   |-ImplicitConceptSpecializationDecl 0x55f7813af060 
>   | `-TemplateArgument type 'type-parameter-1-0'
>   |   `-TemplateTypeParmType 0x55f7813901d0 'type-parameter-1-0' dependent 
> depth 1 index 0
>   `-TemplateArgument type 'T22'
> `-TemplateTypeParmType 0x55f7813ae590 'T22' dependent depth 1 index 0
>   `-TemplateTypeParm 0x55f7813ae540 'T22'
> ```
> 
> 
So the thought behind the 'empty' level was for a case where the 
`PartialClassTemplSpec` is defined inside of another type that actually DOES 
have arguments we need to compare.  Though, I guess for the purposes of 
substitution, it isn't really needed (since if we have a 
`PartialClassTemplSpec`, we can't fully instantiate ANYWAY)... and I can't 
think of a case where it totally matters anyway.  I think I'm OK with this as 
is, but I'm a touch suspicious.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146178

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


[PATCH] D146987: [Assignment Tracking] Enable by default

2023-05-05 Thread Orlando Cazalet-Hyams via Phabricator via cfe-commits
Orlando added a comment.

Thanks for the reproducer and report! I'll have a patch up for this shortly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146987

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


[PATCH] D146178: [Clang][Sema] Fix comparison of constraint expressions

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

I see this is closed... but I accept if you wish to re-commit this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146178

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


[PATCH] D149723: [clang-tidy] Optimize performance of RenamerClangTidyCheck

2023-05-05 Thread Nathan James via Phabricator via cfe-commits
njames93 accepted this revision.
njames93 added a comment.
This revision is now accepted and ready to land.

Mostly looks good, just a few small nits




Comment at: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp:47
 
-std::hash SecondHash;
-return DenseMapInfo::getHashValue(Val.first) +
-   SecondHash(Val.second);
+return hash_combine(
+DenseMapInfo::getHashValue(Val.first),

What's the purpose of using hash_combine instead of just adding the 2 hashes 
together, there is enough entropy in the hashes that a simple operation makes 
more sense?



Comment at: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp:201
 
-addUsage(Decl->getParent(), Decl->getNameInfo().getSourceRange(),
- Result.SourceManager);
+  bool shouldVisitTemplateInstantiations() const { return true; }
+

What is the reason for visiting template instantiations?



Comment at: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp:495
+  AggressiveDependentMemberLookup);
+  Visitor.TraverseDecl(const_cast(Decl));
 }

Instead of this nasty const cast, you can just use 
`Visitor.TraverseAST(*Result.Context);`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149723

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


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

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

return Diag


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149516

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp
  clang/test/CXX/temp/temp.res/temp.local/p3.cpp
  clang/test/Parser/cxx1z-class-template-argument-deduction.cpp
  clang/test/SemaCXX/invalid-deduction-guide-as-template-candidates.cpp

Index: clang/test/SemaCXX/invalid-deduction-guide-as-template-candidates.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/invalid-deduction-guide-as-template-candidates.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template  class Foo {}; // expected-note {{candidate template ignored: couldn't infer template argument 'T'}} \
+ // expected-note {{candidate function template not viable: requires 1 argument, but 0 were provided}}
+Foo(); // expected-error {{deduction guide declaration without trailing return type}}
+Foo vs; // expected-error {{no viable constructor or deduction guide for deduction of template arguments of 'Foo'}}
Index: clang/test/Parser/cxx1z-class-template-argument-deduction.cpp
===
--- clang/test/Parser/cxx1z-class-template-argument-deduction.cpp
+++ clang/test/Parser/cxx1z-class-template-argument-deduction.cpp
@@ -241,9 +241,8 @@
 };
 
 struct A2 {
-  template  // expected-note {{non-deducible template parameter 'Ty'}}
+  template 
   B() noexcept(false); // expected-error {{deduction guide must be declared in the same scope as template 'PR49735::B'}} \
-   // expected-error {{deduction guide template contains a template parameter that cannot be deduced}} \
// expected-error {{deduction guide declaration without trailing return type}}
 };
 
Index: clang/test/CXX/temp/temp.res/temp.local/p3.cpp
===
--- clang/test/CXX/temp/temp.res/temp.local/p3.cpp
+++ clang/test/CXX/temp/temp.res/temp.local/p3.cpp
@@ -28,8 +28,7 @@
 
 WebVector(const WebVector& other) { } // expected-error{{undeclared identifier 'T'}} \
 precxx17-error{{a type specifier is required}} \
-cxx17-error{{deduction guide declaration without trailing return type}} \
-cxx17-error{{deduction guide cannot have a function definition}}
+cxx17-error{{deduction guide declaration without trailing return type}}
 
   template 
   WebVector& operator=(const C& other) { } // expected-error{{undeclared identifier 'T'}}
Index: clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp
===
--- clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp
+++ clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp
@@ -173,10 +173,10 @@
 concept g = f::h;
 template 
 concept i = g;
-template  class j { // expected-note {{candidate template ignored}}
+template  class j {
   template 
   requires requires { requires i; }
-  j(); // expected-note {{candidate template ignored}}
+  j();
 };
-template <> j(); // expected-error {{deduction guide declaration without trailing return type}} // expected-error {{no function template}}
+template <> j(); // expected-error {{deduction guide declaration without trailing return type}}
 }
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -11087,8 +11087,8 @@
 /// Check the validity of a declarator that we parsed for a deduction-guide.
 /// These aren't actually declarators in the grammar, so we need to check that
 /// the user didn't specify any pieces that are not part of the deduction-guide
-/// grammar.
-void Sema::CheckDeductionGuideDeclarator(Declarator &D, QualType &R,
+/// grammar. Return true on error.
+bool Sema::CheckDeductionGuideDeclarator(Declarator &D, QualType &R,
  StorageClass &SC) {
   TemplateName GuidedTemplate = D.getName().TemplateName.get().get();
   TemplateDecl *GuidedTemplateDecl = GuidedTemplate.getAsTemplateDecl();
@@ -11138,7 +11138,7 @@
   }
 
   if (D.isInvalidType())
-return;
+return true;
 
   // Check the declarator is simple enough.
   bool FoundFunction = false;
@@ -11151,11 +11151,9 @@
   << D.getSourceRange();
   break;
 }
-if (!Chunk.Fun.hasTrailingReturnType()) {
-  Diag(D.getName().getBeginLoc(),
+if (

[PATCH] D141907: [CMake] Ensure `CLANG_RESOURCE_DIR` is respected

2023-05-05 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added inline comments.



Comment at: cmake/Modules/GetClangResourceDir.cmake:13
+  if(DEFINED CLANG_RESOURCE_DIR AND NOT CLANG_RESOURCE_DIR STREQUAL "")
+set(ret_dir bin/${CLANG_RESOURCE_DIR})
+  else()

tstellar wrote:
> tstellar wrote:
> > paperchalice wrote:
> > > tstellar wrote:
> > > > Why is the bin prefix here?
> > > See 
> > > https://clang.llvm.org/doxygen/classclang_1_1driver_1_1Driver.html#acda8dfdf4f80efa84df98157e1779152
> > > `GetResourcesPath` will return `/lib/` when 
> > > `CLANG_RESOURCE_DIR` is empty, `/bin/CLANG_RESOURCE_DIR` 
> > > otherwise.
> > > 
> > `GetResourcesPath` calls `sys::path::parent_path` twice on the path to the 
> > clang executable which is going to give you `/usr ` on most Linux systems, 
> > so it's returning `/CLANG_RESOURCE_DIR` not 
> > `/bin/CLANG_RESOURCE_DIR`.
> Sorry, you are correct.  I was looking at the wrong branch.  It's really 
> strange that it does that.
@paperchalice Can you update the description of the CLANG_RESOURCE_DIR cache 
variable in clang/CMakeLists.txt to mention that the path should be relative to 
the directory with the clang executable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141907

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


[PATCH] D146987: [Assignment Tracking] Enable by default

2023-05-05 Thread Orlando Cazalet-Hyams via Phabricator via cfe-commits
Orlando added a comment.

That should be fixed with D149959 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146987

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


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

2023-05-05 Thread Vy Nguyen via Phabricator via cfe-commits
oontvoo updated this revision to Diff 519849.
oontvoo added a comment.
Herald added a subscriber: MaskRay.

updated more clang test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144999

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/femit-dwarf-unwind.c
  clang/test/Driver/femit-dwarf-unwind.s
  clang/tools/driver/cc1as_main.cpp
  lld/MachO/UnwindInfoSection.cpp
  lld/test/MachO/Inputs/eh-frame-x86_64-r.o
  lld/test/MachO/compact-unwind-both-local-and-dylib-personality.s
  lld/test/MachO/compact-unwind-generated.test
  lld/test/MachO/compact-unwind-lsda-folding.s
  lld/test/MachO/compact-unwind-stack-ind.s
  lld/test/MachO/compact-unwind.s
  lld/test/MachO/eh-frame-personality-dedup.s
  lld/test/MachO/eh-frame.s
  lld/test/MachO/icf-only-lsda-folded.s
  lld/test/MachO/icf.s
  lld/test/MachO/invalid/compact-unwind-bad-reloc.s
  lld/test/MachO/invalid/compact-unwind-personalities.s
  llvm/include/llvm/MC/MCAsmBackend.h
  llvm/include/llvm/MC/MCContext.h
  llvm/include/llvm/MC/MCTargetOptions.h
  llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h
  llvm/lib/MC/MCAsmBackend.cpp
  llvm/lib/MC/MCContext.cpp
  llvm/lib/MC/MCStreamer.cpp
  llvm/lib/MC/MCTargetOptionsCommandFlags.cpp
  llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
  llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
  llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackendDarwin.h
  llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp

Index: llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
===
--- llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
+++ llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
@@ -1350,9 +1350,13 @@
 
   /// Implementation of algorithm to generate the compact unwind encoding
   /// for the CFI instructions.
-  uint32_t
-  generateCompactUnwindEncoding(ArrayRef Instrs) const override {
+  uint32_t generateCompactUnwindEncoding(const MCDwarfFrameInfo *FI,
+ const MCContext *Ctxt) const override {
+ArrayRef Instrs = FI->Instructions;
 if (Instrs.empty()) return 0;
+if (!isDarwinCanonicalPersonality(FI->Personality) &&
+!Ctxt->emitCompactUnwindNonCanonical())
+  return CU::UNWIND_MODE_DWARF;
 
 // Reset the saved registers.
 unsigned SavedRegIdx = 0;
Index: llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackendDarwin.h
===
--- llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackendDarwin.h
+++ llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackendDarwin.h
@@ -11,6 +11,7 @@
 
 #include "ARMAsmBackend.h"
 #include "llvm/BinaryFormat/MachO.h"
+#include "llvm/MC/MCContext.h"
 #include "llvm/MC/MCObjectWriter.h"
 
 namespace llvm {
@@ -32,8 +33,8 @@
 /*Is64Bit=*/false, cantFail(MachO::getCPUType(TT)), Subtype);
   }
 
-  uint32_t generateCompactUnwindEncoding(
-  ArrayRef Instrs) const override;
+  uint32_t generateCompactUnwindEncoding(const MCDwarfFrameInfo *FI,
+ const MCContext *Ctxt) const override;
 };
 } // end namespace llvm
 
Index: llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
===
--- llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
+++ llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
@@ -1108,14 +1108,19 @@
 /// encoded in compact unwind, the method returns UNWIND_ARM_MODE_DWARF which
 /// tells the runtime to fallback and unwind using dwarf.
 uint32_t ARMAsmBackendDarwin::generateCompactUnwindEncoding(
-ArrayRef Instrs) const {
+const MCDwarfFrameInfo *FI, const MCContext *Ctxt) const {
   DEBUG_WITH_TYPE("compact-unwind", llvm::dbgs() << "generateCU()\n");
   // Only armv7k uses CFI based unwinding.
   if (Subtype != MachO::CPU_SUBTYPE_ARM_V7K)
 return 0;
   // No .cfi directives means no frame.
+  ArrayRef Instrs = FI->Instructions;
   if (Instrs.empty())
 return 0;
+  if (!isDarwinCanonicalPersonality(FI->Personality) &&
+  !Ctxt->emitCompactUnwindNonCanonical())
+return CU::UNWIND_ARM_MODE_DWARF;
+
   // Start off assuming CFA is at SP+0.
   unsigned CFARegister = ARM::SP;
   int CFARegisterOffset = 0;
Index: llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
===
--- llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
+++ llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
@@ -564,10 +564,14 @@
   }
 
   /// Generate the compact unwind encoding from the CFI directives.
-  uint32_t generateCompactUnwindEncoding(
- ArrayRef Instrs) const override {
+  uint32_t generateCompactUnwindEncoding(const MCDwarfFrameInfo *FI,
+

[PATCH] D149904: Generic selection expressions that accept a type operand

2023-05-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 519850.
aaron.ballman marked an inline comment as done.
aaron.ballman added a comment.

Updated based on review feedback.


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

https://reviews.llvm.org/D149904

Files:
  clang/include/clang/AST/ASTNodeTraverser.h
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ComputeDependence.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/Analysis/ExprMutationAnalyzer.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseTentative.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprObjC.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaPseudoObject.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/Parser/generic-selection-type-extension-pedantic.c
  clang/test/Parser/generic-selection-type-extension.c
  clang/test/Sema/generic-selection-type-extension.c
  clang/test/SemaCXX/generic-selection.cpp

Index: clang/test/SemaCXX/generic-selection.cpp
===
--- clang/test/SemaCXX/generic-selection.cpp
+++ clang/test/SemaCXX/generic-selection.cpp
@@ -3,7 +3,7 @@
 template 
 struct A {
   enum {
-id = _Generic(T(), // expected-error {{controlling expression type 'char' not compatible with any generic association type}}
+id = _Generic(T{}, // expected-error {{controlling expression type 'char' not compatible with any generic association type}}
 int: 1, // expected-note {{compatible type 'int' specified here}}
 float: 2,
 U: 3) // expected-error {{type 'int' in generic association compatible with previously specified type 'int'}}
@@ -20,7 +20,7 @@
 template 
 struct B {
   enum {
-id = _Generic(T(),
+id = _Generic(T{},
 int: 1, // expected-note {{compatible type 'int' specified here}}
 int: 2, // expected-error {{type 'int' in generic association compatible with previously specified type 'int'}}
 U: 3)
@@ -37,7 +37,7 @@
 
 template  struct TypeMask {
   enum {
-   result = Or<_Generic(Args(), int: 1, long: 2, short: 4, float: 8)...>::result
+   result = Or<_Generic(Args{}, int: 1, long: 2, short: 4, float: 8)...>::result
   };
 };
 
Index: clang/test/Sema/generic-selection-type-extension.c
===
--- /dev/null
+++ clang/test/Sema/generic-selection-type-extension.c
@@ -0,0 +1,130 @@
+// RUN: %clang_cc1 -std=c2x -fsyntax-only -verify -Wno-unused %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-unused -x c++ %s
+
+// Test that the semantic behavior of the extension allowing the user to pass a
+// type as the first argument to _Generic.
+
+// Test that we match on basic types.
+static_assert(_Generic(int, int : 1, default : 0) == 1);
+static_assert(_Generic(_BitInt(12), int : 1, _BitInt(10) : 2, _BitInt(12) : 3) == 3);
+
+// Test that we correctly fall back to the default association appropriately.
+static_assert(_Generic(int, long : 1, default : 0) == 0);
+
+// Ensure we correctly match constant arrays by their extent.
+static_assert(_Generic(int[12], int[0] : 0, int * : 0, int[12] : 1, default : 0) == 1);
+
+// Ensure we correctly match function types by their signature.
+static_assert(_Generic(int(int), void(void) : 0, int(void) : 0, void(int) : 0, int(int) : 1, default : 0) == 1);
+
+// Test that we still diagnose when no associations match and that the
+// diagnostic includes qualifiers.
+static_assert(_Generic(const int, long : 1)); // expected-error {{controlling expression type 'const int' not compatible with any generic association type}}
+
+// Test that qualifiers work as expected and do not issue a diagnostic when
+// using the type form.
+static_assert(_Generic(const int, int : 0, const int : 1) == 1);
+static_assert(_Generic(int volatile _Atomic const, int : 0, const int : 0, volatile int : 0, _Atomic int : 0, _Atomic const volatile int : 1) == 1);
+
+// Test that inferred qualifiers also work as expected.
+const int ci = 0;
+static_assert(_Generic(__typeof__(ci), int : 0, const int : 1) == 1);
+// And that the expression form still complains about qualified associations
+// and matches the correct association.
+static_assert(_Generic(ci, int : 1, const int : 0) == 1); // expected-warning {{due to lvalue conversion of the controlling expression, association of type 'const int' will never be selected because it is qualified}}
+
+// The type operand form of _Generic allows incomplete and non-object types,
+// but the expression operand form still rejects them.
+static_assert(_Generic(struct incomplete, struct incomplete : 1, default : 0) == 1);
+static_assert(_Generic(struct another_incomplete, struct i

[PATCH] D149904: Generic selection expressions that accept a type operand

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

In D149904#4321144 , @cor3ntin wrote:

> I observe there is no documentation or release notes yet :)

Those are coming up, I wanted to see if the RFC made any substantive changes to 
the design before doing the documentation for the extension.




Comment at: clang/lib/Sema/SemaExpr.cpp:19851
+bool IsExpr = GSE->isExprPredicate();
+if (IsExpr)
+  ExOrTy = GSE->getControllingExpr();

aaron.ballman wrote:
> erichkeane wrote:
> > aaron.ballman wrote:
> > > erichkeane wrote:
> > > > I find myself wondering if a `getControllingOperand` here is valuable?
> > > This pattern only comes up once, so I don't think it's worth it, but it's 
> > > certainly easy enough to add if you disagree.
> > Yep, I think I agree, after seeing the rest of the review, I don't see as 
> > much value. 
> > 
> > On this re-read, I kind of which we instead had 2 separate 'create' 
> > functions here, rather than going through void*, so that this becomes:
> > 
> > ```
> > if (IsExpr)
> >   return AnyChanged ? S.CreateGenericSelectionExpr(, 
> > GSE->getControllingExpr(), ...) : ExprEmpty();
> > 
> >   return AnyChanged ? S.CreateGenericSelectionExpr(, 
> > GSE->getControllingType(), ...) : ExprEmpty();
> > ```
> > 
> > The `void*` version gives me the jeebies (and is perhaps a 'worse' 
> > interface?  Particularly for libclang folks?).
> That makes this one use better but at the expense of making that create 
> function rather awkward.
I took another run at this and decided to put a FIXME comment in the header 
file. I agree that the interface is a bit awkward, but it's also pretty hard to 
make work in `ActOnGenericSelectionExpr` due to it taking an `Expr *` or a 
`ParsedType` (currently it takes a `void *` of the parsed type's opaque value).


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

https://reviews.llvm.org/D149904

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


[clang] 30af2fb - [NFC][Clang] Remove release note since the patch was backported in time

2023-05-05 Thread Roy Jacobson via cfe-commits

Author: Roy Jacobson
Date: 2023-05-05T17:54:40+03:00
New Revision: 30af2fb33ed2f610abfa50e53df9712887b2bd25

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

LOG: [NFC][Clang] Remove release note since the patch was backported in time

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index e0ad5f5e3ae53..a41917a5ed66a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -58,8 +58,7 @@ C++ Specific Potentially Breaking Changes
 
 ABI Changes in This Version
 ---
-- ``__is_trivial`` has changed for a small category of classes with 
constrained default constructors (`#60697 
`_).
-  *FIXME: Remove this note if we've backported this change to the Clang 16 
branch.*
+
 
 What's New in Clang |release|?
 ==



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


[clang] 55e196e - [RISCV] Add sifive-x280 processor with all of its extensions

2023-05-05 Thread Michael Maitland via cfe-commits

Author: Michael Maitland
Date: 2023-05-05T07:55:07-07:00
New Revision: 55e196e7718c543b4492f2949c13de003a4ba443

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

LOG: [RISCV] Add sifive-x280 processor with all of its extensions

Add sifive-x280 processor that uses the SiFive7 scheduler model.

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

Added: 


Modified: 
clang/test/Driver/riscv-cpus.c
llvm/docs/ReleaseNotes.rst
llvm/lib/Target/RISCV/RISCVProcessors.td

Removed: 




diff  --git a/clang/test/Driver/riscv-cpus.c b/clang/test/Driver/riscv-cpus.c
index 76325311668d8..a484b07ce330a 100644
--- a/clang/test/Driver/riscv-cpus.c
+++ b/clang/test/Driver/riscv-cpus.c
@@ -167,6 +167,20 @@
 // MTUNE-E31-MCPU-E76-SAME: "-target-feature" "+zicsr" "-target-feature" 
"+zifencei"
 // MTUNE-E31-MCPU-E76-SAME: "-tune-cpu" "sifive-e76"
 
+// mcpu with default march include experimental extensions
+// RUN: %clang -target riscv64 -### -c %s 2>&1 
-menable-experimental-extensions -mcpu=sifive-x280 | FileCheck 
-check-prefix=MCPU-SIFIVE-X280 %s
+// MCPU-SIFIVE-X280: "-nostdsysteminc" "-target-cpu" "sifive-x280"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+m" "-target-feature" "+a" 
"-target-feature" "+f" "-target-feature" "+d"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+c" "-target-feature" "+v"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zicsr" "-target-feature" 
"+zifencei"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zfh"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zba" "-target-feature" "+zbb"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+experimental-zvfh"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zvl128b"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zvl256b" "-target-feature" 
"+zvl32b"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zvl512b" "-target-feature" 
"+zvl64b"
+// MCPU-SIFIVE-X280-SAME: "-target-abi" "lp64d"
+
 // Check failed cases
 
 // RUN: %clang --target=riscv32 -### -c %s 2>&1 -mcpu=generic-rv321 | 
FileCheck -check-prefix=FAIL-MCPU-NAME %s

diff  --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index c764a50f88b22..845cee9e75455 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -175,6 +175,7 @@ Changes to the RISC-V Backend
   ``RISCV::parseCPU``. The ``CPUKind`` enum is no longer part of the
   RISCVTargetParser.h interface. Similar for ``parseTuneCPUkind`` and
   ``checkTuneCPUKind``.
+* Add sifive-x280 processor.
 
 Changes to the WebAssembly Backend
 --

diff  --git a/llvm/lib/Target/RISCV/RISCVProcessors.td 
b/llvm/lib/Target/RISCV/RISCVProcessors.td
index 67b0364aa2fd7..69edacc4058c1 100644
--- a/llvm/lib/Target/RISCV/RISCVProcessors.td
+++ b/llvm/lib/Target/RISCV/RISCVProcessors.td
@@ -166,6 +166,22 @@ def SIFIVE_U74 : RISCVProcessorModel<"sifive-u74",
   FeatureStdExtC],
  [TuneSiFive7]>;
 
+def SIFIVE_X280 : RISCVProcessorModel<"sifive-x280", SiFive7Model,
+  [Feature64Bit,
+   FeatureStdExtZifencei,
+   FeatureStdExtM,
+   FeatureStdExtA,
+   FeatureStdExtF,
+   FeatureStdExtD,
+   FeatureStdExtC,
+   FeatureStdExtV,
+   FeatureStdExtZvl512b,
+   FeatureStdExtZfh,
+   FeatureStdExtZvfh,
+   FeatureStdExtZba,
+   FeatureStdExtZbb],
+  [TuneSiFive7]>;
+
 def SYNTACORE_SCR1_BASE : RISCVProcessorModel<"syntacore-scr1-base",
   SyntacoreSCR1Model,
   [Feature32Bit,



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


[PATCH] D149960: [clang][Interp] Fix ignoring String- and CharacterLiterals

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

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149960

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/test/AST/Interp/literals.cpp


Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -901,6 +901,8 @@
 (int[]){1,2,3};
 int arr[] = {1,2,3};
 arr[0];
+"a";
+'b';
 
 return 0;
   }
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -676,6 +676,8 @@
 
 template 
 bool ByteCodeExprGen::VisitStringLiteral(const StringLiteral *E) {
+  if (DiscardResult)
+return true;
   unsigned StringIndex = P.createGlobalString(E);
   return this->emitGetPtrGlobal(StringIndex, E);
 }
@@ -683,6 +685,8 @@
 template 
 bool ByteCodeExprGen::VisitCharacterLiteral(
 const CharacterLiteral *E) {
+  if (DiscardResult)
+return true;
   return this->emitConst(E->getValue(), E);
 }
 


Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -901,6 +901,8 @@
 (int[]){1,2,3};
 int arr[] = {1,2,3};
 arr[0];
+"a";
+'b';
 
 return 0;
   }
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -676,6 +676,8 @@
 
 template 
 bool ByteCodeExprGen::VisitStringLiteral(const StringLiteral *E) {
+  if (DiscardResult)
+return true;
   unsigned StringIndex = P.createGlobalString(E);
   return this->emitGetPtrGlobal(StringIndex, E);
 }
@@ -683,6 +685,8 @@
 template 
 bool ByteCodeExprGen::VisitCharacterLiteral(
 const CharacterLiteral *E) {
+  if (DiscardResult)
+return true;
   return this->emitConst(E->getValue(), E);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D149710: [RISCV] Add sifive-x280 processor with all of its extensions

2023-05-05 Thread Michael Maitland 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 rG55e196e7718c: [RISCV] Add sifive-x280 processor with all of 
its extensions (authored by michaelmaitland).

Changed prior to commit:
  https://reviews.llvm.org/D149710?vs=518922&id=519853#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149710

Files:
  clang/test/Driver/riscv-cpus.c
  llvm/docs/ReleaseNotes.rst
  llvm/lib/Target/RISCV/RISCVProcessors.td


Index: llvm/lib/Target/RISCV/RISCVProcessors.td
===
--- llvm/lib/Target/RISCV/RISCVProcessors.td
+++ llvm/lib/Target/RISCV/RISCVProcessors.td
@@ -166,6 +166,22 @@
   FeatureStdExtC],
  [TuneSiFive7]>;
 
+def SIFIVE_X280 : RISCVProcessorModel<"sifive-x280", SiFive7Model,
+  [Feature64Bit,
+   FeatureStdExtZifencei,
+   FeatureStdExtM,
+   FeatureStdExtA,
+   FeatureStdExtF,
+   FeatureStdExtD,
+   FeatureStdExtC,
+   FeatureStdExtV,
+   FeatureStdExtZvl512b,
+   FeatureStdExtZfh,
+   FeatureStdExtZvfh,
+   FeatureStdExtZba,
+   FeatureStdExtZbb],
+  [TuneSiFive7]>;
+
 def SYNTACORE_SCR1_BASE : RISCVProcessorModel<"syntacore-scr1-base",
   SyntacoreSCR1Model,
   [Feature32Bit,
Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -175,6 +175,7 @@
   ``RISCV::parseCPU``. The ``CPUKind`` enum is no longer part of the
   RISCVTargetParser.h interface. Similar for ``parseTuneCPUkind`` and
   ``checkTuneCPUKind``.
+* Add sifive-x280 processor.
 
 Changes to the WebAssembly Backend
 --
Index: clang/test/Driver/riscv-cpus.c
===
--- clang/test/Driver/riscv-cpus.c
+++ clang/test/Driver/riscv-cpus.c
@@ -167,6 +167,20 @@
 // MTUNE-E31-MCPU-E76-SAME: "-target-feature" "+zicsr" "-target-feature" 
"+zifencei"
 // MTUNE-E31-MCPU-E76-SAME: "-tune-cpu" "sifive-e76"
 
+// mcpu with default march include experimental extensions
+// RUN: %clang -target riscv64 -### -c %s 2>&1 
-menable-experimental-extensions -mcpu=sifive-x280 | FileCheck 
-check-prefix=MCPU-SIFIVE-X280 %s
+// MCPU-SIFIVE-X280: "-nostdsysteminc" "-target-cpu" "sifive-x280"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+m" "-target-feature" "+a" 
"-target-feature" "+f" "-target-feature" "+d"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+c" "-target-feature" "+v"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zicsr" "-target-feature" 
"+zifencei"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zfh"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zba" "-target-feature" "+zbb"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+experimental-zvfh"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zvl128b"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zvl256b" "-target-feature" 
"+zvl32b"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zvl512b" "-target-feature" 
"+zvl64b"
+// MCPU-SIFIVE-X280-SAME: "-target-abi" "lp64d"
+
 // Check failed cases
 
 // RUN: %clang --target=riscv32 -### -c %s 2>&1 -mcpu=generic-rv321 | 
FileCheck -check-prefix=FAIL-MCPU-NAME %s


Index: llvm/lib/Target/RISCV/RISCVProcessors.td
===
--- llvm/lib/Target/RISCV/RISCVProcessors.td
+++ llvm/lib/Target/RISCV/RISCVProcessors.td
@@ -166,6 +166,22 @@
   FeatureStdExtC],
  [TuneSiFive7]>;
 
+def SIFIVE_X280 : RISCVProcessorModel<"sifive-x280", SiFive7Model,
+  [Feature64Bit,
+   FeatureStdExtZifencei,
+   FeatureStdExtM,
+   FeatureStdExtA,
+   FeatureStdExtF,
+   FeatureStdExtD,
+   FeatureStdExtC,
+   FeatureStdExtV,
+   FeatureStdExtZvl512b,
+   FeatureStdExtZfh,
+   FeatureStdE

[PATCH] D149497: [RISCV] Add scheduling information for Zba and Zbb to RISCVSchedSiFive7.td

2023-05-05 Thread Michael Maitland via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcd02b69e75dd: [RISCV] Add scheduling information for Zba and 
Zbb to RISCVSchedSiFive7.td (authored by michaelmaitland).

Changed prior to commit:
  https://reviews.llvm.org/D149497?vs=518924&id=519854#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149497

Files:
  llvm/lib/Target/RISCV/RISCVSchedSiFive7.td

Index: llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
===
--- llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
+++ llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
@@ -76,6 +76,35 @@
   let ResourceCycles = [1, 15];
 }
 
+// Bitmanip
+let Latency = 3 in {
+// Rotates are in the late-B ALU.
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+
+// clz[w]/ctz[w] are in the late-B ALU.
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+
+// cpop[w] look exactly like multiply.
+def : WriteRes;
+def : WriteRes;
+
+// orc.b is in the late-B ALU.
+def : WriteRes;
+
+// rev8 is in the late-A and late-B ALUs.
+def : WriteRes;
+
+// shNadd[.uw] is on the early-B and late-B ALUs.
+def : WriteRes;
+def : WriteRes;
+}
+
 // Memory
 def : WriteRes;
 def : WriteRes;
@@ -230,11 +259,188 @@
 
 def : ReadAdvance;
 
+// 6. Configuration-Setting Instructions
+def : ReadAdvance;
+def : ReadAdvance;
+
+// 7. Vector Loads and Stores
+def : ReadAdvance;
+def : ReadAdvance;
+defm "" : LMULReadAdvance<"ReadVSTEV", 0>;
+defm "" : LMULReadAdvance<"ReadVSTM", 0>;
+def : ReadAdvance;
+def : ReadAdvance;
+defm "" : LMULReadAdvance<"ReadVSTS8V", 0>;
+defm "" : LMULReadAdvance<"ReadVSTS16V", 0>;
+defm "" : LMULReadAdvance<"ReadVSTS32V", 0>;
+defm "" : LMULReadAdvance<"ReadVSTS64V", 0>;
+defm "" : LMULReadAdvance<"ReadVLDUXV", 0>;
+defm "" : LMULReadAdvance<"ReadVLDOXV", 0>;
+defm "" : LMULReadAdvance<"ReadVSTUX8", 0>;
+defm "" : LMULReadAdvance<"ReadVSTUX16", 0>;
+defm "" : LMULReadAdvance<"ReadVSTUX32", 0>;
+defm "" : LMULReadAdvance<"ReadVSTUX64", 0>;
+defm "" : LMULReadAdvance<"ReadVSTUXV", 0>;
+defm "" : LMULReadAdvance<"ReadVSTUX8V", 0>;
+defm "" : LMULReadAdvance<"ReadVSTUX16V", 0>;
+defm "" : LMULReadAdvance<"ReadVSTUX32V", 0>;
+defm "" : LMULReadAdvance<"ReadVSTUX64V", 0>;
+defm "" : LMULReadAdvance<"ReadVSTOX8", 0>;
+defm "" : LMULReadAdvance<"ReadVSTOX16", 0>;
+defm "" : LMULReadAdvance<"ReadVSTOX32", 0>;
+defm "" : LMULReadAdvance<"ReadVSTOX64", 0>;
+defm "" : LMULReadAdvance<"ReadVSTOXV", 0>;
+defm "" : LMULReadAdvance<"ReadVSTOX8V", 0>;
+defm "" : LMULReadAdvance<"ReadVSTOX16V", 0>;
+defm "" : LMULReadAdvance<"ReadVSTOX32V", 0>;
+defm "" : LMULReadAdvance<"ReadVSTOX64V", 0>;
+// LMUL Aware
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+
+// 12. Vector Integer Arithmetic Instructions
+defm : LMULReadAdvance<"ReadVIALUV", 0>;
+defm : LMULReadAdvance<"ReadVIALUX", 0>;
+defm : LMULReadAdvanceW<"ReadVIWALUV", 0>;
+defm : LMULReadAdvanceW<"ReadVIWALUX", 0>;
+defm : LMULReadAdvance<"ReadVExtV", 0>;
+defm : LMULReadAdvance<"ReadVICALUV", 0>;
+defm : LMULReadAdvance<"ReadVICALUX", 0>;
+defm : LMULReadAdvance<"ReadVShiftV", 0>;
+defm : LMULReadAdvance<"ReadVShiftX", 0>;
+defm : LMULReadAdvanceW<"ReadVNShiftV", 0>;
+defm : LMULReadAdvanceW<"ReadVNShiftX", 0>;
+defm : LMULReadAdvance<"ReadVICmpV", 0>;
+defm : LMULReadAdvance<"ReadVICmpX", 0>;
+defm : LMULReadAdvance<"ReadVIMulV", 0>;
+defm : LMULReadAdvance<"ReadVIMulX", 0>;
+defm : LMULSEWReadAdvance<"ReadVIDivV", 0>;
+defm : LMULSEWReadAdvance<"ReadVIDivX", 0>;
+defm : LMULReadAdvanceW<"ReadVIWMulV", 0>;
+defm : LMULReadAdvanceW<"ReadVIWMulX", 0>;
+defm : LMULReadAdvance<"ReadVIMulAddV", 0>;
+defm : LMULReadAdvance<"ReadVIMulAddX", 0>;
+defm : LMULReadAdvanceW<"ReadVIWMulAddV", 0>;
+defm : LMULReadAdvanceW<"ReadVIWMulAddX", 0>;
+defm : LMULReadAdvance<"ReadVIMergeV", 0>;
+defm : LMULReadAdvance<"ReadVIMergeX", 0>;
+defm : LMULReadAdvance<"ReadVIMovV", 0>;
+defm : LMULReadAdvance<"ReadVIMovX", 0>;
+
+// 13. Vector Fixed-Point Arithmetic Instructions
+defm "" : LMULReadAdvance<"ReadVSALUV", 0>;
+defm "" : LMULReadAdvance<"ReadVSALUX", 0>;
+defm "" : LMULReadAdvance<"ReadVAALUV", 0>;
+defm "" : LMULReadAdvance<"ReadVAALUX", 0>;
+defm "" : LMULReadAdvance<"ReadVSMulV", 0>;
+defm "" : LMULReadAdvance<"ReadVSMulX", 0>;
+defm "" : LMULReadAdvance<"ReadVSShiftV", 0>;
+defm "" : LMULReadAdvance<"ReadVSShiftX", 0>;
+defm "" : LMULReadAdvanceW<"ReadVNClipV", 0>;
+defm "" : LMULReadAdvanceW<"ReadVNClipX", 0>;
+
+// 14. Vector Floating-Point Instructions
+defm "" : LMULReadAdvance<"ReadVFALUV", 0>;
+defm "" : LMULReadAdvance<"ReadVFALUF", 0>;
+defm "" : LMULReadAdvanceFW<"ReadVFWALUV", 0>;
+defm "" : LMULReadAdvanceFW<"ReadVFWALUF", 0>;
+defm "" : LMULReadAdvance<"ReadVFMulV", 0>;
+defm "" : LMULReadAdvance<"ReadVFMulF", 0>;
+defm "" : LMULSEWReadAdvanceF<"ReadVFDivV", 0>;
+defm "" : LMULSEWReadAdvanc

[PATCH] D149498: [RISCV] Add Scheduling information for Zfh to SiFive7 model

2023-05-05 Thread Michael Maitland via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb77d6f51ba4e: [RISCV] Add Scheduling information for Zfh to 
SiFive7 model (authored by michaelmaitland).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149498

Files:
  llvm/lib/Target/RISCV/RISCVSchedSiFive7.td

Index: llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
===
--- llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
+++ llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
@@ -110,6 +110,7 @@
 def : WriteRes;
 def : WriteRes;
 def : WriteRes;
+def : WriteRes;
 def : WriteRes;
 def : WriteRes;
 
@@ -121,6 +122,7 @@
 }
 
 let Latency = 2 in {
+def : WriteRes;
 def : WriteRes;
 def : WriteRes;
 }
@@ -136,6 +138,22 @@
 def : WriteRes;
 }
 
+// Half precision.
+let Latency = 5 in {
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+}
+let Latency = 3 in {
+def : WriteRes;
+def : WriteRes;
+}
+
+let Latency = 14, ResourceCycles = [1, 13] in {
+def :  WriteRes;
+def :  WriteRes;
+}
+
 // Single precision.
 let Latency = 5 in {
 def : WriteRes;
@@ -170,21 +188,33 @@
 
 // Conversions
 let Latency = 3 in {
+def : WriteRes;
 def : WriteRes;
 def : WriteRes;
+def : WriteRes;
 def : WriteRes;
 def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
 def : WriteRes;
 def : WriteRes;
+def : WriteRes;
 def : WriteRes;
 def : WriteRes;
 def : WriteRes;
+def : WriteRes;
 def : WriteRes;
 
+def : WriteRes;
 def : WriteRes;
 def : WriteRes;
+def : WriteRes;
 def : WriteRes;
 def : WriteRes;
+def : WriteRes;
+def : WriteRes;
 def : WriteRes;
 def : WriteRes;
 def : WriteRes;
@@ -224,36 +254,55 @@
 def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
+def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
+def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
+def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
+def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
+def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
+def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
+def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
+def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
+def : ReadAdvance;
 def : ReadAdvance;
 def : ReadAdvance;
 
@@ -446,5 +495,4 @@
 defm : UnsupportedSchedZbkb;
 defm : UnsupportedSchedZbkx;
 defm : UnsupportedSchedZfa;
-defm : UnsupportedSchedZfh;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D149961: [Sema] Mark ineligibility of special member functions correctly

2023-05-05 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson created this revision.
royjacobson added reviewers: shafik, erichkeane.
Herald added a project: All.
royjacobson requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

I checked if the member function declaration was a copy constructor, but it's 
not sufficient; We need to check
the arguments against the instantiated class.

Fixed https://github.com/llvm/llvm-project/issues/62555


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149961

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/SemaCXX/constrained-special-member-functions.cpp


Index: clang/test/SemaCXX/constrained-special-member-functions.cpp
===
--- clang/test/SemaCXX/constrained-special-member-functions.cpp
+++ clang/test/SemaCXX/constrained-special-member-functions.cpp
@@ -299,3 +299,16 @@
 static_assert(!__is_trivial(S));
 
 }
+
+namespace GH62555 {
+
+template 
+struct ExplicitTemplateArgs {
+ExplicitTemplateArgs(ExplicitTemplateArgs&&) = default;
+ExplicitTemplateArgs(ExplicitTemplateArgs&&) requires B {};
+};
+
+static_assert(__is_trivially_copyable(ExplicitTemplateArgs));
+static_assert(__is_trivially_copyable(ExplicitTemplateArgs));
+
+}
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -2523,9 +2523,6 @@
 Constructor->getConstexprKind(), InheritedConstructor(),
 TrailingRequiresClause);
 Method->setRangeEnd(Constructor->getEndLoc());
-if (Constructor->isDefaultConstructor() ||
-Constructor->isCopyOrMoveConstructor())
-  Method->setIneligibleOrNotSelected(true);
   } else if (CXXDestructorDecl *Destructor = dyn_cast(D)) {
 Method = CXXDestructorDecl::Create(
 SemaRef.Context, Record, StartLoc, NameInfo, T, TInfo,
@@ -2548,8 +2545,6 @@
 SemaRef.Context, Record, StartLoc, NameInfo, T, TInfo, SC,
 D->UsesFPIntrin(), D->isInlineSpecified(), D->getConstexprKind(),
 D->getEndLoc(), TrailingRequiresClause);
-if (D->isMoveAssignmentOperator() || D->isCopyAssignmentOperator())
-  Method->setIneligibleOrNotSelected(true);
   }
 
   if (D->isInlined())
@@ -2752,6 +2747,15 @@
   if (IsExplicitSpecialization && !isFriend)
 SemaRef.CompleteMemberSpecialization(Method, Previous);
 
+  if (auto *Constructor = dyn_cast(Method)) {
+if (Constructor->isDefaultConstructor() ||
+Constructor->isCopyOrMoveConstructor())
+  Method->setIneligibleOrNotSelected(true);
+  } else if (Method->isCopyAssignmentOperator() ||
+ Method->isMoveAssignmentOperator()) {
+Method->setIneligibleOrNotSelected(true);
+  }
+
   // If there's a function template, let our caller handle it.
   if (FunctionTemplate) {
 // do nothing
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -58,7 +58,8 @@
 
 ABI Changes in This Version
 ---
-
+- A bug in evaluating the ineligibility of some special member functions has 
been fixed. This can
+  make some classes trivially copyable that were not trivially copyable 
before. (`#62555 `_)
 
 What's New in Clang |release|?
 ==


Index: clang/test/SemaCXX/constrained-special-member-functions.cpp
===
--- clang/test/SemaCXX/constrained-special-member-functions.cpp
+++ clang/test/SemaCXX/constrained-special-member-functions.cpp
@@ -299,3 +299,16 @@
 static_assert(!__is_trivial(S));
 
 }
+
+namespace GH62555 {
+
+template 
+struct ExplicitTemplateArgs {
+ExplicitTemplateArgs(ExplicitTemplateArgs&&) = default;
+ExplicitTemplateArgs(ExplicitTemplateArgs&&) requires B {};
+};
+
+static_assert(__is_trivially_copyable(ExplicitTemplateArgs));
+static_assert(__is_trivially_copyable(ExplicitTemplateArgs));
+
+}
Index: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -2523,9 +2523,6 @@
 Constructor->getConstexprKind(), InheritedConstructor(),
 TrailingRequiresClause);
 Method->setRangeEnd(Constructor->getEndLoc());
-if (Constructor->isDefaultConstructor() ||
-Constructor->isCopyOrMoveConstructor())
-  Method->setIneligibleOrNotSelected(true);
   } else if (CXXDestructorDecl *Destructor = dyn_cast(D)) {
 Method = CXXDestructorDecl::Create(
 SemaRef.Context, Record, StartLoc, NameInfo, T, TInfo,
@@ -2548,8 +2545,6 @@
 SemaRef.Context, Record, StartLoc, NameInfo, T, T

[PATCH] D149922: Fix nullptr dereference found by Coverity static analysis tool

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

In D149922#4321972 , @erichkeane 
wrote:

> Looks like both ABIs that use this assume the parameter passed to 
> `getMemberPointerInfo` is non-null.  While we DO check the type (in reality, 
> we probably should be doing a `if (const auto *MPT = 
> Ty->getAs())` instead, I think this is a problem that at 
> least SHOULD be fixed somehow.
>
> Why was this abandoned?

@erichkeane, Sorry i abandoned the patch without any comment. My change (use 
castAs instead of getAs) was not correct.

>> Looks like both ABIs that use this assume the parameter passed to 
>> `getMemberPointerInfo` is non-null.  While we DO check the type (in reality, 
>> we probably should be doing a `if (const auto *MPT = 
>> Ty->getAs())` instead

Agreed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149922

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


[PATCH] D149922: Fix nullptr dereference found by Coverity static analysis tool

2023-05-05 Thread Soumi Manna via Phabricator via cfe-commits
Manna updated this revision to Diff 519859.
Manna added a comment.

I have updated patch


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

https://reviews.llvm.org/D149922

Files:
  clang/lib/AST/ASTContext.cpp


Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2859,8 +2859,7 @@
   if (Ty->isPointerType())
 return true;
 
-  if (Ty->isMemberPointerType()) {
-const auto *MPT = Ty->getAs();
+  if (const auto *MPT = Ty->getAs()) {
 return !ABI->getMemberPointerInfo(MPT).HasPadding;
   }
 


Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2859,8 +2859,7 @@
   if (Ty->isPointerType())
 return true;
 
-  if (Ty->isMemberPointerType()) {
-const auto *MPT = Ty->getAs();
+  if (const auto *MPT = Ty->getAs()) {
 return !ABI->getMemberPointerInfo(MPT).HasPadding;
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D149904: Generic selection expressions that accept a type operand

2023-05-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 519861.
aaron.ballman added a comment.

Added a feature test macro, documentation, and a release note.


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

https://reviews.llvm.org/D149904

Files:
  clang/docs/LanguageExtensions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ASTNodeTraverser.h
  clang/include/clang/AST/Expr.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/Features.def
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ComputeDependence.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/Analysis/ExprMutationAnalyzer.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseTentative.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprObjC.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaPseudoObject.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/Lexer/has_extension.c
  clang/test/Parser/generic-selection-type-extension-pedantic.c
  clang/test/Parser/generic-selection-type-extension.c
  clang/test/Sema/generic-selection-type-extension.c
  clang/test/SemaCXX/generic-selection.cpp

Index: clang/test/SemaCXX/generic-selection.cpp
===
--- clang/test/SemaCXX/generic-selection.cpp
+++ clang/test/SemaCXX/generic-selection.cpp
@@ -3,7 +3,7 @@
 template 
 struct A {
   enum {
-id = _Generic(T(), // expected-error {{controlling expression type 'char' not compatible with any generic association type}}
+id = _Generic(T{}, // expected-error {{controlling expression type 'char' not compatible with any generic association type}}
 int: 1, // expected-note {{compatible type 'int' specified here}}
 float: 2,
 U: 3) // expected-error {{type 'int' in generic association compatible with previously specified type 'int'}}
@@ -20,7 +20,7 @@
 template 
 struct B {
   enum {
-id = _Generic(T(),
+id = _Generic(T{},
 int: 1, // expected-note {{compatible type 'int' specified here}}
 int: 2, // expected-error {{type 'int' in generic association compatible with previously specified type 'int'}}
 U: 3)
@@ -37,7 +37,7 @@
 
 template  struct TypeMask {
   enum {
-   result = Or<_Generic(Args(), int: 1, long: 2, short: 4, float: 8)...>::result
+   result = Or<_Generic(Args{}, int: 1, long: 2, short: 4, float: 8)...>::result
   };
 };
 
Index: clang/test/Sema/generic-selection-type-extension.c
===
--- /dev/null
+++ clang/test/Sema/generic-selection-type-extension.c
@@ -0,0 +1,130 @@
+// RUN: %clang_cc1 -std=c2x -fsyntax-only -verify -Wno-unused %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-unused -x c++ %s
+
+// Test that the semantic behavior of the extension allowing the user to pass a
+// type as the first argument to _Generic.
+
+// Test that we match on basic types.
+static_assert(_Generic(int, int : 1, default : 0) == 1);
+static_assert(_Generic(_BitInt(12), int : 1, _BitInt(10) : 2, _BitInt(12) : 3) == 3);
+
+// Test that we correctly fall back to the default association appropriately.
+static_assert(_Generic(int, long : 1, default : 0) == 0);
+
+// Ensure we correctly match constant arrays by their extent.
+static_assert(_Generic(int[12], int[0] : 0, int * : 0, int[12] : 1, default : 0) == 1);
+
+// Ensure we correctly match function types by their signature.
+static_assert(_Generic(int(int), void(void) : 0, int(void) : 0, void(int) : 0, int(int) : 1, default : 0) == 1);
+
+// Test that we still diagnose when no associations match and that the
+// diagnostic includes qualifiers.
+static_assert(_Generic(const int, long : 1)); // expected-error {{controlling expression type 'const int' not compatible with any generic association type}}
+
+// Test that qualifiers work as expected and do not issue a diagnostic when
+// using the type form.
+static_assert(_Generic(const int, int : 0, const int : 1) == 1);
+static_assert(_Generic(int volatile _Atomic const, int : 0, const int : 0, volatile int : 0, _Atomic int : 0, _Atomic const volatile int : 1) == 1);
+
+// Test that inferred qualifiers also work as expected.
+const int ci = 0;
+static_assert(_Generic(__typeof__(ci), int : 0, const int : 1) == 1);
+// And that the expression form still complains about qualified associations
+// and matches the correct association.
+static_assert(_Generic(ci, int : 1, const int : 0) == 1); // expected-warning {{due to lvalue conversion of the controlling expression, association of type 'const int' will never be selected because it is qualified}}
+
+// The type operand form of _Generic allows incomplete and non-object types,
+// but the expression operand form still rejects them.
+static_assert(_Generi

[PATCH] D149922: Fix nullptr dereference found by Coverity static analysis tool

2023-05-05 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:2862
 
-  if (Ty->isMemberPointerType()) {
-const auto *MPT = Ty->getAs();
+  if (const auto *MPT = Ty->getAs()) {
 return !ABI->getMemberPointerInfo(MPT).HasPadding;

Remove the curley braces, otherwise LGTM.


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

https://reviews.llvm.org/D149922

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


[PATCH] D149965: [clang][Interp] Fix tests for ignored expressions

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

  We didn't call the function explicitly in a static_assert() statement
  and the checkPotentialConstantExpression() invocation quietly aborted
  early because of the missing initializer for A::a.
  
  Fix this by calling ignoredExprs() explicitly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149965

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/test/AST/Interp/literals.cpp


Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -886,7 +886,7 @@
   struct A{ int a; };
   constexpr int ignoredExprs() {
 (void)(1 / 2);
-A a;
+A a{12};
 a;
 (void)a;
 (a);
@@ -906,6 +906,7 @@
 
 return 0;
   }
+  static_assert(ignoredExprs() == 0, "");
 
   /// Ignored comma expressions still have their
   /// expressions evaluated.
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -200,6 +200,8 @@
   case CK_NoOp:
   case CK_UserDefinedConversion:
   case CK_BitCast:
+if (DiscardResult)
+  return this->discard(SubExpr);
 return this->visit(SubExpr);
 
   case CK_IntegralToBoolean:
@@ -573,6 +575,8 @@
 template 
 bool ByteCodeExprGen::VisitUnaryExprOrTypeTraitExpr(
 const UnaryExprOrTypeTraitExpr *E) {
+  if (DiscardResult)
+return true;
   UnaryExprOrTypeTrait Kind = E->getKind();
   ASTContext &ASTCtx = Ctx.getASTContext();
 


Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -886,7 +886,7 @@
   struct A{ int a; };
   constexpr int ignoredExprs() {
 (void)(1 / 2);
-A a;
+A a{12};
 a;
 (void)a;
 (a);
@@ -906,6 +906,7 @@
 
 return 0;
   }
+  static_assert(ignoredExprs() == 0, "");
 
   /// Ignored comma expressions still have their
   /// expressions evaluated.
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -200,6 +200,8 @@
   case CK_NoOp:
   case CK_UserDefinedConversion:
   case CK_BitCast:
+if (DiscardResult)
+  return this->discard(SubExpr);
 return this->visit(SubExpr);
 
   case CK_IntegralToBoolean:
@@ -573,6 +575,8 @@
 template 
 bool ByteCodeExprGen::VisitUnaryExprOrTypeTraitExpr(
 const UnaryExprOrTypeTraitExpr *E) {
+  if (DiscardResult)
+return true;
   UnaryExprOrTypeTrait Kind = E->getKind();
   ASTContext &ASTCtx = Ctx.getASTContext();
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D149922: Fix nullptr dereference found by Coverity static analysis tool

2023-05-05 Thread Soumi Manna via Phabricator via cfe-commits
Manna updated this revision to Diff 519868.
Manna marked an inline comment as done.

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

https://reviews.llvm.org/D149922

Files:
  clang/lib/AST/ASTContext.cpp


Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2859,10 +2859,8 @@
   if (Ty->isPointerType())
 return true;
 
-  if (Ty->isMemberPointerType()) {
-const auto *MPT = Ty->getAs();
+  if (const auto *MPT = Ty->getAs())
 return !ABI->getMemberPointerInfo(MPT).HasPadding;
-  }
 
   if (Ty->isRecordType()) {
 const RecordDecl *Record = Ty->castAs()->getDecl();


Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2859,10 +2859,8 @@
   if (Ty->isPointerType())
 return true;
 
-  if (Ty->isMemberPointerType()) {
-const auto *MPT = Ty->getAs();
+  if (const auto *MPT = Ty->getAs())
 return !ABI->getMemberPointerInfo(MPT).HasPadding;
-  }
 
   if (Ty->isRecordType()) {
 const RecordDecl *Record = Ty->castAs()->getDecl();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D149922: Fix nullptr dereference found by Coverity static analysis tool

2023-05-05 Thread Soumi Manna via Phabricator via cfe-commits
Manna added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:2862
 
-  if (Ty->isMemberPointerType()) {
-const auto *MPT = Ty->getAs();
+  if (const auto *MPT = Ty->getAs()) {
 return !ABI->getMemberPointerInfo(MPT).HasPadding;

erichkeane wrote:
> Remove the curley braces, otherwise LGTM.
Missed that. Done


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

https://reviews.llvm.org/D149922

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


[PATCH] D149579: [X86][MC] Fix parsing Intel syntax indirect branch with symbol only

2023-05-05 Thread Alvin Wong via Phabricator via cfe-commits
alvinhochun updated this revision to Diff 519869.
alvinhochun edited the summary of this revision.
alvinhochun added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Rebase and add test cases with `offset` operator, and some TODOs/FIXMEs for 
comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149579

Files:
  clang/test/CodeGen/ms-inline-asm-functions.c
  llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
  llvm/test/MC/X86/intel-syntax-branch-fail.s
  llvm/test/MC/X86/intel-syntax-branch.s

Index: llvm/test/MC/X86/intel-syntax-branch.s
===
--- /dev/null
+++ llvm/test/MC/X86/intel-syntax-branch.s
@@ -0,0 +1,69 @@
+// RUN: llvm-mc -triple i686-unknown-unknown -x86-asm-syntax=intel %s | FileCheck %s --check-prefixes=CHECK-32,CHECK
+// RUN: llvm-mc -triple x86_64-unknown-unknown --defsym X64=1 -x86-asm-syntax=intel %s | FileCheck %s --check-prefixes=CHECK-64,CHECK
+
+t0:
+call direct_branch
+jmp direct_branch
+// CHECK-LABEL: t0:
+// CHECK-64: callq direct_branch
+// CHECK-32: calll direct_branch
+// CHECK:jmp direct_branch
+
+t1:
+call [fn_ref]
+jmp [fn_ref]
+// CHECK-LABEL: t1:
+// CHECK-64: callq *fn_ref
+// CHECK-64: jmpq *fn_ref
+// CHECK-32: calll *fn_ref
+// CHECK-32: jmpl *fn_ref
+
+.ifdef X64
+
+  t2:
+  call qword ptr [fn_ref]
+  jmp qword ptr [fn_ref]
+  // CHECK-64-LABEL: t2:
+  // CHECK-64: callq *fn_ref
+  // CHECK-64: jmpq *fn_ref
+
+  t3:
+  call qword ptr [rip + fn_ref]
+  jmp qword ptr [rip + fn_ref]
+  // CHECK-64-LABEL: t3:
+  // CHECK-64: callq *fn_ref(%rip)
+  // CHECK-64: jmpq *fn_ref(%rip)
+
+.else
+
+  t4:
+  call dword ptr [fn_ref]
+  jmp dword ptr [fn_ref]
+  // CHECK-32-LABEL: t4:
+  // CHECK-32: calll *fn_ref
+  // CHECK-32: jmpl *fn_ref
+
+  t5:
+  call dword ptr fn_ref
+  jmp dword ptr fn_ref
+  // CHECK-32-LABEL: t5:
+  // CHECK-32: calll *fn_ref
+  // CHECK-32: jmpl *fn_ref
+
+  t6:
+  call dword ptr [offset fn_ref]
+  jmp dword ptr [offset fn_ref]
+  // CHECK-32-LABEL: t6:
+  // CHECK-32: calll *fn_ref
+  // CHECK-32: jmpl *fn_ref
+
+  t7:
+  // FIXME: MASM does not accept this syntax and GAS assembles this as a direct
+  //call/jump instead of indirect. Consider making this syntax an error?
+  call [offset fn_ref]
+  jmp [offset fn_ref]
+  // CHECK-32-LABEL: t7:
+  // CHECK-32: calll *fn_ref
+  // CHECK-32: jmpl *fn_ref
+
+.endif
Index: llvm/test/MC/X86/intel-syntax-branch-fail.s
===
--- /dev/null
+++ llvm/test/MC/X86/intel-syntax-branch-fail.s
@@ -0,0 +1,12 @@
+// RUN: not llvm-mc -triple i686-unknown-unknown -x86-asm-syntax=intel %s 2>&1 | FileCheck %s
+
+// TODO: Consider making this syntax an error?
+// call [offset fn_ref]
+// // TODO-CHECK: {{.*}}intel-syntax-branch-fail.s:[[#@LINE+-1]]:1: error: `OFFSET` operator cannot be used in an unconditional branch
+// jmp [offset fn_ref]
+// // TODO-CHECK: {{.*}}intel-syntax-branch-fail.s:[[#@LINE+-1]]:1: error: `OFFSET` operator cannot be used in an unconditional branch
+
+call offset fn_ref
+// CHECK: {{.*}}intel-syntax-branch-fail.s:[[#@LINE+-1]]:1: error: invalid operand for instruction
+jmp offset fn_ref
+// CHECK: {{.*}}intel-syntax-branch-fail.s:[[#@LINE+-1]]:1: error: invalid operand for instruction
Index: llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
===
--- llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -432,6 +432,7 @@
 InlineAsmIdentifierInfo Info;
 short BracCount = 0;
 bool MemExpr = false;
+bool BracketUsed = false;
 bool OffsetOperator = false;
 bool AttachToOperandIdx = false;
 bool IsPIC = false;
@@ -454,6 +455,7 @@
 void addImm(int64_t imm) { Imm += imm; }
 short getBracCount() const { return BracCount; }
 bool isMemExpr() const { return MemExpr; }
+bool isBracketUsed() const { return BracketUsed; }
 bool isOffsetOperator() const { return OffsetOperator; }
 SMLoc getOffsetLoc() const { return OffsetOperatorLoc; }
 unsigned getBaseReg() const { return BaseReg; }
@@ -954,6 +956,7 @@
 break;
   }
   MemExpr = true;
+  BracketUsed = true;
   BracCount++;
   return false;
 }
@@ -2630,9 +2633,9 @@
   unsigned DefaultBaseReg = X86::NoRegister;
   bool MaybeDirectBranchDest = true;
 
+  bool IsUnconditionalBranch =
+  Name.equals_insensitive("jmp") || Name.equals_insensitive("call");
   if (Parser.isParsingMasm()) {
-bool IsUnconditionalBranch =
-Name.equals_insensitive("jmp") || Name.equals_insensitive("call");
 if (is64BitMode() && SM.getElementSize() > 0) {
   DefaultBaseReg = X86::RIP;
 }
@@ -2654,6 +2657,14 @@
 }
   }
 }
+  } else if (IsUnconditionalBranch) {
+// TODO: Consider making the `call [offset fn_

[PATCH] D149579: [X86][MC] Fix parsing Intel syntax indirect branch with symbol only

2023-05-05 Thread Alvin Wong via Phabricator via cfe-commits
alvinhochun marked an inline comment as not done.
alvinhochun added a comment.

In D149579#4320765 , @MaskRay wrote:

> OK. I  think after D149695  (landed), 
> D149920 , and this patch D149579 
> , these cases should be correct.

Thank you so much for looking into this!

I have one question in inline comment.




Comment at: llvm/test/MC/X86/intel-syntax-branch.s:61-67
+  // FIXME: MASM does not accept this syntax and GAS assembles this as a direct
+  //call/jump instead of indirect. Consider making this syntax an 
error?
+  call [offset fn_ref]
+  jmp [offset fn_ref]
+  // CHECK-32-LABEL: t7:
+  // CHECK-32: calll *fn_ref
+  // CHECK-32: jmpl *fn_ref

About the `call [offset fn_ref]` case, do you think we should reject it since 
MASM does not accept this syntax and GAS appears to behave oddly with it? The 
`ms-inline-asm-functions.c` test does generate `call [offset _kptr]` so this 
will also need to be changed.



Comment at: llvm/test/MC/X86/intel-syntax-branch.s:48
+  call dword ptr fn_ref
+  jmp dword ptr fn_ref
+  // CHECK-32-LABEL: t5:

MaskRay wrote:
> ICC and MSVC parse this differently.
> 
> Is this syntax valid?
MASM ml.exe assembles this as `jmp dword ptr [fn_ref]` in my test, so does GAS. 
I don't know how valid this syntax is though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149579

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


[PATCH] D149710: [RISCV] Add sifive-x280 processor with all of its extensions

2023-05-05 Thread Michael Maitland via Phabricator via cfe-commits
michaelmaitland added a comment.

I had to revert this commit because it failed tests that did not fail during 
build through phabricator nor local check-all.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149710

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


[PATCH] D149922: Fix nullptr dereference found by Coverity static analysis tool

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

Thanks @erichkeane for reviews!


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

https://reviews.llvm.org/D149922

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


[clang] d6bd4ea - Revert "[RISCV] Add sifive-x280 processor with all of its extensions"

2023-05-05 Thread Michael Maitland via cfe-commits

Author: Michael Maitland
Date: 2023-05-05T08:20:18-07:00
New Revision: d6bd4ea35437b1d39933e9526779e8c6e03125e0

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

LOG: Revert "[RISCV] Add sifive-x280 processor with all of its extensions"

This commit causes tests to fail.

This reverts commit 55e196e7718c543b4492f2949c13de003a4ba443.

Added: 


Modified: 
clang/test/Driver/riscv-cpus.c
llvm/docs/ReleaseNotes.rst
llvm/lib/Target/RISCV/RISCVProcessors.td

Removed: 




diff  --git a/clang/test/Driver/riscv-cpus.c b/clang/test/Driver/riscv-cpus.c
index a484b07ce330a..76325311668d8 100644
--- a/clang/test/Driver/riscv-cpus.c
+++ b/clang/test/Driver/riscv-cpus.c
@@ -167,20 +167,6 @@
 // MTUNE-E31-MCPU-E76-SAME: "-target-feature" "+zicsr" "-target-feature" 
"+zifencei"
 // MTUNE-E31-MCPU-E76-SAME: "-tune-cpu" "sifive-e76"
 
-// mcpu with default march include experimental extensions
-// RUN: %clang -target riscv64 -### -c %s 2>&1 
-menable-experimental-extensions -mcpu=sifive-x280 | FileCheck 
-check-prefix=MCPU-SIFIVE-X280 %s
-// MCPU-SIFIVE-X280: "-nostdsysteminc" "-target-cpu" "sifive-x280"
-// MCPU-SIFIVE-X280-SAME: "-target-feature" "+m" "-target-feature" "+a" 
"-target-feature" "+f" "-target-feature" "+d"
-// MCPU-SIFIVE-X280-SAME: "-target-feature" "+c" "-target-feature" "+v"
-// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zicsr" "-target-feature" 
"+zifencei"
-// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zfh"
-// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zba" "-target-feature" "+zbb"
-// MCPU-SIFIVE-X280-SAME: "-target-feature" "+experimental-zvfh"
-// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zvl128b"
-// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zvl256b" "-target-feature" 
"+zvl32b"
-// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zvl512b" "-target-feature" 
"+zvl64b"
-// MCPU-SIFIVE-X280-SAME: "-target-abi" "lp64d"
-
 // Check failed cases
 
 // RUN: %clang --target=riscv32 -### -c %s 2>&1 -mcpu=generic-rv321 | 
FileCheck -check-prefix=FAIL-MCPU-NAME %s

diff  --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index 845cee9e75455..c764a50f88b22 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -175,7 +175,6 @@ Changes to the RISC-V Backend
   ``RISCV::parseCPU``. The ``CPUKind`` enum is no longer part of the
   RISCVTargetParser.h interface. Similar for ``parseTuneCPUkind`` and
   ``checkTuneCPUKind``.
-* Add sifive-x280 processor.
 
 Changes to the WebAssembly Backend
 --

diff  --git a/llvm/lib/Target/RISCV/RISCVProcessors.td 
b/llvm/lib/Target/RISCV/RISCVProcessors.td
index 69edacc4058c1..67b0364aa2fd7 100644
--- a/llvm/lib/Target/RISCV/RISCVProcessors.td
+++ b/llvm/lib/Target/RISCV/RISCVProcessors.td
@@ -166,22 +166,6 @@ def SIFIVE_U74 : RISCVProcessorModel<"sifive-u74",
   FeatureStdExtC],
  [TuneSiFive7]>;
 
-def SIFIVE_X280 : RISCVProcessorModel<"sifive-x280", SiFive7Model,
-  [Feature64Bit,
-   FeatureStdExtZifencei,
-   FeatureStdExtM,
-   FeatureStdExtA,
-   FeatureStdExtF,
-   FeatureStdExtD,
-   FeatureStdExtC,
-   FeatureStdExtV,
-   FeatureStdExtZvl512b,
-   FeatureStdExtZfh,
-   FeatureStdExtZvfh,
-   FeatureStdExtZba,
-   FeatureStdExtZbb],
-  [TuneSiFive7]>;
-
 def SYNTACORE_SCR1_BASE : RISCVProcessorModel<"syntacore-scr1-base",
   SyntacoreSCR1Model,
   [Feature32Bit,



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


[PATCH] D148689: [clang][Interp] Handle PredefinedExprs

2023-05-05 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 a caution about testing the mangled signature (you can fix that up 
when landing though).




Comment at: clang/test/AST/Interp/literals.cpp:848
+  void foo() {
+static_assert(strings_match(__FUNCDNAME__, "_ZN15PredefinedExprs3fooEv"), 
"");
+static_assert(strings_match(__FUNCSIG__, "void __cdecl 
PredefinedExprs::foo(void)"), "");

I suspect this will pass for you on one ABI but fail on another due to mangling 
differences. You might need to specify an ABI on the RUN lines to account for 
that.


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

https://reviews.llvm.org/D148689

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


[PATCH] D149776: Re-land "[AMDGPU] Define data layout entries for buffers""

2023-05-05 Thread Jay Foad via Phabricator via cfe-commits
foad added a comment.

Hi, with the new datalayout we're hitting this crash:

  ; RUN: opt -passes=indvars -S < %s
  
  target datalayout = 
"e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8"
  target triple = "amdgcn--amdpal"
  
  define void @f(ptr addrspace(7) %arg) {
  bb:
br label %bb1
  bb1:
%i = getelementptr i32, ptr addrspace(7) %arg, i32 2
br i1 false, label %bb2, label %bb1
  bb2:
br label %bb3
  bb3:
%i4 = load i32, ptr addrspace(7) %i, align 4
br label %bb3
  }

  PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ 
and include the crash backtrace.
  Stack dump:
  0.Program arguments: /home/jayfoad2/llvm-release/bin/opt -passes=indvars 
-S
   #0 0x063a25e7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
(/home/jayfoad2/llvm-release/bin/opt+0x63a25e7)
   #1 0x063a049e llvm::sys::RunSignalHandlers() 
(/home/jayfoad2/llvm-release/bin/opt+0x63a049e)
   #2 0x063a2c8a SignalHandler(int) Signals.cpp:0:0
   #3 0x7fdb0be42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
   #4 0x05b0b80f llvm::EVT::isExtendedVector() const 
(/home/jayfoad2/llvm-release/bin/opt+0x5b0b80f)
   #5 0x05a59bf9 
llvm::TargetLoweringBase::getTypeConversion(llvm::LLVMContext&, llvm::EVT) 
const (/home/jayfoad2/llvm-release/bin/opt+0x5a59bf9)
   #6 0x0423cf63 
llvm::BasicTTIImplBase::getTypeLegalizationCost(llvm::Type*) 
const AMDGPUTargetMachine.cpp:0:0
   #7 0x04305117 llvm::GCNTTIImpl::getArithmeticInstrCost(unsigned int, 
llvm::Type*, llvm::TargetTransformInfo::TargetCostKind, 
llvm::TargetTransformInfo::OperandValueInfo, 
llvm::TargetTransformInfo::OperandValueInfo, llvm::ArrayRef, llvm::Instruction const*) AMDGPUTargetTransformInfo.cpp:0:0
   #8 0x05549453 
llvm::TargetTransformInfo::getArithmeticInstrCost(unsigned int, llvm::Type*, 
llvm::TargetTransformInfo::TargetCostKind, 
llvm::TargetTransformInfo::OperandValueInfo, 
llvm::TargetTransformInfo::OperandValueInfo, llvm::ArrayRef, llvm::Instruction const*) const 
(/home/jayfoad2/llvm-release/bin/opt+0x5549453)
   #9 0x064b5695 
llvm::SCEVExpander::isHighCostExpansionHelper(llvm::SCEVOperand const&, 
llvm::Loop*, llvm::Instruction const&, llvm::InstructionCost&, unsigned int, 
llvm::TargetTransformInfo const&, llvm::SmallPtrSetImpl&, 
llvm::SmallVectorImpl&) 
(/home/jayfoad2/llvm-release/bin/opt+0x64b5695)
  #10 0x06475d2b 
llvm::SCEVExpander::isHighCostExpansion(llvm::ArrayRef, 
llvm::Loop*, unsigned int, llvm::TargetTransformInfo const*, llvm::Instruction 
const*) LoopUnrollRuntime.cpp:0:0
  #11 0x064813ab llvm::rewriteLoopExitValues(llvm::Loop*, 
llvm::LoopInfo*, llvm::TargetLibraryInfo*, llvm::ScalarEvolution*, 
llvm::TargetTransformInfo const*, llvm::SCEVExpander&, llvm::DominatorTree*, 
llvm::ReplaceExitVal, llvm::SmallVector&) 
(/home/jayfoad2/llvm-release/bin/opt+0x64813ab)
  #12 0x06a71b09 (anonymous 
namespace)::IndVarSimplify::run(llvm::Loop*) IndVarSimplify.cpp:0:0
  #13 0x06a7 llvm::IndVarSimplifyPass::run(llvm::Loop&, 
llvm::AnalysisManager&, 
llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) 
(/home/jayfoad2/llvm-release/bin/opt+0x6a7)
  #14 0x065bef0d llvm::detail::PassModel, 
llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::run(llvm::Loop&, 
llvm::AnalysisManager&, 
llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) PassBuilder.cpp:0:0
  #15 0x0679b933 std::optional 
llvm::PassManager, llvm::LoopStandardAnalysisResults&, 
llvm::LPMUpdater&>::runSinglePass, 
llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>, 
std::default_delete, 
llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&(llvm::Loop&, 
std::unique_ptr, 
llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>, 
std::default_delete, 
llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>>>&, 
llvm::AnalysisManager&, 
llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&, 
llvm::PassInstrumentation&) (/home/jayfoad2/llvm-release/bin/opt+0x679b933)
  #16 0x0679b5a2 llvm::PassManager, 
llvm::LoopStandardAnalysisResults&, 
llvm::LPMUpdater&>::runWithoutLoopNestPasses(llvm::Loop&, 
llvm::AnalysisManager&, 
llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) 
(/home/jayfoad2/llvm-release/bin/opt+0x679b5a2)
  #17 0x0679ab88 llvm::PassManager, 
llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&>::run(llvm::Loop&, 
llvm::AnalysisManager&, 
llvm::LoopStandardAnalysisResults&, llvm::LPMUpdater&) 
(/home/jayfoad2/llvm-release/bin/opt+0x679ab88)
  #18 0x0659ddbd llvm::detail::PassModel, llvm::LoopStandardAnalysisResults&, 
llvm::LPMUpdater&>, llvm::PreservedAnalyses, llvm::AnalysisManager, llvm::LoopStandardAnalysisResults&, 
llvm::LPMUpdater&>::run(llvm::Loop&, llvm::AnalysisManager&, llvm::LoopStandardAnalysisResults&

[PATCH] D149961: [Sema] Mark ineligibility of special member functions correctly

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

Thank you for fixing this so quickly!




Comment at: clang/lib/Sema/SemaTemplateInstantiateDecl.cpp:2750
 
+  if (auto *Constructor = dyn_cast(Method)) {
+if (Constructor->isDefaultConstructor() ||

I have look at this function a few times and it is not obvious to me why this 
is the right thing to do once we get to this point, Can you add some 
explanatory comments and maybe a standard reference. This is a large function 
and probably could use a lot more explanatory comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149961

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


[clang] a11dfd0 - [RISCV] Add sifive-x280 processor with all of its extensions

2023-05-05 Thread Michael Maitland via cfe-commits

Author: Michael Maitland
Date: 2023-05-05T08:47:57-07:00
New Revision: a11dfd0fe6b1c38495f7de9858a2d1839d2902b9

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

LOG: [RISCV] Add sifive-x280 processor with all of its extensions

Add sifive-x280 processor that uses the SiFive7 scheduler model.

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

Added: 


Modified: 
clang/test/Driver/riscv-cpus.c
clang/test/Misc/target-invalid-cpu-note.c
llvm/docs/ReleaseNotes.rst
llvm/lib/Target/RISCV/RISCVProcessors.td

Removed: 




diff  --git a/clang/test/Driver/riscv-cpus.c b/clang/test/Driver/riscv-cpus.c
index 76325311668d8..a484b07ce330a 100644
--- a/clang/test/Driver/riscv-cpus.c
+++ b/clang/test/Driver/riscv-cpus.c
@@ -167,6 +167,20 @@
 // MTUNE-E31-MCPU-E76-SAME: "-target-feature" "+zicsr" "-target-feature" 
"+zifencei"
 // MTUNE-E31-MCPU-E76-SAME: "-tune-cpu" "sifive-e76"
 
+// mcpu with default march include experimental extensions
+// RUN: %clang -target riscv64 -### -c %s 2>&1 
-menable-experimental-extensions -mcpu=sifive-x280 | FileCheck 
-check-prefix=MCPU-SIFIVE-X280 %s
+// MCPU-SIFIVE-X280: "-nostdsysteminc" "-target-cpu" "sifive-x280"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+m" "-target-feature" "+a" 
"-target-feature" "+f" "-target-feature" "+d"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+c" "-target-feature" "+v"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zicsr" "-target-feature" 
"+zifencei"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zfh"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zba" "-target-feature" "+zbb"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+experimental-zvfh"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zvl128b"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zvl256b" "-target-feature" 
"+zvl32b"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zvl512b" "-target-feature" 
"+zvl64b"
+// MCPU-SIFIVE-X280-SAME: "-target-abi" "lp64d"
+
 // Check failed cases
 
 // RUN: %clang --target=riscv32 -### -c %s 2>&1 -mcpu=generic-rv321 | 
FileCheck -check-prefix=FAIL-MCPU-NAME %s

diff  --git a/clang/test/Misc/target-invalid-cpu-note.c 
b/clang/test/Misc/target-invalid-cpu-note.c
index 1f205163a966e..ba43ba50accd9 100644
--- a/clang/test/Misc/target-invalid-cpu-note.c
+++ b/clang/test/Misc/target-invalid-cpu-note.c
@@ -85,7 +85,7 @@
 
 // RUN: not %clang_cc1 -triple riscv64 -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix RISCV64
 // RISCV64: error: unknown target CPU 'not-a-cpu'
-// RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, 
sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, sifive-u74{{$}}
+// RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, 
sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, sifive-u74{{$}}, 
sifive-x280
 
 // RUN: not %clang_cc1 -triple riscv32 -tune-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix TUNE-RISCV32
 // TUNE-RISCV32: error: unknown target CPU 'not-a-cpu'
@@ -93,4 +93,4 @@
 
 // RUN: not %clang_cc1 -triple riscv64 -tune-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix TUNE-RISCV64
 // TUNE-RISCV64: error: unknown target CPU 'not-a-cpu'
-// TUNE-RISCV64-NEXT: note: valid target CPU values are: generic-rv64, 
rocket-rv64, sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, 
sifive-u74, generic, rocket, sifive-7-series{{$}}
+// TUNE-RISCV64-NEXT: note: valid target CPU values are: generic-rv64, 
rocket-rv64, sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, 
sifive-u74, sifive-x280, generic, rocket, sifive-7-series{{$}}

diff  --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index c764a50f88b22..845cee9e75455 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -175,6 +175,7 @@ Changes to the RISC-V Backend
   ``RISCV::parseCPU``. The ``CPUKind`` enum is no longer part of the
   RISCVTargetParser.h interface. Similar for ``parseTuneCPUkind`` and
   ``checkTuneCPUKind``.
+* Add sifive-x280 processor.
 
 Changes to the WebAssembly Backend
 --

diff  --git a/llvm/lib/Target/RISCV/RISCVProcessors.td 
b/llvm/lib/Target/RISCV/RISCVProcessors.td
index 67b0364aa2fd7..69edacc4058c1 100644
--- a/llvm/lib/Target/RISCV/RISCVProcessors.td
+++ b/llvm/lib/Target/RISCV/RISCVProcessors.td
@@ -166,6 +166,22 @@ def SIFIVE_U74 : RISCVProcessorModel<"sifive-u74",
   FeatureStdExtC],
  [TuneSiFive7]>;
 
+def SIFIVE_X280 : RISCVProcessorModel<"sifive-x280", SiFive7Model,
+  [Feature64Bit,
+   FeatureStdExtZifencei,
+   Feat

[PATCH] D149917: [lld][WebAssembly] Add --preserve-features flag

2023-05-05 Thread Derek Schuff via Phabricator via cfe-commits
dschuff added a comment.

Do we want to make this any more general? In the future we might want to 
preserve other sections, e.g. passing optimization or profiling info from LLVM 
to Binaryen. Or maybe JSPI info?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149917

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


[clang] 6e7ca68 - Revert "[RISCV] Add sifive-x280 processor with all of its extensions"

2023-05-05 Thread Michael Maitland via cfe-commits

Author: Michael Maitland
Date: 2023-05-05T09:03:06-07:00
New Revision: 6e7ca6839def260e57334040a586934011f0098d

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

LOG: Revert "[RISCV] Add sifive-x280 processor with all of its extensions"

Test still not working...

This reverts commit a11dfd0fe6b1c38495f7de9858a2d1839d2902b9.

Added: 


Modified: 
clang/test/Driver/riscv-cpus.c
clang/test/Misc/target-invalid-cpu-note.c
llvm/docs/ReleaseNotes.rst
llvm/lib/Target/RISCV/RISCVProcessors.td

Removed: 




diff  --git a/clang/test/Driver/riscv-cpus.c b/clang/test/Driver/riscv-cpus.c
index a484b07ce330a..76325311668d8 100644
--- a/clang/test/Driver/riscv-cpus.c
+++ b/clang/test/Driver/riscv-cpus.c
@@ -167,20 +167,6 @@
 // MTUNE-E31-MCPU-E76-SAME: "-target-feature" "+zicsr" "-target-feature" 
"+zifencei"
 // MTUNE-E31-MCPU-E76-SAME: "-tune-cpu" "sifive-e76"
 
-// mcpu with default march include experimental extensions
-// RUN: %clang -target riscv64 -### -c %s 2>&1 
-menable-experimental-extensions -mcpu=sifive-x280 | FileCheck 
-check-prefix=MCPU-SIFIVE-X280 %s
-// MCPU-SIFIVE-X280: "-nostdsysteminc" "-target-cpu" "sifive-x280"
-// MCPU-SIFIVE-X280-SAME: "-target-feature" "+m" "-target-feature" "+a" 
"-target-feature" "+f" "-target-feature" "+d"
-// MCPU-SIFIVE-X280-SAME: "-target-feature" "+c" "-target-feature" "+v"
-// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zicsr" "-target-feature" 
"+zifencei"
-// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zfh"
-// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zba" "-target-feature" "+zbb"
-// MCPU-SIFIVE-X280-SAME: "-target-feature" "+experimental-zvfh"
-// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zvl128b"
-// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zvl256b" "-target-feature" 
"+zvl32b"
-// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zvl512b" "-target-feature" 
"+zvl64b"
-// MCPU-SIFIVE-X280-SAME: "-target-abi" "lp64d"
-
 // Check failed cases
 
 // RUN: %clang --target=riscv32 -### -c %s 2>&1 -mcpu=generic-rv321 | 
FileCheck -check-prefix=FAIL-MCPU-NAME %s

diff  --git a/clang/test/Misc/target-invalid-cpu-note.c 
b/clang/test/Misc/target-invalid-cpu-note.c
index ba43ba50accd9..1f205163a966e 100644
--- a/clang/test/Misc/target-invalid-cpu-note.c
+++ b/clang/test/Misc/target-invalid-cpu-note.c
@@ -85,7 +85,7 @@
 
 // RUN: not %clang_cc1 -triple riscv64 -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix RISCV64
 // RISCV64: error: unknown target CPU 'not-a-cpu'
-// RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, 
sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, sifive-u74{{$}}, 
sifive-x280
+// RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, 
sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, sifive-u74{{$}}
 
 // RUN: not %clang_cc1 -triple riscv32 -tune-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix TUNE-RISCV32
 // TUNE-RISCV32: error: unknown target CPU 'not-a-cpu'
@@ -93,4 +93,4 @@
 
 // RUN: not %clang_cc1 -triple riscv64 -tune-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix TUNE-RISCV64
 // TUNE-RISCV64: error: unknown target CPU 'not-a-cpu'
-// TUNE-RISCV64-NEXT: note: valid target CPU values are: generic-rv64, 
rocket-rv64, sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, 
sifive-u74, sifive-x280, generic, rocket, sifive-7-series{{$}}
+// TUNE-RISCV64-NEXT: note: valid target CPU values are: generic-rv64, 
rocket-rv64, sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, 
sifive-u74, generic, rocket, sifive-7-series{{$}}

diff  --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index 845cee9e75455..c764a50f88b22 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -175,7 +175,6 @@ Changes to the RISC-V Backend
   ``RISCV::parseCPU``. The ``CPUKind`` enum is no longer part of the
   RISCVTargetParser.h interface. Similar for ``parseTuneCPUkind`` and
   ``checkTuneCPUKind``.
-* Add sifive-x280 processor.
 
 Changes to the WebAssembly Backend
 --

diff  --git a/llvm/lib/Target/RISCV/RISCVProcessors.td 
b/llvm/lib/Target/RISCV/RISCVProcessors.td
index 69edacc4058c1..67b0364aa2fd7 100644
--- a/llvm/lib/Target/RISCV/RISCVProcessors.td
+++ b/llvm/lib/Target/RISCV/RISCVProcessors.td
@@ -166,22 +166,6 @@ def SIFIVE_U74 : RISCVProcessorModel<"sifive-u74",
   FeatureStdExtC],
  [TuneSiFive7]>;
 
-def SIFIVE_X280 : RISCVProcessorModel<"sifive-x280", SiFive7Model,
-  [Feature64Bit,
-   FeatureStdExtZifencei,
-   FeatureStdExtM,
-   

[PATCH] D147875: [clang][Diagnostics] Show line numbers when printing code snippets

2023-05-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Frontend/TextDiagnostic.cpp:1121-1138
+static unsigned getNumDisplayWidth(unsigned N) {
+  if (N < 10)
+return 1;
+  if (N < 100)
+return 2;
+  if (N < 1'000)
+return 3;

jrtc27 wrote:
> kwk wrote:
> > This function screamed at me to be generalized so I gave it a try: 
> > https://gist.github.com/kwk/7e408065ea291e49fea4a83cf90a9cdf
> I don't think I want floating point arithmetic in my compiler... Something 
> like:
> 
> ```
> unsigned L, M;
> for (L = 1U, M = 10U; N >= M && M != ~0U; ++L)
> M = (M > ((~0U) / 10U)) ? (~0U) : (M * 10U);
> 
> return (L);
> ```
> 
> is the generalised form (without all the redundant parentheses I added during 
> debugging).
Cleaned up a bit:
```
constexpr unsigned getNumDisplayWidth(unsigned N) {
  unsigned L = 1U, M = 10U;
  constexpr unsigned Upper = ~0U / 10U;
  for (; N >= M && M != ~0U; ++L)
M = M > Upper ? ~0U : M * 10U;
  return L;
}
```
https://godbolt.org/z/szTYsEM4v



Comment at: clang/test/FixIt/fixit-function-call.cpp:1
-// RUN: not %clang_cc1 -fdiagnostics-parseable-fixits -x c++ %s 2> %t
+// RUN: not %clang_cc1 -fdiagnostics-parseable-fixits 
-fno-diagnostics-show-line-numbers -fcaret-diagnostics-max-lines 1 -x c++ %s 2> 
%t
 // RUN: FileCheck %s < %t

tbaeder wrote:
> aaron.ballman wrote:
> > Just to double-check, parseable diagnostic output still works even if line 
> > numbers are shown, yes?
> Yes, at leat we don't prepend the line numbers to the parseable fixits:
> ```
>21 | // CHECK-NEXT: fix-it{{.*}})
>22 | // CHECK: void f1(double *a);
>23 |   f1(a + 1);
>   |  ~
>   |  *(   )
> fix-it:"../clang/test/FixIt/fixit-function-call.cpp":{23:6-23:6}:"*("
> fix-it:"../clang/test/FixIt/fixit-function-call.cpp":{23:11-23:11}:")"
> ```
Excellent, thank you!


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

https://reviews.llvm.org/D147875

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


[PATCH] D146764: [clang] Make predefined expressions string literals under -fms-extensions

2023-05-05 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.

Presuming that the issues found by precommit CI were resolved (current failures 
are unrelated to your changes), this LGTM but still needs a release note.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146764

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


[PATCH] D148689: [clang][Interp] Handle PredefinedExprs

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

LGTM


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

https://reviews.llvm.org/D148689

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


[PATCH] D149867: [M68k] Add Clang support for the new M68k_RTD CC

2023-05-05 Thread Min-Yih Hsu via Phabricator via cfe-commits
myhsu added inline comments.



Comment at: clang/test/CodeGen/mrtd.c:9
+// X86: define{{.*}} x86_stdcallcc void @foo(i32 noundef %arg) [[NUW:#[0-9]+]]
+// M68k: define{{.*}} cc104 void @foo(i32 noundef %arg)
 void foo(int arg) {

0x59616e wrote:
> 0x59616e wrote:
> > Just curious, why do we have to use such an arcane name instead of a more 
> > lucid one , such as `m68k_rtdcc`.
> I guess this involves more work ?
> I guess this involves more work ?

Yes because it requires changes to (LLVM IR's) AsmReader/Writer. But it's not 
hard and I can do that. The reason I didn't do that was simply because this CC 
is rare so the arcane name's impact on (our) productivity will be low.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149867

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


[clang] 8394694 - [RISCV] Add sifive-x280 processor with all of its extensions

2023-05-05 Thread Michael Maitland via cfe-commits

Author: Michael Maitland
Date: 2023-05-05T10:02:28-07:00
New Revision: 839469436afcbdf5bb6dc9b081b1bcf3a1b22fea

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

LOG: [RISCV] Add sifive-x280 processor with all of its extensions

Add sifive-x280 processor that uses the SiFive7 scheduler model.

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

Added: 


Modified: 
clang/test/Driver/riscv-cpus.c
clang/test/Misc/target-invalid-cpu-note.c
llvm/docs/ReleaseNotes.rst
llvm/lib/Target/RISCV/RISCVProcessors.td

Removed: 




diff  --git a/clang/test/Driver/riscv-cpus.c b/clang/test/Driver/riscv-cpus.c
index 76325311668d8..a484b07ce330a 100644
--- a/clang/test/Driver/riscv-cpus.c
+++ b/clang/test/Driver/riscv-cpus.c
@@ -167,6 +167,20 @@
 // MTUNE-E31-MCPU-E76-SAME: "-target-feature" "+zicsr" "-target-feature" 
"+zifencei"
 // MTUNE-E31-MCPU-E76-SAME: "-tune-cpu" "sifive-e76"
 
+// mcpu with default march include experimental extensions
+// RUN: %clang -target riscv64 -### -c %s 2>&1 
-menable-experimental-extensions -mcpu=sifive-x280 | FileCheck 
-check-prefix=MCPU-SIFIVE-X280 %s
+// MCPU-SIFIVE-X280: "-nostdsysteminc" "-target-cpu" "sifive-x280"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+m" "-target-feature" "+a" 
"-target-feature" "+f" "-target-feature" "+d"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+c" "-target-feature" "+v"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zicsr" "-target-feature" 
"+zifencei"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zfh"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zba" "-target-feature" "+zbb"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+experimental-zvfh"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zvl128b"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zvl256b" "-target-feature" 
"+zvl32b"
+// MCPU-SIFIVE-X280-SAME: "-target-feature" "+zvl512b" "-target-feature" 
"+zvl64b"
+// MCPU-SIFIVE-X280-SAME: "-target-abi" "lp64d"
+
 // Check failed cases
 
 // RUN: %clang --target=riscv32 -### -c %s 2>&1 -mcpu=generic-rv321 | 
FileCheck -check-prefix=FAIL-MCPU-NAME %s

diff  --git a/clang/test/Misc/target-invalid-cpu-note.c 
b/clang/test/Misc/target-invalid-cpu-note.c
index 1f205163a966e..ddc639dc60a80 100644
--- a/clang/test/Misc/target-invalid-cpu-note.c
+++ b/clang/test/Misc/target-invalid-cpu-note.c
@@ -85,7 +85,7 @@
 
 // RUN: not %clang_cc1 -triple riscv64 -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix RISCV64
 // RISCV64: error: unknown target CPU 'not-a-cpu'
-// RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, 
sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, sifive-u74{{$}}
+// RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, 
sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, sifive-u74, 
sifive-x280{{$}}
 
 // RUN: not %clang_cc1 -triple riscv32 -tune-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix TUNE-RISCV32
 // TUNE-RISCV32: error: unknown target CPU 'not-a-cpu'
@@ -93,4 +93,4 @@
 
 // RUN: not %clang_cc1 -triple riscv64 -tune-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix TUNE-RISCV64
 // TUNE-RISCV64: error: unknown target CPU 'not-a-cpu'
-// TUNE-RISCV64-NEXT: note: valid target CPU values are: generic-rv64, 
rocket-rv64, sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, 
sifive-u74, generic, rocket, sifive-7-series{{$}}
+// TUNE-RISCV64-NEXT: note: valid target CPU values are: generic-rv64, 
rocket-rv64, sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, 
sifive-u74, sifive-x280, generic, rocket, sifive-7-series{{$}}

diff  --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index c764a50f88b22..845cee9e75455 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -175,6 +175,7 @@ Changes to the RISC-V Backend
   ``RISCV::parseCPU``. The ``CPUKind`` enum is no longer part of the
   RISCVTargetParser.h interface. Similar for ``parseTuneCPUkind`` and
   ``checkTuneCPUKind``.
+* Add sifive-x280 processor.
 
 Changes to the WebAssembly Backend
 --

diff  --git a/llvm/lib/Target/RISCV/RISCVProcessors.td 
b/llvm/lib/Target/RISCV/RISCVProcessors.td
index 67b0364aa2fd7..69edacc4058c1 100644
--- a/llvm/lib/Target/RISCV/RISCVProcessors.td
+++ b/llvm/lib/Target/RISCV/RISCVProcessors.td
@@ -166,6 +166,22 @@ def SIFIVE_U74 : RISCVProcessorModel<"sifive-u74",
   FeatureStdExtC],
  [TuneSiFive7]>;
 
+def SIFIVE_X280 : RISCVProcessorModel<"sifive-x280", SiFive7Model,
+  [Feature64Bit,
+   FeatureStdExtZifencei,
+   Feat

[PATCH] D149514: Check if First argument in _builtin_assume_aligned_ is of pointer type

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

LGTM, thank you! Do you need someone to commit on your behalf? If so, what name 
and email address would you like used for patch attribution?


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

https://reviews.llvm.org/D149514

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


[PATCH] D149514: Check if First argument in _builtin_assume_aligned_ is of pointer type

2023-05-05 Thread Rishabh Bali via Phabricator via cfe-commits
Ris-Bali added a comment.

Name : Rishabh Bali
Github Username : Ris-Bali
email-id : rishabhsb...@gmail.com


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

https://reviews.llvm.org/D149514

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


[PATCH] D149596: [AIX][TLS] Relax front end diagnostics to accept the local-exec TLS model

2023-05-05 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/D149596/new/

https://reviews.llvm.org/D149596

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


[clang] 0b3d737 - Check if First argument in _builtin_assume_aligned_ is of pointer type

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

Author: Rishabh Bali
Date: 2023-05-05T13:11:16-04:00
New Revision: 0b3d737877040a4eae03e47223f9a9ddfd7bd182

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

LOG: Check if First argument in _builtin_assume_aligned_ is of pointer type

Currently clang doesn't verify if the first argument in
`_builtin_assume_aligned` is of pointer type. This leads to an
assertion build failure. This patch aims to add a check if the first
argument is of pointer type or not and diagnose it with
diag::err_typecheck_convert_incompatible if its not of pointer type.

Fixes https://github.com/llvm/llvm-project/issues/62305
Differential Revision: https://reviews.llvm.org/D149514

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Sema/SemaChecking.cpp
clang/test/Sema/builtin-assume-aligned.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index a41917a5ed66a..910a853eafc81 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -368,6 +368,9 @@ Bug Fixes in This Version
   (`#62207 `_)
 - Fix lambdas and other anonymous function names not respecting 
``-fdebug-prefix-map``
   (`#62192 `_)
+- Fix crash when attempting to pass a non-pointer type as first argument of
+  ``__builtin_assume_aligned``.
+  (`#62305 `_) 
 
 Bug Fixes to Compiler Builtins
 ^^

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 5952ac4ff5ac4..03d6574ef3bcf 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -2829,8 +2829,6 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
   case Builtin::BI__builtin_assume_aligned: {
 const Expr *Ptr = E->getArg(0);
 Value *PtrValue = EmitScalarExpr(Ptr);
-if (PtrValue->getType() != VoidPtrTy)
-  PtrValue = EmitCastToVoidPtr(PtrValue);
 Value *OffsetValue =
   (E->getNumArgs() > 2) ? EmitScalarExpr(E->getArg(2)) : nullptr;
 

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 63c5b25b27262..a759cf30eeafd 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -8100,8 +8100,9 @@ bool Sema::SemaBuiltinAssumeAligned(CallExpr *TheCall) {
   {
 ExprResult FirstArgResult =
 DefaultFunctionArrayLvalueConversion(FirstArg);
-if (FirstArgResult.isInvalid())
+if (checkBuiltinArgument(*this, TheCall, 0))
   return true;
+/// In-place updation of FirstArg by checkBuiltinArgument is ignored.
 TheCall->setArg(0, FirstArgResult.get());
   }
 

diff  --git a/clang/test/Sema/builtin-assume-aligned.c 
b/clang/test/Sema/builtin-assume-aligned.c
index a5dd7e387181e..c2e4f9d659dd4 100644
--- a/clang/test/Sema/builtin-assume-aligned.c
+++ b/clang/test/Sema/builtin-assume-aligned.c
@@ -71,6 +71,25 @@ int test13(int *a) {
   return a[0];
 }
 
+int test14(int *a, int b) {
+  a = (int *)__builtin_assume_aligned(b, 32); // expected-error {{incompatible 
integer to pointer conversion passing 'int' to parameter of type 'const void *}}
+}
+
+int test15(int *b) {
+  int arr[3] = {1, 2, 3};
+  b = (int *)__builtin_assume_aligned(arr, 32);
+  return b[0];
+}
+
+int val(int x) {
+  return x;
+}
+
+int test16(int *b) {
+  b = (int *)__builtin_assume_aligned(val, 32);
+  return b[0];
+}
+
 void test_void_assume_aligned(void) __attribute__((assume_aligned(32))); // 
expected-warning {{'assume_aligned' attribute only applies to return values 
that are pointers}}
 int test_int_assume_aligned(void) __attribute__((assume_aligned(16))); // 
expected-warning {{'assume_aligned' attribute only applies to return values 
that are pointers}}
 void *test_ptr_assume_aligned(void) __attribute__((assume_aligned(64))); // 
no-warning



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


[PATCH] D149514: Check if First argument in _builtin_assume_aligned_ is of pointer type

2023-05-05 Thread Aaron Ballman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0b3d73787704: Check if First argument in 
_builtin_assume_aligned_ is of pointer type (authored by Ris-Bali, committed by 
aaron.ballman).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149514

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/builtin-assume-aligned.c


Index: clang/test/Sema/builtin-assume-aligned.c
===
--- clang/test/Sema/builtin-assume-aligned.c
+++ clang/test/Sema/builtin-assume-aligned.c
@@ -71,6 +71,25 @@
   return a[0];
 }
 
+int test14(int *a, int b) {
+  a = (int *)__builtin_assume_aligned(b, 32); // expected-error {{incompatible 
integer to pointer conversion passing 'int' to parameter of type 'const void *}}
+}
+
+int test15(int *b) {
+  int arr[3] = {1, 2, 3};
+  b = (int *)__builtin_assume_aligned(arr, 32);
+  return b[0];
+}
+
+int val(int x) {
+  return x;
+}
+
+int test16(int *b) {
+  b = (int *)__builtin_assume_aligned(val, 32);
+  return b[0];
+}
+
 void test_void_assume_aligned(void) __attribute__((assume_aligned(32))); // 
expected-warning {{'assume_aligned' attribute only applies to return values 
that are pointers}}
 int test_int_assume_aligned(void) __attribute__((assume_aligned(16))); // 
expected-warning {{'assume_aligned' attribute only applies to return values 
that are pointers}}
 void *test_ptr_assume_aligned(void) __attribute__((assume_aligned(64))); // 
no-warning
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -8100,8 +8100,9 @@
   {
 ExprResult FirstArgResult =
 DefaultFunctionArrayLvalueConversion(FirstArg);
-if (FirstArgResult.isInvalid())
+if (checkBuiltinArgument(*this, TheCall, 0))
   return true;
+/// In-place updation of FirstArg by checkBuiltinArgument is ignored.
 TheCall->setArg(0, FirstArgResult.get());
   }
 
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -2829,8 +2829,6 @@
   case Builtin::BI__builtin_assume_aligned: {
 const Expr *Ptr = E->getArg(0);
 Value *PtrValue = EmitScalarExpr(Ptr);
-if (PtrValue->getType() != VoidPtrTy)
-  PtrValue = EmitCastToVoidPtr(PtrValue);
 Value *OffsetValue =
   (E->getNumArgs() > 2) ? EmitScalarExpr(E->getArg(2)) : nullptr;
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -368,6 +368,9 @@
   (`#62207 `_)
 - Fix lambdas and other anonymous function names not respecting 
``-fdebug-prefix-map``
   (`#62192 `_)
+- Fix crash when attempting to pass a non-pointer type as first argument of
+  ``__builtin_assume_aligned``.
+  (`#62305 `_) 
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/Sema/builtin-assume-aligned.c
===
--- clang/test/Sema/builtin-assume-aligned.c
+++ clang/test/Sema/builtin-assume-aligned.c
@@ -71,6 +71,25 @@
   return a[0];
 }
 
+int test14(int *a, int b) {
+  a = (int *)__builtin_assume_aligned(b, 32); // expected-error {{incompatible integer to pointer conversion passing 'int' to parameter of type 'const void *}}
+}
+
+int test15(int *b) {
+  int arr[3] = {1, 2, 3};
+  b = (int *)__builtin_assume_aligned(arr, 32);
+  return b[0];
+}
+
+int val(int x) {
+  return x;
+}
+
+int test16(int *b) {
+  b = (int *)__builtin_assume_aligned(val, 32);
+  return b[0];
+}
+
 void test_void_assume_aligned(void) __attribute__((assume_aligned(32))); // expected-warning {{'assume_aligned' attribute only applies to return values that are pointers}}
 int test_int_assume_aligned(void) __attribute__((assume_aligned(16))); // expected-warning {{'assume_aligned' attribute only applies to return values that are pointers}}
 void *test_ptr_assume_aligned(void) __attribute__((assume_aligned(64))); // no-warning
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -8100,8 +8100,9 @@
   {
 ExprResult FirstArgResult =
 DefaultFunctionArrayLvalueConversion(FirstArg);
-if (FirstArgResult.isInvalid())
+if (checkBuiltinArgument(*this, TheCall, 0))
   return true;
+/// In-place updation of FirstArg by checkBuiltinArgument is ignored.
 TheCall->setArg(0, FirstArgResult.get());

[PATCH] D149497: [RISCV] Add scheduling information for Zba and Zbb to RISCVSchedSiFive7.td

2023-05-05 Thread Michael Maitland via Phabricator via cfe-commits
michaelmaitland added a comment.

This revision needs to be reopened because it was committed with changes that 
are not relevant to this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149497

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


[PATCH] D149497: [RISCV] Add scheduling information for Zba and Zbb to RISCVSchedSiFive7.td

2023-05-05 Thread Michael Maitland via Phabricator via cfe-commits
michaelmaitland updated this revision to Diff 519921.
michaelmaitland added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149497

Files:
  llvm/lib/Target/RISCV/RISCVSchedSiFive7.td


Index: llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
===
--- llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
+++ llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
@@ -76,6 +76,35 @@
   let ResourceCycles = [1, 15];
 }
 
+// Bitmanip
+let Latency = 3 in {
+// Rotates are in the late-B ALU.
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+
+// clz[w]/ctz[w] are in the late-B ALU.
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+
+// cpop[w] look exactly like multiply.
+def : WriteRes;
+def : WriteRes;
+
+// orc.b is in the late-B ALU.
+def : WriteRes;
+
+// rev8 is in the late-A and late-B ALUs.
+def : WriteRes;
+
+// shNadd[.uw] is on the early-B and late-B ALUs.
+def : WriteRes;
+def : WriteRes;
+}
+
 // Memory
 def : WriteRes;
 def : WriteRes;
@@ -279,11 +308,25 @@
 
 def : ReadAdvance;
 
+// Bitmanip
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+
 
//===--===//
 // Unsupported extensions
 defm : UnsupportedSchedV;
-defm : UnsupportedSchedZba;
-defm : UnsupportedSchedZbb;
 defm : UnsupportedSchedZbc;
 defm : UnsupportedSchedZbs;
 defm : UnsupportedSchedZbkb;


Index: llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
===
--- llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
+++ llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
@@ -76,6 +76,35 @@
   let ResourceCycles = [1, 15];
 }
 
+// Bitmanip
+let Latency = 3 in {
+// Rotates are in the late-B ALU.
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+
+// clz[w]/ctz[w] are in the late-B ALU.
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+
+// cpop[w] look exactly like multiply.
+def : WriteRes;
+def : WriteRes;
+
+// orc.b is in the late-B ALU.
+def : WriteRes;
+
+// rev8 is in the late-A and late-B ALUs.
+def : WriteRes;
+
+// shNadd[.uw] is on the early-B and late-B ALUs.
+def : WriteRes;
+def : WriteRes;
+}
+
 // Memory
 def : WriteRes;
 def : WriteRes;
@@ -279,11 +308,25 @@
 
 def : ReadAdvance;
 
+// Bitmanip
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+
 //===--===//
 // Unsupported extensions
 defm : UnsupportedSchedV;
-defm : UnsupportedSchedZba;
-defm : UnsupportedSchedZbb;
 defm : UnsupportedSchedZbc;
 defm : UnsupportedSchedZbs;
 defm : UnsupportedSchedZbkb;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D149497: [RISCV] Add scheduling information for Zba and Zbb to RISCVSchedSiFive7.td

2023-05-05 Thread Michael Maitland 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 rGf9fa8a599704: [RISCV] Add scheduling information for Zba and 
Zbb to RISCVSchedSiFive7.td (authored by michaelmaitland).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149497

Files:
  llvm/lib/Target/RISCV/RISCVSchedSiFive7.td


Index: llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
===
--- llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
+++ llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
@@ -76,6 +76,35 @@
   let ResourceCycles = [1, 15];
 }
 
+// Bitmanip
+let Latency = 3 in {
+// Rotates are in the late-B ALU.
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+
+// clz[w]/ctz[w] are in the late-B ALU.
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+
+// cpop[w] look exactly like multiply.
+def : WriteRes;
+def : WriteRes;
+
+// orc.b is in the late-B ALU.
+def : WriteRes;
+
+// rev8 is in the late-A and late-B ALUs.
+def : WriteRes;
+
+// shNadd[.uw] is on the early-B and late-B ALUs.
+def : WriteRes;
+def : WriteRes;
+}
+
 // Memory
 def : WriteRes;
 def : WriteRes;
@@ -279,11 +308,25 @@
 
 def : ReadAdvance;
 
+// Bitmanip
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+
 
//===--===//
 // Unsupported extensions
 defm : UnsupportedSchedV;
-defm : UnsupportedSchedZba;
-defm : UnsupportedSchedZbb;
 defm : UnsupportedSchedZbc;
 defm : UnsupportedSchedZbs;
 defm : UnsupportedSchedZbkb;


Index: llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
===
--- llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
+++ llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
@@ -76,6 +76,35 @@
   let ResourceCycles = [1, 15];
 }
 
+// Bitmanip
+let Latency = 3 in {
+// Rotates are in the late-B ALU.
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+
+// clz[w]/ctz[w] are in the late-B ALU.
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+def : WriteRes;
+
+// cpop[w] look exactly like multiply.
+def : WriteRes;
+def : WriteRes;
+
+// orc.b is in the late-B ALU.
+def : WriteRes;
+
+// rev8 is in the late-A and late-B ALUs.
+def : WriteRes;
+
+// shNadd[.uw] is on the early-B and late-B ALUs.
+def : WriteRes;
+def : WriteRes;
+}
+
 // Memory
 def : WriteRes;
 def : WriteRes;
@@ -279,11 +308,25 @@
 
 def : ReadAdvance;
 
+// Bitmanip
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+def : ReadAdvance;
+
 //===--===//
 // Unsupported extensions
 defm : UnsupportedSchedV;
-defm : UnsupportedSchedZba;
-defm : UnsupportedSchedZbb;
 defm : UnsupportedSchedZbc;
 defm : UnsupportedSchedZbs;
 defm : UnsupportedSchedZbkb;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D149518: [clang] Optimize clang::ASTNodeKind::isBaseOf

2023-05-05 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.

Oh wow, I'm surprised that calculating the distance has that much compile time 
impact. Great catch! Please add `NFC` to the commit summary so folks know why 
there are no tests.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149518

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


[PATCH] D149723: [clang-tidy] Optimize performance of RenamerClangTidyCheck

2023-05-05 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL marked 3 inline comments as done.
PiotrZSL added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp:47
 
-std::hash SecondHash;
-return DenseMapInfo::getHashValue(Val.first) +
-   SecondHash(Val.second);
+return hash_combine(
+DenseMapInfo::getHashValue(Val.first),

njames93 wrote:
> What's the purpose of using hash_combine instead of just adding the 2 hashes 
> together, there is enough entropy in the hashes that a simple operation makes 
> more sense?
Habit, hash_combine sounded better here, I can change this to +.



Comment at: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp:201
 
-addUsage(Decl->getParent(), Decl->getNameInfo().getSourceRange(),
- Result.SourceManager);
+  bool shouldVisitTemplateInstantiations() const { return true; }
+

njames93 wrote:
> What is the reason for visiting template instantiations?
Tests were failing, some method overrides are known only when we visit template 
instances. Without this code related to "Fix overridden methods"  (line 281) 
were not executed properly.
And as an result overridden virtual methods in template classes were not 
"fixed". Previously it worked in same way.



Comment at: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp:495
+  AggressiveDependentMemberLookup);
+  Visitor.TraverseDecl(const_cast(Decl));
 }

njames93 wrote:
> Instead of this nasty const cast, you can just use 
> `Visitor.TraverseAST(*Result.Context);`
Yes I know, but it looked strange when we register matcher for something, and 
then in check we don't use that something.
I can change this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149723

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


[PATCH] D149723: [clang-tidy] Optimize performance of RenamerClangTidyCheck

2023-05-05 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL updated this revision to Diff 519924.
PiotrZSL marked 3 inline comments as done.
PiotrZSL added a comment.

Use operator  + instead of hash_combine.
Use TraverseAST.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149723

Files:
  clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h

Index: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
===
--- clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
+++ clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
@@ -102,24 +102,26 @@
 NamingCheckFailure() = default;
   };
 
-  using NamingCheckId = std::pair;
+  using NamingCheckId = std::pair;
 
   using NamingCheckFailureMap =
   llvm::DenseMap;
 
   /// Check Macros for style violations.
-  void checkMacro(SourceManager &SourceMgr, const Token &MacroNameTok,
+  void checkMacro(const SourceManager &SourceMgr, const Token &MacroNameTok,
   const MacroInfo *MI);
 
   /// Add a usage of a macro if it already has a violation.
   void expandMacro(const Token &MacroNameTok, const MacroInfo *MI);
 
   void addUsage(const RenamerClangTidyCheck::NamingCheckId &Decl,
-SourceRange Range, SourceManager *SourceMgr = nullptr);
+SourceRange Range, const SourceManager *SourceMgr = nullptr);
 
   /// Convenience method when the usage to be added is a NamedDecl.
   void addUsage(const NamedDecl *Decl, SourceRange Range,
-SourceManager *SourceMgr = nullptr);
+const SourceManager *SourceMgr = nullptr);
+
+  void checkNamedDecl(const NamedDecl *Decl, const SourceManager &SourceMgr);
 
 protected:
   /// Overridden by derived classes, returns information about if and how a Decl
Index: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
===
--- clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
+++ clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
@@ -9,6 +9,7 @@
 #include "RenamerClangTidyCheck.h"
 #include "ASTUtils.h"
 #include "clang/AST/CXXInheritance.h"
+#include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/Frontend/CompilerInstance.h"
@@ -43,9 +44,8 @@
 assert(Val != getEmptyKey() && "Cannot hash the empty key!");
 assert(Val != getTombstoneKey() && "Cannot hash the tombstone key!");
 
-std::hash SecondHash;
 return DenseMapInfo::getHashValue(Val.first) +
-   SecondHash(Val.second);
+   DenseMapInfo::getHashValue(Val.second);
   }
 
   static bool isEqual(const NamingCheckId &LHS, const NamingCheckId &RHS) {
@@ -61,153 +61,6 @@
 
 namespace clang::tidy {
 
-namespace {
-
-/// Callback supplies macros to RenamerClangTidyCheck::checkMacro
-class RenamerClangTidyCheckPPCallbacks : public PPCallbacks {
-public:
-  RenamerClangTidyCheckPPCallbacks(Preprocessor *PP,
-   RenamerClangTidyCheck *Check)
-  : PP(PP), Check(Check) {}
-
-  /// MacroDefined calls checkMacro for macros in the main file
-  void MacroDefined(const Token &MacroNameTok,
-const MacroDirective *MD) override {
-if (MD->getMacroInfo()->isBuiltinMacro())
-  return;
-if (PP->getSourceManager().isWrittenInBuiltinFile(
-MacroNameTok.getLocation()))
-  return;
-if (PP->getSourceManager().isWrittenInCommandLineFile(
-MacroNameTok.getLocation()))
-  return;
-Check->checkMacro(PP->getSourceManager(), MacroNameTok, MD->getMacroInfo());
-  }
-
-  /// MacroExpands calls expandMacro for macros in the main file
-  void MacroExpands(const Token &MacroNameTok, const MacroDefinition &MD,
-SourceRange /*Range*/,
-const MacroArgs * /*Args*/) override {
-Check->expandMacro(MacroNameTok, MD.getMacroInfo());
-  }
-
-private:
-  Preprocessor *PP;
-  RenamerClangTidyCheck *Check;
-};
-
-} // namespace
-
-RenamerClangTidyCheck::RenamerClangTidyCheck(StringRef CheckName,
- ClangTidyContext *Context)
-: ClangTidyCheck(CheckName, Context),
-  AggressiveDependentMemberLookup(
-  Options.getLocalOrGlobal("AggressiveDependentMemberLookup", false)) {}
-RenamerClangTidyCheck::~RenamerClangTidyCheck() = default;
-
-void RenamerClangTidyCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
-  Options.store(Opts, "AggressiveDependentMemberLookup",
-AggressiveDependentMemberLookup);
-}
-
-void RenamerClangTidyCheck::registerMatchers(MatchFinder *Finder) {
-  Finder->addMatcher(namedDecl().bind("decl"), this);
-  Finder->addMatcher(usingDecl().bind("using"), this);
-  Finder->addMatcher(declRefExpr().bind("declRef"), this);
-  Finder->

[PATCH] D149846: [clang][Interp] Check inc/dec family of ops for initialization

2023-05-05 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/D149846/new/

https://reviews.llvm.org/D149846

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


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

2023-05-05 Thread Vy Nguyen via Phabricator via cfe-commits
oontvoo marked an inline comment as done.
oontvoo added a comment.

In D144999#4319964 , @jyknight wrote:

> I wonder if we actually need to define a clang frontend flag for this; I 
> suspect nobody will ever want to specify it, since the only non-canonical 
> personality clang will ever generate that changes behavior is the pure-C 
> destructor-only personality, `__gnu_personality_v0`. Otherwise, it could only 
> arise from assembly or IR.
>
> For a test-case, can just use `-mllvm -emit-compact-unwind-non-canonical`.

Per offline discussion, passing it via `-mllvm` doesn't work because  
llvm-flags that populate MCTargetOptions flags aren't registered in Clang, so 
it needs to be at least a clang cc1 option.




Comment at: lld/MachO/UnwindInfoSection.cpp:364
   cu.encoding = target->modeDwarfEncoding | d->unwindEntry->outSecOff;
-  const FDE &fde = cast(d->getFile())->fdes[d->unwindEntry];
   cu.functionLength = fde.funcLength;

int3 wrote:
> seems like this was accidentally deleted?
yes - good catch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144999

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


[PATCH] D149976: adding bf16 support to NVPTX

2023-05-05 Thread Kushan Ahmadian via Phabricator via cfe-commits
kushanam created this revision.
Herald added subscribers: mattd, gchakrabarti, asavonic, hiraditya.
Herald added a project: All.
kushanam requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, jdoerfert, jholewinski.
Herald added projects: clang, LLVM.

Currently, bf16 has been scatteredly added to the PTX codegen. This patch aims 
to complete the set of instructions and code path required to support bf16 data 
type.

Depends on D144911 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149976

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

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

[PATCH] D147591: [clang][Interp] Handle CXXTemporaryObjectExprs

2023-05-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/test/AST/Interp/records.cpp:317-318
 {
-  auto T = Test(Arr, Pos);
+  Test(Arr, Pos);
   // End of scope, should destroy Test.
 }

Nit: nothing actually tests that this object is destroyed correctly. Here's an 
interesting test to consider:
```
struct S {
  constexpr S() {}
  constexpr ~S() noexcept(false) { throw 12; }
};

constexpr int f() {
  S{};
  return 12;
}

static_assert(f() == 12);
```
That should fail because `~S()` would hit the `throw` expression and thus is 
not valid. Note, you'll need to add `-Wno-invalid-constexpr` to your test to 
avoid the warning-defaults-to-error about the destructor never producing a 
constant expression.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147591

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


[PATCH] D149579: [X86][MC] Fix parsing Intel syntax indirect branch with symbol only

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



Comment at: llvm/test/MC/X86/intel-syntax-branch.s:61-67
+  // FIXME: MASM does not accept this syntax and GAS assembles this as a direct
+  //call/jump instead of indirect. Consider making this syntax an 
error?
+  call [offset fn_ref]
+  jmp [offset fn_ref]
+  // CHECK-32-LABEL: t7:
+  // CHECK-32: calll *fn_ref
+  // CHECK-32: jmpl *fn_ref

alvinhochun wrote:
> About the `call [offset fn_ref]` case, do you think we should reject it since 
> MASM does not accept this syntax and GAS appears to behave oddly with it? The 
> `ms-inline-asm-functions.c` test does generate `call [offset _kptr]` so this 
> will also need to be changed.
Yes, I think we should reject `call [offset fn_ref]`. Confirmed with a MinGW 
dev (lh_mouse) that this is invalid.



Comment at: llvm/test/MC/X86/intel-syntax-branch.s:48
+  call dword ptr fn_ref
+  jmp dword ptr fn_ref
+  // CHECK-32-LABEL: t5:

alvinhochun wrote:
> MaskRay wrote:
> > ICC and MSVC parse this differently.
> > 
> > Is this syntax valid?
> MASM ml.exe assembles this as `jmp dword ptr [fn_ref]` in my test, so does 
> GAS. I don't know how valid this syntax is though.
LG. cl.exe compiles `void (*kptr)(); ... __asm call kptr;` to `callDWORD 
PTR _kptr`, so it seems that the bracket can be omitted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149579

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


[PATCH] D142991: [clang-tidy] Add --fix-mode and --nolint-prefix options

2023-05-05 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added inline comments.
Herald added a subscriber: PiotrZSL.



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:58
+  (Lexer::getIndentationForLine(Loc, Loc.getManager()) + "/* " +
+   NoLintPrefix + "NOLINTNEXTLINE(" + Error.DiagnosticName + ") */\n")
+  .str());

Note that if the NOLINT is being inserted into a macro definition, we also need 
a backslash before the newline.



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h:245
+/// Controls how clang-tidy applies fixes.
+enum FixType {
+  /// Only apply fix-its.

Generally in Clang and adjacent projects we reserve the word "Type" to refer to 
C++ types. For other uses, we use a synonym - like "Kind" or "Mode".

I think "FixMode" will work well here, WDYT?



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h:251
+  /// Add NOLINT if fix-it is not available.
+  FT_FixItOrNoLint
+};

I think it would be better to use an enum class and avoid prefixing.

(There are a lot of plain enums in Clang because Clang was originally developed 
in C++03.)



Comment at: 
clang-tools-extra/test/clang-tidy/infrastructure/fix-mode-nolint.cpp:2
+// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
+// RUN: clang-tidy %t.cpp 
-checks='-*,modernize-use-trailing-return-type,readability-identifier-length' 
-fix -fix-mode=nolint -nolint-prefix='FIXME: ' -export-fixes=%t.yaml -- > 
%t.msg 2>&1
+// RUN: FileCheck -input-file=%t.cpp %s

Could you add a second clang-tidy invocation over the fixed file to show that 
no warnings are produced? That would prove that the comments are inserted in 
the right place.

(here and in the other test)



Comment at: 
clang-tools-extra/test/clang-tidy/infrastructure/fix-mode-nolint.cpp:7
+
+// CHECK: /* FIXME: NOLINTNEXTLINE(modernize-use-trailing-return-type) */
+// CHECK-NEXT: int func() {

WDYT about making the comment style configurable? I think many people working 
in C++ will prefer //-style comments.





Comment at: 
clang-tools-extra/test/clang-tidy/infrastructure/fix-mode-nolint.cpp:18
+  return i;
+}

Could you add more tests, specifically tests with macros?

- A test where the problem is reported in the macro expansion, the warning is 
attached to the macro definition.

- A test where the problem is reported in the macro expansion, but the warning 
is attached to the tokens in the macro argument.

The SourceLocation computations are quite subtle with macros so these cases are 
worth covering.

Note that when inserting NOLINTs into a macro definition, one has to use `/* 
*/`-style comments.


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

https://reviews.llvm.org/D142991

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


[PATCH] D149976: adding bf16 support to NVPTX

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

This patch appears to *include* the changes in D144911 
 (e.g. 
llvm/test/CodeGen/NVPTX/bf16-instructions.ll is added by both patches). Can you 
update it as an incremental patch that actually excludes it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149976

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


[PATCH] D146030: [clang][Interp] Handle LambdaExprs

2023-05-05 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/AST/Interp/ByteCodeEmitter.cpp:56-57
+  const Record *R = P.getOrCreateRecord(MD->getParent());
+  llvm::DenseMap _LambdaCaptures;
+  FieldDecl *_LambdaThisCapture;
+

UB alert -- `_L` is reserved; let's pick names without leading underscores or 
shadowing.



Comment at: clang/lib/AST/Interp/ByteCodeEmitter.h:73-74
   llvm::DenseMap Params;
+  /// Lambda captures.
+  llvm::DenseMap> LambdaCaptures;
+  unsigned *LambdaThisCapture;

Can you add comments explaining what the `unsigned, bool` pair is encoding?



Comment at: clang/lib/AST/Interp/ByteCodeEmitter.h:75
+  llvm::DenseMap> LambdaCaptures;
+  unsigned *LambdaThisCapture;
   /// Local descriptors.

Why is this a pointer? Since it's not really implemented, I'd recommend 
removing this for now and adding it back when you add support for capturing 
`this`.



Comment at: clang/test/AST/Interp/lambda.cpp:92
+  static_assert(foo() == 1); // expected-error {{not an integral constant 
expression}}
+}
+

How about some tests like:
```
constexpr int call_thru_func_ptr(int i) {
  auto l = [](int i) { return i; };
  int (*fp)(int) = l;
  return fp(i);  
}
static_assert(call_thru_func_ptr(12) == 12);

constexpr int call_through_copied_lambda(auto lam, int i) {
  auto copy = lam;
  return copy(i);
}

constexpr int call_through_copied_lambda(auto lam) {
  auto copy = lam;
  return copy();
}

void func() {
  constexpr int i = 12;
  static_assert(call_through_copied_lambda([i]() { return i; }) == 12);
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146030

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


[clang] 6e0c441 - [NFC][CLANG] Fix nullptr dereference found by Coverity static analysis tool

2023-05-05 Thread via cfe-commits

Author: Manna, Soumi
Date: 2023-05-05T11:57:33-07:00
New Revision: 6e0c44174823260fd74d14d036eaf1c64fa5eded

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

LOG: [NFC][CLANG] Fix nullptr dereference found by Coverity static analysis tool

Reported by Coverity:

  In clang::ASTContext::hasUniqueObjectRepresentations(clang::QualType, bool): 
Return value of function which returns null is dereferenced without checking.

  (Ty->isMemberPointerType()) {
//returned_null: getAs returns nullptr.
//var_assigned: Assigning: MPT = nullptr return value from getAs.
  const auto *MPT = Ty->getAs();

 //dereference: Dereferencing a pointer that might be nullptr MPT when 
calling getMemberPointerInfo. (The virtual call resolves to
 ::ItaniumCXXABI::getMemberPointerInfo.)
  return !ABI->getMemberPointerInfo(MPT).HasPadding;
}

ABIs assume the parameter passed to `getMemberPointerInfo` is non-null.
This patch checks type by doing a `if (const auto *MPT = 
Ty->getAs())` instead.

Reviewed By: erichkeane

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

Added: 


Modified: 
clang/lib/AST/ASTContext.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 3a72c3d25794..de65c3cc47b9 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -2859,10 +2859,8 @@ bool ASTContext::hasUniqueObjectRepresentations(
   if (Ty->isPointerType())
 return true;
 
-  if (Ty->isMemberPointerType()) {
-const auto *MPT = Ty->getAs();
+  if (const auto *MPT = Ty->getAs())
 return !ABI->getMemberPointerInfo(MPT).HasPadding;
-  }
 
   if (Ty->isRecordType()) {
 const RecordDecl *Record = Ty->castAs()->getDecl();



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


[PATCH] D149922: Fix nullptr dereference found by Coverity static analysis tool

2023-05-05 Thread Soumi Manna via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6e0c44174823: [NFC][CLANG] Fix nullptr dereference found by 
Coverity static analysis tool (authored by Manna).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149922

Files:
  clang/lib/AST/ASTContext.cpp


Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2859,10 +2859,8 @@
   if (Ty->isPointerType())
 return true;
 
-  if (Ty->isMemberPointerType()) {
-const auto *MPT = Ty->getAs();
+  if (const auto *MPT = Ty->getAs())
 return !ABI->getMemberPointerInfo(MPT).HasPadding;
-  }
 
   if (Ty->isRecordType()) {
 const RecordDecl *Record = Ty->castAs()->getDecl();


Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -2859,10 +2859,8 @@
   if (Ty->isPointerType())
 return true;
 
-  if (Ty->isMemberPointerType()) {
-const auto *MPT = Ty->getAs();
+  if (const auto *MPT = Ty->getAs())
 return !ABI->getMemberPointerInfo(MPT).HasPadding;
-  }
 
   if (Ty->isRecordType()) {
 const RecordDecl *Record = Ty->castAs()->getDecl();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-05-05 Thread Vy Nguyen via Phabricator via cfe-commits
oontvoo updated this revision to Diff 519939.
oontvoo added a comment.

addressed review comments:

- added explanation on why we left out _gcc personality
- updated more clang tests

hopefully should be all green now!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144999

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/femit-dwarf-unwind.c
  clang/test/Driver/femit-dwarf-unwind.s
  clang/tools/driver/cc1as_main.cpp
  lld/MachO/UnwindInfoSection.cpp
  lld/test/MachO/Inputs/eh-frame-x86_64-r.o
  lld/test/MachO/compact-unwind-both-local-and-dylib-personality.s
  lld/test/MachO/compact-unwind-generated.test
  lld/test/MachO/compact-unwind-lsda-folding.s
  lld/test/MachO/compact-unwind-stack-ind.s
  lld/test/MachO/compact-unwind.s
  lld/test/MachO/eh-frame-personality-dedup.s
  lld/test/MachO/eh-frame.s
  lld/test/MachO/icf-only-lsda-folded.s
  lld/test/MachO/icf.s
  lld/test/MachO/invalid/compact-unwind-bad-reloc.s
  lld/test/MachO/invalid/compact-unwind-personalities.s
  llvm/include/llvm/MC/MCAsmBackend.h
  llvm/include/llvm/MC/MCContext.h
  llvm/include/llvm/MC/MCTargetOptions.h
  llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h
  llvm/lib/MC/MCAsmBackend.cpp
  llvm/lib/MC/MCContext.cpp
  llvm/lib/MC/MCStreamer.cpp
  llvm/lib/MC/MCTargetOptionsCommandFlags.cpp
  llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
  llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
  llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackendDarwin.h
  llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
  llvm/test/CodeGen/X86/2014-08-29-CompactUnwind.ll
  llvm/test/CodeGen/X86/compact-unwind.ll
  llvm/test/MC/AArch64/arm64-leaf-compact-unwind.s
  llvm/test/MC/MachO/AArch64/emit-dwarf-unwind.s
  llvm/test/MC/MachO/ARM/compact-unwind-armv7k.s
  llvm/test/MC/X86/compact-unwind.s

Index: llvm/test/MC/X86/compact-unwind.s
===
--- llvm/test/MC/X86/compact-unwind.s
+++ llvm/test/MC/X86/compact-unwind.s
@@ -1,4 +1,4 @@
-# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin10.0 %s | llvm-objdump --unwind-info - | FileCheck %s
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin10.0 %s -emit-compact-unwind-non-canonical=true | llvm-objdump --unwind-info - | FileCheck %s
 
 	.section	__TEXT,__text,regular,pure_instructions
 	.macosx_version_min 10, 10
Index: llvm/test/MC/MachO/ARM/compact-unwind-armv7k.s
===
--- llvm/test/MC/MachO/ARM/compact-unwind-armv7k.s
+++ llvm/test/MC/MachO/ARM/compact-unwind-armv7k.s
@@ -1,4 +1,4 @@
-@ RUN: llvm-mc -triple=thumbv7k-apple-watchos2.0.0 -filetype=obj -o %t < %s && llvm-objdump --unwind-info %t | FileCheck %s
+@ RUN: llvm-mc -triple=thumbv7k-apple-watchos2.0.0 -emit-compact-unwind-non-canonical=true -filetype=obj -o %t < %s && llvm-objdump --unwind-info %t | FileCheck %s
 
 @ CHECK: Contents of __compact_unwind section:
 
Index: llvm/test/MC/MachO/AArch64/emit-dwarf-unwind.s
===
--- llvm/test/MC/MachO/AArch64/emit-dwarf-unwind.s
+++ llvm/test/MC/MachO/AArch64/emit-dwarf-unwind.s
@@ -1,11 +1,11 @@
 // RUN: rm -rf %t; mkdir %t
-// RUN: llvm-mc -triple x86_64-apple-macos11.0 %s -filetype=obj -o %t/x86_64.o
+// RUN: llvm-mc -triple x86_64-apple-macos11.0 %s -filetype=obj -o %t/x86_64.o -emit-compact-unwind-non-canonical=true
 // RUN: llvm-objdump --macho --dwarf=frames %t/x86_64.o | FileCheck %s --check-prefix TWO-FDES
-// RUN: llvm-mc -triple arm64-apple-macos11.0 %s -filetype=obj -o %t/arm64.o
+// RUN: llvm-mc -triple arm64-apple-macos11.0 %s -filetype=obj -o %t/arm64.o -emit-compact-unwind-non-canonical=true
 // RUN: llvm-objdump --macho --dwarf=frames %t/arm64.o | FileCheck %s --check-prefix ONE-FDE
-// RUN: llvm-mc -triple x86_64-apple-macos11.0 %s -filetype=obj --emit-dwarf-unwind no-compact-unwind -o %t/x86_64-no-dwarf.o
+// RUN: llvm-mc -triple x86_64-apple-macos11.0 %s -filetype=obj --emit-dwarf-unwind no-compact-unwind -o %t/x86_64-no-dwarf.o -emit-compact-unwind-non-canonical=true
 // RUN: llvm-objdump --macho --dwarf=frames %t/x86_64-no-dwarf.o | FileCheck %s --check-prefix ONE-FDE
-// RUN: llvm-mc -triple arm64-apple-macos11.0 %s -filetype=obj --emit-dwarf-unwind always -o %t/arm64-dwarf.o
+// RUN: llvm-mc -triple arm64-apple-macos11.0 %s -filetype=obj --emit-dwarf-unwind always -o %t/arm64-dwarf.o -emit-compact-unwind-non-canonical=true
 // RUN: llvm-objdump --macho --dwarf=frames %t/arm64-dwarf.o | FileCheck %s --check-prefix TWO-FDES
 
 // TWO-FDES: FDE
Index: llvm/test/MC/AArch64/arm64-leaf-compact-unwind.s
===
--- llvm/test/MC/AArch64/arm64-leaf-compact-unwind.s
+++ llvm/test/MC/AArch64/arm64-leaf-compa

[PATCH] D149978: [Clang][NVPTX] Allow passing arguments to the linker while standalone

2023-05-05 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: JonChesterfield, tra, yaxunl, MaskRay.
Herald added subscribers: mattd, gchakrabarti, asavonic.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

We support standalone compilation for the NVPTX architecture using
'nvlink' as our linker. Because of the special handling required to
transform input files to cubins, as nvlink expects for some reason, we
didn't use the standard `AddLinkerInput` method. However, this also
meant that we weren't forwarding options passed with `-Wl` to the
linker. Add this support in for the standalone toolchain path.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149978

Files:
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/test/Driver/cuda-cross-compiling.c


Index: clang/test/Driver/cuda-cross-compiling.c
===
--- clang/test/Driver/cuda-cross-compiling.c
+++ clang/test/Driver/cuda-cross-compiling.c
@@ -77,3 +77,11 @@
 // RUN:   | FileCheck -check-prefix=LOWERING %s
 
 // LOWERING: -cc1" "-triple" "nvptx64-nvidia-cuda" {{.*}} "-mllvm" 
"--nvptx-lower-global-ctor-dtor"
+
+//
+// Test passing arguments directly to nvlink.
+//
+// RUN: %clang -target nvptx64-nvidia-cuda -Wl,-v -### %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=LINKER-ARGS %s
+
+// LINKER-ARGS: nvlink{{.*}}"-v"
Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -590,9 +590,6 @@
   CmdArgs.push_back("-arch");
   CmdArgs.push_back(Args.MakeArgString(GPUArch));
 
-  // Add paths specified in LIBRARY_PATH environment variable as -L options.
-  addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH");
-
   // Add paths for the default clang library path.
   SmallString<256> DefaultLibPath =
   llvm::sys::path::parent_path(TC.getDriver().Dir);
@@ -607,37 +604,42 @@
   continue;
 }
 
-// Currently, we only pass the input files to the linker, we do not pass
-// any libraries that may be valid only for the host.
-if (!II.isFilename())
-  continue;
-
 // The 'nvlink' application performs RDC-mode linking when given a '.o'
 // file and device linking when given a '.cubin' file. We always want to
 // perform device linking, so just rename any '.o' files.
 // FIXME: This should hopefully be removed if NVIDIA updates their tooling.
-auto InputFile = getToolChain().getInputFilename(II);
-if (llvm::sys::path::extension(InputFile) != ".cubin") {
-  // If there are no actions above this one then this is direct input and 
we
-  // can copy it. Otherwise the input is internal so a `.cubin` file should
-  // exist.
-  if (II.getAction() && II.getAction()->getInputs().size() == 0) {
-const char *CubinF =
-Args.MakeArgString(getToolChain().getDriver().GetTemporaryPath(
-llvm::sys::path::stem(InputFile), "cubin"));
-if (std::error_code EC =
-llvm::sys::fs::copy_file(InputFile, C.addTempFile(CubinF)))
-  continue;
+if (II.isFilename()) {
+  auto InputFile = getToolChain().getInputFilename(II);
+  if (llvm::sys::path::extension(InputFile) != ".cubin") {
+// If there are no actions above this one then this is direct input and
+// we can copy it. Otherwise the input is internal so a `.cubin` file
+// should exist.
+if (II.getAction() && II.getAction()->getInputs().size() == 0) {
+  const char *CubinF =
+  Args.MakeArgString(getToolChain().getDriver().GetTemporaryPath(
+  llvm::sys::path::stem(InputFile), "cubin"));
+  if (std::error_code EC =
+  llvm::sys::fs::copy_file(InputFile, C.addTempFile(CubinF)))
+continue;
 
-CmdArgs.push_back(CubinF);
+  CmdArgs.push_back(CubinF);
+} else {
+  SmallString<256> Filename(InputFile);
+  llvm::sys::path::replace_extension(Filename, "cubin");
+  CmdArgs.push_back(Args.MakeArgString(Filename));
+}
   } else {
-SmallString<256> Filename(InputFile);
-llvm::sys::path::replace_extension(Filename, "cubin");
-CmdArgs.push_back(Args.MakeArgString(Filename));
+CmdArgs.push_back(Args.MakeArgString(InputFile));
   }
-} else {
-  CmdArgs.push_back(Args.MakeArgString(InputFile));
+  continue;
 }
+
+// In some error cases, the input could be Nothing; skip those.
+if (II.isNothing())
+  continue;
+
+// Render any remaining arguments as input to nvlink.
+II.getInputArg().renderAsInput(Args, CmdArgs);
   }
 
   C.addCommand(std::make_unique(


Index: clang/test/Driver/cuda-cross-compiling.c
===
--- clang/test/Driv

[PATCH] D149978: [Clang][NVPTX] Allow passing arguments to the linker while standalone

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



Comment at: clang/lib/Driver/ToolChains/Cuda.cpp:594
-  // Add paths specified in LIBRARY_PATH environment variable as -L options.
-  addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH");
-

Is removal of this line intentional? 



Comment at: clang/lib/Driver/ToolChains/Cuda.cpp:634
   }
-} else {
-  CmdArgs.push_back(Args.MakeArgString(InputFile));
+  continue;
 }

I'd prefer to replace it with 
```
if (II.isFileName()) {
  do stuff...
} else {
  if (!II.isNothing()
  II.getInputArg().renderAsInput(Args, CmdArgs); 
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149978

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


[PATCH] D149980: Remove unused basic_android_tree/mipsel-linux-android

2023-05-05 Thread Aditya Kumar via Phabricator via cfe-commits
hiraditya created this revision.
hiraditya added reviewers: danalbert, enh, pirama, srhines.
Herald added subscribers: danielkiss, atanasyan, jrtc27, arichardson, sdardis.
Herald added a project: All.
hiraditya 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/D149980

Files:
  clang/test/Driver/Inputs/basic_android_tree/mipsel-linux-android/bin/.keep
  
clang/test/Driver/Inputs/basic_android_tree/mipsel-linux-android/include/c++/4.4.3/.keep
  clang/test/Driver/Inputs/basic_android_tree/mipsel-linux-android/lib/.keep




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


[PATCH] D149981: [clang][AST][NFC] Factor out check for structural equivalence of names.

2023-05-05 Thread David Stone via Phabricator via cfe-commits
davidstone created this revision.
Herald added a subscriber: martong.
Herald added a project: All.
davidstone requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

We have four places that we try to decide which name to use for the test for 
structural equivalence, and in each of those we evaluate 
`getTypedefNameForAnonDecl` twice. Pull out the check into a function to reduce 
duplication and evaluate things only once.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149981

Files:
  clang/lib/AST/ASTStructuralEquivalence.cpp


Index: clang/lib/AST/ASTStructuralEquivalence.cpp
===
--- clang/lib/AST/ASTStructuralEquivalence.cpp
+++ clang/lib/AST/ASTStructuralEquivalence.cpp
@@ -1453,19 +1453,25 @@
   return true;
 }
 
+static bool NameIsStructurallyEquivalent(const TagDecl &D1, const TagDecl &D2) 
{
+  auto GetName = [](const TagDecl &D) -> const IdentifierInfo * {
+if (const IdentifierInfo *Name = D.getIdentifier()) {
+  return Name;
+}
+if (const TypedefNameDecl *TypedefName = D.getTypedefNameForAnonDecl()) {
+  return TypedefName->getIdentifier();
+}
+return nullptr;
+  };
+  return IsStructurallyEquivalent(GetName(D1), GetName(D2));
+}
+
 /// Determine structural equivalence of two records.
 static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
  RecordDecl *D1, RecordDecl *D2) {
-
-  // Check for equivalent structure names.
-  IdentifierInfo *Name1 = D1->getIdentifier();
-  if (!Name1 && D1->getTypedefNameForAnonDecl())
-Name1 = D1->getTypedefNameForAnonDecl()->getIdentifier();
-  IdentifierInfo *Name2 = D2->getIdentifier();
-  if (!Name2 && D2->getTypedefNameForAnonDecl())
-Name2 = D2->getTypedefNameForAnonDecl()->getIdentifier();
-  if (!IsStructurallyEquivalent(Name1, Name2))
+  if (!NameIsStructurallyEquivalent(*D1, *D2)) {
 return false;
+  }
 
   if (D1->isUnion() != D2->isUnion()) {
 if (Context.Complain) {
@@ -1727,16 +1733,9 @@
 /// Determine structural equivalence of two enums.
 static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
  EnumDecl *D1, EnumDecl *D2) {
-
-  // Check for equivalent enum names.
-  IdentifierInfo *Name1 = D1->getIdentifier();
-  if (!Name1 && D1->getTypedefNameForAnonDecl())
-Name1 = D1->getTypedefNameForAnonDecl()->getIdentifier();
-  IdentifierInfo *Name2 = D2->getIdentifier();
-  if (!Name2 && D2->getTypedefNameForAnonDecl())
-Name2 = D2->getTypedefNameForAnonDecl()->getIdentifier();
-  if (!IsStructurallyEquivalent(Name1, Name2))
+  if (!NameIsStructurallyEquivalent(*D1, *D2)) {
 return false;
+  }
 
   // Compare the definitions of these two enums. If either or both are
   // incomplete (i.e. forward declared), we assume that they are equivalent.


Index: clang/lib/AST/ASTStructuralEquivalence.cpp
===
--- clang/lib/AST/ASTStructuralEquivalence.cpp
+++ clang/lib/AST/ASTStructuralEquivalence.cpp
@@ -1453,19 +1453,25 @@
   return true;
 }
 
+static bool NameIsStructurallyEquivalent(const TagDecl &D1, const TagDecl &D2) {
+  auto GetName = [](const TagDecl &D) -> const IdentifierInfo * {
+if (const IdentifierInfo *Name = D.getIdentifier()) {
+  return Name;
+}
+if (const TypedefNameDecl *TypedefName = D.getTypedefNameForAnonDecl()) {
+  return TypedefName->getIdentifier();
+}
+return nullptr;
+  };
+  return IsStructurallyEquivalent(GetName(D1), GetName(D2));
+}
+
 /// Determine structural equivalence of two records.
 static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
  RecordDecl *D1, RecordDecl *D2) {
-
-  // Check for equivalent structure names.
-  IdentifierInfo *Name1 = D1->getIdentifier();
-  if (!Name1 && D1->getTypedefNameForAnonDecl())
-Name1 = D1->getTypedefNameForAnonDecl()->getIdentifier();
-  IdentifierInfo *Name2 = D2->getIdentifier();
-  if (!Name2 && D2->getTypedefNameForAnonDecl())
-Name2 = D2->getTypedefNameForAnonDecl()->getIdentifier();
-  if (!IsStructurallyEquivalent(Name1, Name2))
+  if (!NameIsStructurallyEquivalent(*D1, *D2)) {
 return false;
+  }
 
   if (D1->isUnion() != D2->isUnion()) {
 if (Context.Complain) {
@@ -1727,16 +1733,9 @@
 /// Determine structural equivalence of two enums.
 static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
  EnumDecl *D1, EnumDecl *D2) {
-
-  // Check for equivalent enum names.
-  IdentifierInfo *Name1 = D1->getIdentifier();
-  if (!Name1 && D1->getTypedefNameForAnonDecl())
-Name1 = D1->getTypedefNameForAnonDecl()->getIdentifier();
-  IdentifierInfo *Name2 = D2->getIdentifier();
-  if (!Name2 && D2->getTypedefNameForAnonDecl())
-Name2 = D2->getTypedefNameForAnonDecl()->getId

[PATCH] D149946: [LoongArch] Define `ual` feature and override `allowsMisalignedMemoryAccesses`

2023-05-05 Thread Peter Smith via Phabricator via cfe-commits
peter.smith added a comment.

No objections for moving out m_arm_Features_Group or adding the alias. It looks 
like that is currently unused i.e. no driver filters out the 
m_arm_Features_Group. I can't comment on the LoongArch specific parts of the 
patch.

I think you may want to note in the help that the option is not universally 
supported. Perhaps add a test to show that it remains unused on a target that 
does not support it. For example for an x86_64 target:

  clang: warning: argument unused during compilation: '-munaligned-access' 
[-Wunused-command-line-argument]




Comment at: clang/include/clang/Driver/Options.td:3656
-def munaligned_access : Flag<["-"], "munaligned-access">, 
Group,
-  HelpText<"Allow memory accesses to be unaligned (AArch32/AArch64 only)">;
-def mno_unaligned_access : Flag<["-"], "mno-unaligned-access">, 
Group,

I think this is AArch32/AArch64/LoongArch only. I don't think this patch adds 
support for all other Targets.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149946

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


[PATCH] D149982: AMDGPU: Add basic gfx941 target

2023-05-05 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl created this revision.
kzhuravl added reviewers: arsenm, msearles, rampitec, t-tye.
Herald added subscribers: kosarev, mattd, gchakrabarti, asavonic, foad, 
kerbowa, hiraditya, tpr, dstuttard, yaxunl, jvesely, emaste.
Herald added a reviewer: jhenderson.
Herald added a reviewer: MaskRay.
Herald added a project: All.
kzhuravl requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, wdng, jholewinski.
Herald added projects: clang, LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149982

Files:
  clang/include/clang/Basic/Cuda.h
  clang/lib/Basic/Cuda.cpp
  clang/lib/Basic/Targets/NVPTX.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/test/CodeGenOpenCL/amdgpu-features.cl
  clang/test/Driver/amdgpu-macros.cl
  clang/test/Driver/amdgpu-mcpu.cl
  clang/test/Misc/target-invalid-cpu-note.c
  llvm/docs/AMDGPUUsage.rst
  llvm/include/llvm/BinaryFormat/ELF.h
  llvm/include/llvm/TargetParser/TargetParser.h
  llvm/lib/Object/ELFObjectFile.cpp
  llvm/lib/ObjectYAML/ELFYAML.cpp
  llvm/lib/Target/AMDGPU/AMDGPU.td
  llvm/lib/Target/AMDGPU/GCNProcessors.td
  llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp
  llvm/lib/TargetParser/TargetParser.cpp
  llvm/test/CodeGen/AMDGPU/directive-amdgcn-target.ll
  llvm/test/CodeGen/AMDGPU/elf-header-flags-mach.ll
  llvm/test/Object/AMDGPU/elf-header-flags-mach.yaml
  llvm/test/tools/llvm-objdump/ELF/AMDGPU/subtarget.ll
  llvm/test/tools/llvm-readobj/ELF/amdgpu-elf-headers.test
  llvm/tools/llvm-readobj/ELFDumper.cpp

Index: llvm/tools/llvm-readobj/ELFDumper.cpp
===
--- llvm/tools/llvm-readobj/ELFDumper.cpp
+++ llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -1588,6 +1588,7 @@
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX90A),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX90C),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX940),
+  LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX941),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1010),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1011),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1012),
@@ -1648,6 +1649,7 @@
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX90A),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX90C),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX940),
+  LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX941),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1010),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1011),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1012),
Index: llvm/test/tools/llvm-readobj/ELF/amdgpu-elf-headers.test
===
--- llvm/test/tools/llvm-readobj/ELF/amdgpu-elf-headers.test
+++ llvm/test/tools/llvm-readobj/ELF/amdgpu-elf-headers.test
@@ -205,6 +205,15 @@
 # RUN: yaml2obj %s -o %t -DABI_VERSION=2 -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX940
 # RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=ALL,KNOWN-ABI-VERSION,SINGLE-FLAG --match-full-lines -DABI_VERSION=2 -DFILE=%t -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX940 -DFLAG_VALUE=0x40
 
+# RUN: yaml2obj %s -o %t -DABI_VERSION=0 -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX941
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=ALL,KNOWN-ABI-VERSION,SINGLE-FLAG --match-full-lines -DABI_VERSION=0 -DFILE=%t -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX941 -DFLAG_VALUE=0x4B
+
+# RUN: yaml2obj %s -o %t -DABI_VERSION=1 -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX941
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=ALL,KNOWN-ABI-VERSION,SINGLE-FLAG --match-full-lines -DABI_VERSION=1 -DFILE=%t -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX941 -DFLAG_VALUE=0x4B
+
+# RUN: yaml2obj %s -o %t -DABI_VERSION=2 -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX941
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=ALL,KNOWN-ABI-VERSION,SINGLE-FLAG --match-full-lines -DABI_VERSION=2 -DFILE=%t -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX941 -DFLAG_VALUE=0x4B
+
 # RUN: yaml2obj %s -o %t -DABI_VERSION=0 -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX1010
 # RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=ALL,KNOWN-ABI-VERSION,SINGLE-FLAG --match-full-lines -DABI_VERSION=0 -DFILE=%t -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX1010 -DFLAG_VALUE=0x33
 
Index: llvm/test/tools/llvm-objdump/ELF/AMDGPU/subtarget.ll
===
--- llvm/test/tools/llvm-objdump/ELF/AMDGPU/subtarget.ll
+++ llvm/test/tools/llvm-objdump/ELF/AMDGPU/subtarget.ll
@@ -85,6 +85,11 @@
 
 ; --GFX9---
 ;
+; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx941 -filetype=obj -O0 -o %t.o %s
+; RUN: llvm-objdump -D --arch-name=amdgcn --mcpu=gfx941 %t.o > %t-specify.txt
+; RUN: llvm-objdump -D %t.o > %t-detect.txt
+; RUN: diff %t-specify.txt %t-detect.txt
+
 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx940 -filetype=obj -O0 -o

[PATCH] D149983: AMDGPU: Add basic gfx942 target

2023-05-05 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl created this revision.
kzhuravl added reviewers: arsenm, msearles, rampitec, t-tye.
Herald added subscribers: kosarev, mattd, gchakrabarti, asavonic, foad, 
kerbowa, hiraditya, tpr, dstuttard, yaxunl, jvesely, emaste.
Herald added a reviewer: jhenderson.
Herald added a reviewer: MaskRay.
Herald added a project: All.
kzhuravl requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, wdng, jholewinski.
Herald added projects: clang, LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149983

Files:
  clang/include/clang/Basic/Cuda.h
  clang/lib/Basic/Cuda.cpp
  clang/lib/Basic/Targets/NVPTX.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/test/CodeGenOpenCL/amdgpu-features.cl
  clang/test/Driver/amdgpu-macros.cl
  clang/test/Driver/amdgpu-mcpu.cl
  clang/test/Misc/target-invalid-cpu-note.c
  llvm/docs/AMDGPUUsage.rst
  llvm/include/llvm/BinaryFormat/ELF.h
  llvm/include/llvm/TargetParser/TargetParser.h
  llvm/lib/Object/ELFObjectFile.cpp
  llvm/lib/ObjectYAML/ELFYAML.cpp
  llvm/lib/Target/AMDGPU/AMDGPU.td
  llvm/lib/Target/AMDGPU/GCNProcessors.td
  llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUTargetStreamer.cpp
  llvm/lib/TargetParser/TargetParser.cpp
  llvm/test/CodeGen/AMDGPU/directive-amdgcn-target.ll
  llvm/test/CodeGen/AMDGPU/elf-header-flags-mach.ll
  llvm/test/Object/AMDGPU/elf-header-flags-mach.yaml
  llvm/test/tools/llvm-objdump/ELF/AMDGPU/subtarget.ll
  llvm/test/tools/llvm-readobj/ELF/amdgpu-elf-headers.test
  llvm/tools/llvm-readobj/ELFDumper.cpp

Index: llvm/tools/llvm-readobj/ELFDumper.cpp
===
--- llvm/tools/llvm-readobj/ELFDumper.cpp
+++ llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -1589,6 +1589,7 @@
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX90C),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX940),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX941),
+  LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX942),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1010),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1011),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1012),
@@ -1650,6 +1651,7 @@
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX90C),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX940),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX941),
+  LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX942),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1010),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1011),
   LLVM_READOBJ_ENUM_ENT(ELF, EF_AMDGPU_MACH_AMDGCN_GFX1012),
Index: llvm/test/tools/llvm-readobj/ELF/amdgpu-elf-headers.test
===
--- llvm/test/tools/llvm-readobj/ELF/amdgpu-elf-headers.test
+++ llvm/test/tools/llvm-readobj/ELF/amdgpu-elf-headers.test
@@ -214,6 +214,15 @@
 # RUN: yaml2obj %s -o %t -DABI_VERSION=2 -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX941
 # RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=ALL,KNOWN-ABI-VERSION,SINGLE-FLAG --match-full-lines -DABI_VERSION=2 -DFILE=%t -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX941 -DFLAG_VALUE=0x4B
 
+# RUN: yaml2obj %s -o %t -DABI_VERSION=0 -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX942
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=ALL,KNOWN-ABI-VERSION,SINGLE-FLAG --match-full-lines -DABI_VERSION=0 -DFILE=%t -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX942 -DFLAG_VALUE=0x4C
+
+# RUN: yaml2obj %s -o %t -DABI_VERSION=1 -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX942
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=ALL,KNOWN-ABI-VERSION,SINGLE-FLAG --match-full-lines -DABI_VERSION=1 -DFILE=%t -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX942 -DFLAG_VALUE=0x4C
+
+# RUN: yaml2obj %s -o %t -DABI_VERSION=2 -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX942
+# RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=ALL,KNOWN-ABI-VERSION,SINGLE-FLAG --match-full-lines -DABI_VERSION=2 -DFILE=%t -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX942 -DFLAG_VALUE=0x4C
+
 # RUN: yaml2obj %s -o %t -DABI_VERSION=0 -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX1010
 # RUN: llvm-readobj -h %t | FileCheck %s --check-prefixes=ALL,KNOWN-ABI-VERSION,SINGLE-FLAG --match-full-lines -DABI_VERSION=0 -DFILE=%t -DFLAG_NAME=EF_AMDGPU_MACH_AMDGCN_GFX1010 -DFLAG_VALUE=0x33
 
Index: llvm/test/tools/llvm-objdump/ELF/AMDGPU/subtarget.ll
===
--- llvm/test/tools/llvm-objdump/ELF/AMDGPU/subtarget.ll
+++ llvm/test/tools/llvm-objdump/ELF/AMDGPU/subtarget.ll
@@ -85,6 +85,11 @@
 
 ; --GFX9---
 ;
+; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx942 -filetype=obj -O0 -o %t.o %s
+; RUN: llvm-objdump -D --arch-name=amdgcn --mcpu=gfx942 %t.o > %t-specify.txt
+; RUN: llvm-objdump -D %t.o > %t-detect.txt
+; RUN: diff %t-specify.txt %t-detect.txt
+
 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx941 -filetype=obj -O0 -o

  1   2   >