[clang] 11ba795 - [clang][Interp][NFC] Add sanity checks to This op

2024-04-08 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2024-04-09T07:55:37+02:00
New Revision: 11ba795565c231a95a7e34bb0e4dff099234c736

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

LOG: [clang][Interp][NFC] Add sanity checks to This op

The instance pointer must be casted to the right base.

Added: 


Modified: 
clang/lib/AST/Interp/Interp.h

Removed: 




diff  --git a/clang/lib/AST/Interp/Interp.h b/clang/lib/AST/Interp/Interp.h
index fe5da47d9027c8..3dc223f97a8cce 100644
--- a/clang/lib/AST/Interp/Interp.h
+++ b/clang/lib/AST/Interp/Interp.h
@@ -1846,6 +1846,15 @@ inline bool This(InterpState , CodePtr OpPC) {
   if (!CheckThis(S, OpPC, This))
 return false;
 
+  // Ensure the This pointer has been cast to the correct base.
+  if (!This.isDummy()) {
+assert(isa(S.Current->getFunction()->getDecl()));
+assert(This.getRecord());
+assert(
+This.getRecord()->getDecl() ==
+cast(S.Current->getFunction()->getDecl())->getParent());
+  }
+
   S.Stk.push(This);
   return true;
 }



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


[clang] acff0b0 - [clang][Interp][NFC] Improve Record debugging

2024-04-08 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2024-04-09T07:55:36+02:00
New Revision: acff0b03167f877f783d9386014e1ebc20db1c2f

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

LOG: [clang][Interp][NFC] Improve Record debugging

Add Record::dump() and return the diagnostic name from getName()

Added: 


Modified: 
clang/lib/AST/Interp/Disasm.cpp
clang/lib/AST/Interp/Record.cpp
clang/lib/AST/Interp/Record.h

Removed: 




diff  --git a/clang/lib/AST/Interp/Disasm.cpp b/clang/lib/AST/Interp/Disasm.cpp
index 01ef1c24744a58..022b394e58e643 100644
--- a/clang/lib/AST/Interp/Disasm.cpp
+++ b/clang/lib/AST/Interp/Disasm.cpp
@@ -233,3 +233,34 @@ LLVM_DUMP_METHOD void InterpFrame::dump(llvm::raw_ostream 
,
 F = F->Caller;
   }
 }
+
+LLVM_DUMP_METHOD void Record::dump(llvm::raw_ostream , unsigned Indentation,
+   unsigned Offset) const {
+  unsigned Indent = Indentation * 2;
+  OS.indent(Indent);
+  {
+ColorScope SC(OS, true, {llvm::raw_ostream::BLUE, true});
+OS << getName() << "\n";
+  }
+
+  unsigned I = 0;
+  for (const Record::Base  : bases()) {
+OS.indent(Indent) << "- Base " << I << ". Offset " << (Offset + B.Offset)
+  << "\n";
+B.R->dump(OS, Indentation + 1, Offset + B.Offset);
+++I;
+  }
+
+  // FIXME: Virtual bases.
+
+  I = 0;
+  for (const Record::Field  : fields()) {
+OS.indent(Indent) << "- Field " << I << ": ";
+{
+  ColorScope SC(OS, true, {llvm::raw_ostream::BRIGHT_RED, true});
+  OS << F.Decl->getName();
+}
+OS << ". Offset " << (Offset + F.Offset) << "\n";
+++I;
+  }
+}

diff  --git a/clang/lib/AST/Interp/Record.cpp b/clang/lib/AST/Interp/Record.cpp
index 909416e6e1a1a5..6a0a28bc9124bc 100644
--- a/clang/lib/AST/Interp/Record.cpp
+++ b/clang/lib/AST/Interp/Record.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "Record.h"
+#include "clang/AST/ASTContext.h"
 
 using namespace clang;
 using namespace clang::interp;
@@ -27,6 +28,14 @@ Record::Record(const RecordDecl *Decl, BaseList &,
 VirtualBaseMap[V.Decl] = 
 }
 
+const std::string Record::getName() const {
+  std::string Ret;
+  llvm::raw_string_ostream OS(Ret);
+  Decl->getNameForDiagnostic(OS, Decl->getASTContext().getPrintingPolicy(),
+ /*Qualified=*/true);
+  return Ret;
+}
+
 const Record::Field *Record::getField(const FieldDecl *FD) const {
   auto It = FieldMap.find(FD);
   assert(It != FieldMap.end() && "Missing field");

diff  --git a/clang/lib/AST/Interp/Record.h b/clang/lib/AST/Interp/Record.h
index a6bde01062531b..cf0480b3f62fa6 100644
--- a/clang/lib/AST/Interp/Record.h
+++ b/clang/lib/AST/Interp/Record.h
@@ -51,7 +51,7 @@ class Record final {
   /// Returns the underlying declaration.
   const RecordDecl *getDecl() const { return Decl; }
   /// Returns the name of the underlying declaration.
-  const std::string getName() const { return Decl->getNameAsString(); }
+  const std::string getName() const;
   /// Checks if the record is a union.
   bool isUnion() const { return getDecl()->isUnion(); }
   /// Returns the size of the record.
@@ -100,6 +100,10 @@ class Record final {
   unsigned getNumVirtualBases() const { return VirtualBases.size(); }
   const Base *getVirtualBase(unsigned I) const { return [I]; }
 
+  void dump(llvm::raw_ostream , unsigned Indentation = 0,
+unsigned Offset = 0) const;
+  void dump() const { dump(llvm::errs()); }
+
 private:
   /// Constructor used by Program to create record descriptors.
   Record(const RecordDecl *, BaseList &, FieldList &,



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


[clang] 5d1f779 - [clang][Interp][NFC] Add Dump debug op

2024-04-08 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2024-04-09T07:55:36+02:00
New Revision: 5d1f779540517f47abb4927f4ded51cac94fd366

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

LOG: [clang][Interp][NFC] Add Dump debug op

This is often useful for debugging and dumps the current stack
contents.

Added: 


Modified: 
clang/lib/AST/Interp/Interp.h
clang/lib/AST/Interp/Opcodes.td

Removed: 




diff  --git a/clang/lib/AST/Interp/Interp.h b/clang/lib/AST/Interp/Interp.h
index 405993eb827036..fe5da47d9027c8 100644
--- a/clang/lib/AST/Interp/Interp.h
+++ b/clang/lib/AST/Interp/Interp.h
@@ -1333,6 +1333,11 @@ inline bool FinishInit(InterpState , CodePtr OpPC) {
   return true;
 }
 
+inline bool Dump(InterpState , CodePtr OpPC) {
+  S.Stk.dump();
+  return true;
+}
+
 inline bool VirtBaseHelper(InterpState , CodePtr OpPC, const RecordDecl 
*Decl,
const Pointer ) {
   Pointer Base = Ptr;

diff  --git a/clang/lib/AST/Interp/Opcodes.td b/clang/lib/AST/Interp/Opcodes.td
index cc1310f4c0d52a..6e79a03203d276 100644
--- a/clang/lib/AST/Interp/Opcodes.td
+++ b/clang/lib/AST/Interp/Opcodes.td
@@ -723,3 +723,8 @@ def CheckNonNullArg : Opcode {
 }
 
 def Memcpy : Opcode;
+
+//===--===//
+// Debugging.
+//===--===//
+def Dump : Opcode;



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


[clang] [Clang] [C++26] Implement P2573R2: `= delete("should have a reason");` (PR #86526)

2024-04-08 Thread via cfe-commits

Sirraide wrote:

I’ve also added a parser test for that as well just now.

https://github.com/llvm/llvm-project/pull/86526
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] [C++26] Implement P2573R2: `= delete("should have a reason");` (PR #86526)

2024-04-08 Thread via cfe-commits

Sirraide wrote:

> I wanted to make you aware of this new core issue 
> https://cplusplus.github.io/CWG/issues/2876.html (which i think we should 
> have tests for). Thanks

So, as of now, this
```c++
using T = void ();
using U = int;

T a = delete ("hello");
U b = delete ("hello"), c, d = delete ("hello");

struct C {
T e = delete ("hello");
U f = delete ("hello");
};
```
gives
```
test.cc:4:7: error: only functions can have deleted definitions
4 | T a = delete ("hello");
  |   ^
test.cc:5:7: error: only functions can have deleted definitions
5 | U b = delete ("hello"), c, d = delete ("hello");
  |   ^
test.cc:5:32: error: only functions can have deleted definitions
5 | U b = delete ("hello"), c, d = delete ("hello");
  |^
test.cc:8:8: error: '= delete' is a function definition and must occur in a 
standalone declaration
8 | T e = delete ("hello");
  |   ^
test.cc:9:8: error: cannot delete expression of type 'const char[6]'
9 | U f = delete ("hello");
  |   ^  ~
```
which seems reasonable to me—unless there’s something I’m missing here, but 
it’s ill-formed either way, so so long as we’re diagnosing it, we’re fine, from 
what I can tell at least.

One thing I did just now is made sure we discard the `("message")` if we 
encounter `= delete` in a place where it doesn’t belong so we don’t issue two 
errors instead of one (there was a ‘missing semicolon at end of declaration’ 
error that imo is just noise in this context).

https://github.com/llvm/llvm-project/pull/86526
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] c7db450 - [clang][NFC] Refactor `EvaluateBinaryTypeTrait` to accept `TypeSourceInfo`

2024-04-08 Thread Vlad Serebrennikov via cfe-commits

Author: Vlad Serebrennikov
Date: 2024-04-09T08:51:36+03:00
New Revision: c7db450e5c1a83ea768765dcdedfd50f3358d418

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

LOG: [clang][NFC] Refactor `EvaluateBinaryTypeTrait` to accept `TypeSourceInfo`

Some type traits issue diagnostics that would benefit from additional source 
location information.

Added: 


Modified: 
clang/lib/Sema/SemaExprCXX.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 901c3c4d00cfb4..dee6b658cd0054 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -5566,8 +5566,8 @@ static bool EvaluateUnaryTypeTrait(Sema , TypeTrait 
UTT,
   }
 }
 
-static bool EvaluateBinaryTypeTrait(Sema , TypeTrait BTT, QualType LhsT,
-QualType RhsT, SourceLocation KeyLoc);
+static bool EvaluateBinaryTypeTrait(Sema , TypeTrait BTT, const 
TypeSourceInfo *Lhs,
+const TypeSourceInfo *Rhs, SourceLocation 
KeyLoc);
 
 static bool EvaluateBooleanTypeTrait(Sema , TypeTrait Kind,
  SourceLocation KWLoc,
@@ -5583,8 +5583,8 @@ static bool EvaluateBooleanTypeTrait(Sema , TypeTrait 
Kind,
   // Evaluate ReferenceBindsToTemporary and ReferenceConstructsFromTemporary
   // alongside the IsConstructible traits to avoid duplication.
   if (Kind <= BTT_Last && Kind != BTT_ReferenceBindsToTemporary && Kind != 
BTT_ReferenceConstructsFromTemporary)
-return EvaluateBinaryTypeTrait(S, Kind, Args[0]->getType(),
-   Args[1]->getType(), RParenLoc);
+return EvaluateBinaryTypeTrait(S, Kind, Args[0],
+   Args[1], RParenLoc);
 
   switch (Kind) {
   case clang::BTT_ReferenceBindsToTemporary:
@@ -5679,8 +5679,8 @@ static bool EvaluateBooleanTypeTrait(Sema , TypeTrait 
Kind,
   if (U->isReferenceType())
 return false;
 
-  QualType TPtr = S.Context.getPointerType(S.BuiltinRemoveReference(T, 
UnaryTransformType::RemoveCVRef, {}));
-  QualType UPtr = S.Context.getPointerType(S.BuiltinRemoveReference(U, 
UnaryTransformType::RemoveCVRef, {}));
+  TypeSourceInfo *TPtr = 
S.Context.CreateTypeSourceInfo(S.Context.getPointerType(S.BuiltinRemoveReference(T,
 UnaryTransformType::RemoveCVRef, {})));
+  TypeSourceInfo *UPtr = 
S.Context.CreateTypeSourceInfo(S.Context.getPointerType(S.BuiltinRemoveReference(U,
 UnaryTransformType::RemoveCVRef, {})));
   return EvaluateBinaryTypeTrait(S, TypeTrait::BTT_IsConvertibleTo, UPtr, 
TPtr, RParenLoc);
 }
 
@@ -5814,8 +5814,11 @@ ExprResult Sema::ActOnTypeTrait(TypeTrait Kind, 
SourceLocation KWLoc,
   return BuildTypeTrait(Kind, KWLoc, ConvertedArgs, RParenLoc);
 }
 
-static bool EvaluateBinaryTypeTrait(Sema , TypeTrait BTT, QualType LhsT,
-QualType RhsT, SourceLocation KeyLoc) {
+static bool EvaluateBinaryTypeTrait(Sema , TypeTrait BTT, const 
TypeSourceInfo *Lhs,
+const TypeSourceInfo *Rhs, SourceLocation 
KeyLoc) {
+  QualType LhsT = Lhs->getType();
+  QualType RhsT = Rhs->getType();
+
   assert(!LhsT->isDependentType() && !RhsT->isDependentType() &&
  "Cannot evaluate traits of dependent types");
 



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


[clang] [llvm] [PowerPC] Tune AIX shared library TLS model at function level by heuristic (PR #84132)

2024-04-08 Thread Felix via cfe-commits

https://github.com/orcguru deleted 
https://github.com/llvm/llvm-project/pull/84132
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [PowerPC] Tune AIX shared library TLS model at function level by heuristic (PR #84132)

2024-04-08 Thread Felix via cfe-commits


@@ -3369,6 +3369,59 @@ SDValue 
PPCTargetLowering::LowerGlobalTLSAddressAIX(SDValue Op,
   bool Is64Bit = Subtarget.isPPC64();
   bool HasAIXSmallLocalExecTLS = Subtarget.hasAIXSmallLocalExecTLS();
   TLSModel::Model Model = getTargetMachine().getTLSModel(GV);
+  // Initialize TLS model opt setting lazily:

orcguru wrote:

Sure. Created static function guarded by `Subtarget.hasAIXShLibTLSModelOpt()`. 
Thank you for the suggestion!

https://github.com/llvm/llvm-project/pull/84132
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [PowerPC] Tune AIX shared library TLS model at function level by heuristic (PR #84132)

2024-04-08 Thread Felix via cfe-commits


@@ -3369,6 +3369,59 @@ SDValue 
PPCTargetLowering::LowerGlobalTLSAddressAIX(SDValue Op,
   bool Is64Bit = Subtarget.isPPC64();
   bool HasAIXSmallLocalExecTLS = Subtarget.hasAIXSmallLocalExecTLS();
   TLSModel::Model Model = getTargetMachine().getTLSModel(GV);
+  // Initialize TLS model opt setting lazily:

orcguru wrote:

Sure. Created static function guarded by `Subtarget.hasAIXShLibTLSModelOpt()`. 
Thank you for the suggestion!

https://github.com/llvm/llvm-project/pull/84132
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] d412047 - [clang][Interp] Fix "Initializing" zero-size arrays

2024-04-08 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2024-04-09T07:04:35+02:00
New Revision: d4120477130a5f9e472753068dcc627baddc44f6

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

LOG: [clang][Interp] Fix "Initializing" zero-size arrays

getIndex() returns 0 here, so we were trying to initalize the 0th
element.

Fixes #88018

Added: 


Modified: 
clang/lib/AST/Interp/Pointer.cpp
clang/test/AST/Interp/arrays.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/Pointer.cpp 
b/clang/lib/AST/Interp/Pointer.cpp
index af60ced0e10e9e..53998cc3233c94 100644
--- a/clang/lib/AST/Interp/Pointer.cpp
+++ b/clang/lib/AST/Interp/Pointer.cpp
@@ -177,6 +177,10 @@ void Pointer::initialize() const {
 if (isStatic() && Base == 0)
   return;
 
+// Nothing to do for these.
+if (Desc->getNumElems() == 0)
+  return;
+
 InitMapPtr  = getInitMap();
 if (!IM)
   IM =

diff  --git a/clang/test/AST/Interp/arrays.cpp 
b/clang/test/AST/Interp/arrays.cpp
index 2443992f75fb7d..607d67bde020c0 100644
--- a/clang/test/AST/Interp/arrays.cpp
+++ b/clang/test/AST/Interp/arrays.cpp
@@ -566,3 +566,7 @@ char melchizedek[22];
 typedef decltype(melchizedek[1] - melchizedek[0]) ptr
diff _t;
 constexpr ptr
diff _t d1 = [0x7fff] - [0]; // ok
 constexpr ptr
diff _t d3 = [0] - [0x8000u]; // ok
+
+/// GH#88018
+const int SZA[] = {};
+void testZeroSizedArrayAccess() { unsigned c = SZA[4]; }



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


[clang] 62e9257 - Revert "Rework the printing of attributes (#87281)"

2024-04-08 Thread Vassil Vassilev via cfe-commits

Author: Vassil Vassilev
Date: 2024-04-09T05:03:34Z
New Revision: 62e92573d28d62ab7e6438ac34d513b07c51ce09

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

LOG: Revert "Rework the printing of attributes (#87281)"

This reverts commit a30662fc2acdd73ca1a9217716299a4676999fb4 due to bot 
failures.

Added: 


Modified: 
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/CMakeLists.txt
clang/lib/AST/DeclPrinter.cpp
clang/lib/AST/StmtPrinter.cpp
clang/test/AST/ast-print-method-decl.cpp
clang/test/AST/ast-print-no-sanitize.cpp
clang/test/AST/attr-print-emit.cpp
clang/test/Analysis/scopes-cfg-output.cpp
clang/test/OpenMP/assumes_codegen.cpp
clang/test/OpenMP/assumes_print.cpp
clang/test/OpenMP/assumes_template_print.cpp
clang/test/OpenMP/declare_simd_ast_print.cpp
clang/test/SemaCXX/attr-no-sanitize.cpp
clang/test/SemaCXX/cxx11-attr-print.cpp
clang/utils/TableGen/ClangAttrEmitter.cpp
clang/utils/TableGen/TableGen.cpp
clang/utils/TableGen/TableGenBackends.h

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index dc87a8c6f022dc..6584460cf5685e 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -324,10 +324,13 @@ class Spelling {
 }
 
 class GNU : Spelling;
-class Declspec : Spelling;
+class Declspec : Spelling {
+  bit PrintOnLeft = 1;
+}
 class Microsoft : Spelling;
 class CXX11
 : Spelling {
+  bit CanPrintOnLeft = 0;
   string Namespace = namespace;
 }
 class C23
@@ -593,6 +596,12 @@ class AttrSubjectMatcherAggregateRule 
{
 def SubjectMatcherForNamed : AttrSubjectMatcherAggregateRule;
 
 class Attr {
+  // Specifies that when printed, this attribute is meaningful on the
+  // 'left side' of the declaration.
+  bit CanPrintOnLeft = 1;
+  // Specifies that when printed, this attribute is required to be printed on
+  // the 'left side' of the declaration.
+  bit PrintOnLeft = 0;
   // The various ways in which an attribute can be spelled in source
   list Spellings;
   // The things to which an attribute can appertain
@@ -928,6 +937,7 @@ def AVRSignal : InheritableAttr, 
TargetSpecificAttr {
 }
 
 def AsmLabel : InheritableAttr {
+  let CanPrintOnLeft = 0;
   let Spellings = [CustomKeyword<"asm">, CustomKeyword<"__asm__">];
   let Args = [
 // Label specifies the mangled name for the decl.
@@ -1524,6 +1534,7 @@ def AllocSize : InheritableAttr {
 }
 
 def EnableIf : InheritableAttr {
+  let CanPrintOnLeft = 0;
   // Does not have a [[]] spelling because this attribute requires the ability
   // to parse function arguments but the attribute is not written in the type
   // position.
@@ -3160,6 +3171,7 @@ def Unavailable : InheritableAttr {
 }
 
 def DiagnoseIf : InheritableAttr {
+  let CanPrintOnLeft = 0;
   // Does not have a [[]] spelling because this attribute requires the ability
   // to parse function arguments but the attribute is not written in the type
   // position.

diff  --git a/clang/include/clang/Basic/CMakeLists.txt 
b/clang/include/clang/Basic/CMakeLists.txt
index 2ef6ddc68f4bf3..7d53c751c13ac4 100644
--- a/clang/include/clang/Basic/CMakeLists.txt
+++ b/clang/include/clang/Basic/CMakeLists.txt
@@ -31,6 +31,16 @@ clang_tablegen(AttrList.inc -gen-clang-attr-list
   SOURCE Attr.td
   TARGET ClangAttrList)
 
+clang_tablegen(AttrLeftSideCanPrintList.inc -gen-clang-attr-can-print-left-list
+  -I ${CMAKE_CURRENT_SOURCE_DIR}/../../
+  SOURCE Attr.td
+  TARGET ClangAttrCanPrintLeftList)
+
+clang_tablegen(AttrLeftSideMustPrintList.inc 
-gen-clang-attr-must-print-left-list
+  -I ${CMAKE_CURRENT_SOURCE_DIR}/../../
+  SOURCE Attr.td
+  TARGET ClangAttrMustPrintLeftList)
+
 clang_tablegen(AttrSubMatchRulesList.inc 
-gen-clang-attr-subject-match-rule-list
   -I ${CMAKE_CURRENT_SOURCE_DIR}/../../
   SOURCE Attr.td

diff  --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index 0d03288a491ab5..edbcdfe4d55bc9 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/lib/AST/DeclPrinter.cpp
@@ -21,7 +21,6 @@
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/PrettyPrinter.h"
 #include "clang/Basic/Module.h"
-#include "clang/Basic/SourceManager.h"
 #include "llvm/Support/raw_ostream.h"
 using namespace clang;
 
@@ -50,6 +49,18 @@ namespace {
 
 void PrintObjCTypeParams(ObjCTypeParamList *Params);
 
+enum class AttrPrintLoc {
+  None = 0,
+  Left = 1,
+  Right = 2,
+  Any = Left | Right,
+
+  LLVM_MARK_AS_BITMASK_ENUM(/*DefaultValue=*/Any)
+};
+
+void prettyPrintAttributes(Decl *D, raw_ostream ,
+   AttrPrintLoc loc = AttrPrintLoc::Any);
+
   public:
 DeclPrinter(raw_ostream , const PrintingPolicy ,
 const ASTContext , 

[clang] [AST][RecoveryExpr] Fix a crash on c89/c90 invalid InitListExpr (#88008) (PR #88014)

2024-04-08 Thread Ding Fei via cfe-commits

https://github.com/danix800 updated 
https://github.com/llvm/llvm-project/pull/88014

>From fbd0780923d40b0d8290280731239a722a7af7a9 Mon Sep 17 00:00:00 2001
From: dingfei 
Date: Tue, 9 Apr 2024 00:26:03 +0800
Subject: [PATCH 1/2] [AST][RecoveryExpr] Fix a crash on c89/c90 invalid
 InitListExpr (#88008)

Use refactored CheckForConstantInitializer() to skip checking expr with error.
---
 clang/include/clang/Sema/Sema.h   |  2 +-
 clang/lib/Sema/SemaDecl.cpp   | 28 ---
 clang/lib/Sema/SemaExpr.cpp   |  3 +-
 .../test/Sema/recover-expr-gh88008-nocrash.c  | 11 
 4 files changed, 25 insertions(+), 19 deletions(-)
 create mode 100644 clang/test/Sema/recover-expr-gh88008-nocrash.c

diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 56d66a4486e0e7..452ccdda868b55 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -3391,7 +3391,7 @@ class Sema final : public SemaBase {
   bool ConstexprSupported, bool CLinkageMayDiffer);
 
   /// type checking declaration initializers (C99 6.7.8)
-  bool CheckForConstantInitializer(Expr *e, QualType t);
+  bool CheckForConstantInitializer(Expr *Init, unsigned DiagID);
 
   QualType deduceVarTypeFromInitializer(VarDecl *VDecl, DeclarationName Name,
 QualType Type, TypeSourceInfo *TSI,
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index c790dab72dd721..a516cff166fd67 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -12769,7 +12769,7 @@ void Sema::DiagnoseHLSLAttrStageMismatch(
   << (AllowedStages.size() != 1) << join(StageStrings, ", ");
 }
 
-bool Sema::CheckForConstantInitializer(Expr *Init, QualType DclT) {
+bool Sema::CheckForConstantInitializer(Expr *Init, unsigned DiagID) {
   // FIXME: Need strict checking.  In C89, we need to check for
   // any assignment, increment, decrement, function-calls, or
   // commas outside of a sizeof.  In C99, it's the same list,
@@ -12787,8 +12787,7 @@ bool Sema::CheckForConstantInitializer(Expr *Init, 
QualType DclT) {
   const Expr *Culprit;
   if (Init->isConstantInitializer(Context, false, ))
 return false;
-  Diag(Culprit->getExprLoc(), diag::err_init_element_not_constant)
-<< Culprit->getSourceRange();
+  Diag(Culprit->getExprLoc(), DiagID) << Culprit->getSourceRange();
   return true;
 }
 
@@ -13906,29 +13905,24 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr 
*Init, bool DirectInit) {
 // OpenCL v1.2 s6.5.3: __constant locals must be constant-initialized.
 // This is true even in C++ for OpenCL.
 } else if (VDecl->getType().getAddressSpace() == LangAS::opencl_constant) {
-  CheckForConstantInitializer(Init, DclT);
+  CheckForConstantInitializer(Init, diag::err_init_element_not_constant);
 
-// Otherwise, C++ does not restrict the initializer.
+  // Otherwise, C++ does not restrict the initializer.
 } else if (getLangOpts().CPlusPlus) {
   // do nothing
 
 // C99 6.7.8p4: All the expressions in an initializer for an object that 
has
 // static storage duration shall be constant expressions or string 
literals.
 } else if (VDecl->getStorageClass() == SC_Static) {
-  CheckForConstantInitializer(Init, DclT);
+  CheckForConstantInitializer(Init, diag::err_init_element_not_constant);
 
-// C89 is stricter than C99 for aggregate initializers.
-// C89 6.5.7p3: All the expressions [...] in an initializer list
-// for an object that has aggregate or union type shall be
-// constant expressions.
+  // C89 is stricter than C99 for aggregate initializers.
+  // C89 6.5.7p3: All the expressions [...] in an initializer list
+  // for an object that has aggregate or union type shall be
+  // constant expressions.
 } else if (!getLangOpts().C99 && VDecl->getType()->isAggregateType() &&
isa(Init)) {
-  const Expr *Culprit;
-  if (!Init->isConstantInitializer(Context, false, )) {
-Diag(Culprit->getExprLoc(),
- diag::ext_aggregate_init_not_constant)
-  << Culprit->getSourceRange();
-  }
+  CheckForConstantInitializer(Init, diag::ext_aggregate_init_not_constant);
 }
 
 if (auto *E = dyn_cast(Init))
@@ -14061,7 +14055,7 @@ void Sema::AddInitializerToDecl(Decl *RealDecl, Expr 
*Init, bool DirectInit) {
 // Avoid duplicate diagnostics for constexpr variables.
 if (!getLangOpts().CPlusPlus && !VDecl->isInvalidDecl() &&
 !VDecl->isConstexpr())
-  CheckForConstantInitializer(Init, DclT);
+  CheckForConstantInitializer(Init, diag::err_init_element_not_constant);
   }
 
   QualType InitType = Init->getType();
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 8db4fffeecfe35..2016d2eb08e0ff 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -7898,7 +7898,8 @@ 

[clang] 5c056b3 - [clang-format] Clean up unit tests from commit 13be0d4a34c4

2024-04-08 Thread Owen Pan via cfe-commits

Author: Owen Pan
Date: 2024-04-08T21:20:18-07:00
New Revision: 5c056b32350e834924356b1af78504d261d24e42

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

LOG: [clang-format] Clean up unit tests from commit 13be0d4a34c4

- Use 1-parameter verifyFormat() to verify formatted input in LLVM style.
- Pass string literal instead of constructed StringRef to verifyFormat().
- Don't include trailing newlines if not needed.

Added: 


Modified: 
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 91a8ff11889d6f..71450f433cec88 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -7977,39 +7977,37 @@ TEST_F(FormatTest, 
AllowAllArgumentsOnNextLineDontAlign) {
 }
 
 TEST_F(FormatTest, BreakFunctionDefinitionParameters) {
-  FormatStyle Style = getLLVMStyle();
-  EXPECT_FALSE(Style.BreakFunctionDefinitionParameters);
   StringRef Input = "void functionDecl(paramA, paramB, paramC);\n"
 "void emptyFunctionDefinition() {}\n"
 "void functionDefinition(int A, int B, int C) {}\n"
-"Class::Class(int A, int B) : m_A(A), m_B(B) {}\n";
-  verifyFormat(StringRef("void functionDecl(paramA, paramB, paramC);\n"
- "void emptyFunctionDefinition() {}\n"
- "void functionDefinition(int A, int B, int C) {}\n"
- "Class::Class(int A, int B) : m_A(A), m_B(B) {}\n"),
-   Input, Style);
+"Class::Class(int A, int B) : m_A(A), m_B(B) {}";
+  verifyFormat(Input);
+
+  FormatStyle Style = getLLVMStyle();
+  EXPECT_FALSE(Style.BreakFunctionDefinitionParameters);
   Style.BreakFunctionDefinitionParameters = true;
-  verifyFormat(StringRef("void functionDecl(paramA, paramB, paramC);\n"
- "void emptyFunctionDefinition() {}\n"
- "void functionDefinition(\n"
- "int A, int B, int C) {}\n"
- "Class::Class(\n"
- "int A, int B)\n"
- ": m_A(A), m_B(B) {}\n"),
+  verifyFormat("void functionDecl(paramA, paramB, paramC);\n"
+   "void emptyFunctionDefinition() {}\n"
+   "void functionDefinition(\n"
+   "int A, int B, int C) {}\n"
+   "Class::Class(\n"
+   "int A, int B)\n"
+   ": m_A(A), m_B(B) {}",
Input, Style);
-  // Test the style where all parameters are on their own lines
+
+  // Test the style where all parameters are on their own lines.
   Style.AllowAllParametersOfDeclarationOnNextLine = false;
   Style.BinPackParameters = false;
-  verifyFormat(StringRef("void functionDecl(paramA, paramB, paramC);\n"
- "void emptyFunctionDefinition() {}\n"
- "void functionDefinition(\n"
- "int A,\n"
- "int B,\n"
- "int C) {}\n"
- "Class::Class(\n"
- "int A,\n"
- "int B)\n"
- ": m_A(A), m_B(B) {}\n"),
+  verifyFormat("void functionDecl(paramA, paramB, paramC);\n"
+   "void emptyFunctionDefinition() {}\n"
+   "void functionDefinition(\n"
+   "int A,\n"
+   "int B,\n"
+   "int C) {}\n"
+   "Class::Class(\n"
+   "int A,\n"
+   "int B)\n"
+   ": m_A(A), m_B(B) {}",
Input, Style);
 }
 



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


[clang] Rework the printing of attributes (PR #87281)

2024-04-08 Thread Vassil Vassilev via cfe-commits

https://github.com/vgvassilev closed 
https://github.com/llvm/llvm-project/pull/87281
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] a30662f - Rework the printing of attributes (#87281)

2024-04-08 Thread via cfe-commits

Author: Vassil Vassilev
Date: 2024-04-09T07:14:43+03:00
New Revision: a30662fc2acdd73ca1a9217716299a4676999fb4

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

LOG: Rework the printing of attributes (#87281)

Commit https://github.com/llvm/llvm-project/commit/46f3ade introduced a
notion of printing the attributes on the left to improve the printing of
attributes attached to variable declarations. The intent was to produce
more GCC compatible code because clang tends to print the attributes on
the right hand side which is not accepted by gcc.

This approach has increased the complexity in tablegen and the
attrubutes themselves as now the are supposed to know where they could
appear. That lead to mishandling of the `override` keyword which is
modelled as an attribute in clang.

This patch takes an inspiration from the existing approach and tries to
keep the position of the attributes as they were written. To do so we
use simpler heuristic which checks if the source locations of the
attribute precedes the declaration. If so, it is considered to be
printed before the declaration.

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

Added: 


Modified: 
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/CMakeLists.txt
clang/lib/AST/DeclPrinter.cpp
clang/lib/AST/StmtPrinter.cpp
clang/test/AST/ast-print-method-decl.cpp
clang/test/AST/ast-print-no-sanitize.cpp
clang/test/AST/attr-print-emit.cpp
clang/test/Analysis/scopes-cfg-output.cpp
clang/test/OpenMP/assumes_codegen.cpp
clang/test/OpenMP/assumes_print.cpp
clang/test/OpenMP/assumes_template_print.cpp
clang/test/OpenMP/declare_simd_ast_print.cpp
clang/test/SemaCXX/attr-no-sanitize.cpp
clang/test/SemaCXX/cxx11-attr-print.cpp
clang/utils/TableGen/ClangAttrEmitter.cpp
clang/utils/TableGen/TableGen.cpp
clang/utils/TableGen/TableGenBackends.h

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 6584460cf5685e..dc87a8c6f022dc 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -324,13 +324,10 @@ class Spelling {
 }
 
 class GNU : Spelling;
-class Declspec : Spelling {
-  bit PrintOnLeft = 1;
-}
+class Declspec : Spelling;
 class Microsoft : Spelling;
 class CXX11
 : Spelling {
-  bit CanPrintOnLeft = 0;
   string Namespace = namespace;
 }
 class C23
@@ -596,12 +593,6 @@ class AttrSubjectMatcherAggregateRule 
{
 def SubjectMatcherForNamed : AttrSubjectMatcherAggregateRule;
 
 class Attr {
-  // Specifies that when printed, this attribute is meaningful on the
-  // 'left side' of the declaration.
-  bit CanPrintOnLeft = 1;
-  // Specifies that when printed, this attribute is required to be printed on
-  // the 'left side' of the declaration.
-  bit PrintOnLeft = 0;
   // The various ways in which an attribute can be spelled in source
   list Spellings;
   // The things to which an attribute can appertain
@@ -937,7 +928,6 @@ def AVRSignal : InheritableAttr, 
TargetSpecificAttr {
 }
 
 def AsmLabel : InheritableAttr {
-  let CanPrintOnLeft = 0;
   let Spellings = [CustomKeyword<"asm">, CustomKeyword<"__asm__">];
   let Args = [
 // Label specifies the mangled name for the decl.
@@ -1534,7 +1524,6 @@ def AllocSize : InheritableAttr {
 }
 
 def EnableIf : InheritableAttr {
-  let CanPrintOnLeft = 0;
   // Does not have a [[]] spelling because this attribute requires the ability
   // to parse function arguments but the attribute is not written in the type
   // position.
@@ -3171,7 +3160,6 @@ def Unavailable : InheritableAttr {
 }
 
 def DiagnoseIf : InheritableAttr {
-  let CanPrintOnLeft = 0;
   // Does not have a [[]] spelling because this attribute requires the ability
   // to parse function arguments but the attribute is not written in the type
   // position.

diff  --git a/clang/include/clang/Basic/CMakeLists.txt 
b/clang/include/clang/Basic/CMakeLists.txt
index 7d53c751c13ac4..2ef6ddc68f4bf3 100644
--- a/clang/include/clang/Basic/CMakeLists.txt
+++ b/clang/include/clang/Basic/CMakeLists.txt
@@ -31,16 +31,6 @@ clang_tablegen(AttrList.inc -gen-clang-attr-list
   SOURCE Attr.td
   TARGET ClangAttrList)
 
-clang_tablegen(AttrLeftSideCanPrintList.inc -gen-clang-attr-can-print-left-list
-  -I ${CMAKE_CURRENT_SOURCE_DIR}/../../
-  SOURCE Attr.td
-  TARGET ClangAttrCanPrintLeftList)
-
-clang_tablegen(AttrLeftSideMustPrintList.inc 
-gen-clang-attr-must-print-left-list
-  -I ${CMAKE_CURRENT_SOURCE_DIR}/../../
-  SOURCE Attr.td
-  TARGET ClangAttrMustPrintLeftList)
-
 clang_tablegen(AttrSubMatchRulesList.inc 
-gen-clang-attr-subject-match-rule-list
   -I ${CMAKE_CURRENT_SOURCE_DIR}/../../
   SOURCE Attr.td

diff  --git a/clang/lib/AST/DeclPrinter.cpp 

[clang] [ASTMatchers] fix captureVars assertion failure on capturesVariables (PR #76619)

2024-04-08 Thread Ding Fei via cfe-commits

danix800 wrote:

> LGTM but please add a release note so users know about the bug fix.

Release note added.

https://github.com/llvm/llvm-project/pull/76619
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ASTMatchers] fix captureVars assertion failure on capturesVariables (PR #76619)

2024-04-08 Thread Ding Fei via cfe-commits

https://github.com/danix800 updated 
https://github.com/llvm/llvm-project/pull/76619

>From 0ca1a2b2573d1f89a1b4d13cd43628a46c1e5c98 Mon Sep 17 00:00:00 2001
From: dingfei 
Date: Sun, 31 Dec 2023 00:32:01 +0800
Subject: [PATCH] [ASTMatchers] fix captureVars assertion failure on
 capturesVariables

Matcher 'capturesVar' should check for capturesVariables() before
calling getCaptureVar() since it asserts this LambdaCapture does capture
a variable.

Fixes #76425
---
 clang/docs/ReleaseNotes.rst | 1 +
 clang/include/clang/ASTMatchers/ASTMatchers.h   | 2 ++
 clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp | 2 ++
 3 files changed, 5 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index abf15c8dc49d9e..8d9ccf789d9cb8 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -633,6 +633,7 @@ AST Matchers
 - Add ``isExplicitObjectMemberFunction``.
 - Fixed ``forEachArgumentWithParam`` and ``forEachArgumentWithParamType`` to
   not skip the explicit object parameter for operator calls.
+- Fixed captureVars assertion failure if not capturesVariables. (#GH76425)
 
 clang-format
 
diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h 
b/clang/include/clang/ASTMatchers/ASTMatchers.h
index 2f71053d030f68..8a2bbfff9e9e6b 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -4961,6 +4961,8 @@ AST_MATCHER_P(LambdaExpr, hasAnyCapture, 
internal::Matcher,
 /// capturesVar(hasName("x")) matches `x` and `x = 1`.
 AST_MATCHER_P(LambdaCapture, capturesVar, internal::Matcher,
   InnerMatcher) {
+  if (!Node.capturesVariable())
+return false;
   auto *capturedVar = Node.getCapturedVar();
   return capturedVar && InnerMatcher.matches(*capturedVar, Finder, Builder);
 }
diff --git a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
index 0edc65162fbe3f..b76627cb9be637 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -2321,6 +2321,8 @@ TEST_P(ASTMatchersTest, 
LambdaCaptureTest_BindsToCaptureOfVarDecl) {
   matches("int main() { int cc; auto f = [=](){ return cc; }; }", 
matcher));
   EXPECT_TRUE(
   matches("int main() { int cc; auto f = [&](){ return cc; }; }", 
matcher));
+  EXPECT_TRUE(matches(
+  "void f(int a) { int cc[a]; auto f = [&](){ return cc;}; }", matcher));
 }
 
 TEST_P(ASTMatchersTest, LambdaCaptureTest_BindsToCaptureWithInitializer) {

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


[clang] [clang] Introduce `SemaSYCL` (PR #88086)

2024-04-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Vlad Serebrennikov (Endilll)


Changes

This patch moves SYCL-related `Sema` functions into new `SemaSYCL` class, 
following the recent example of OpenACC and HLSL. This is a part of the effort 
to split `Sema`. Additional context can be found in #82217, #84184, #87634.

---
Full diff: https://github.com/llvm/llvm-project/pull/88086.diff


7 Files Affected:

- (modified) clang/include/clang/Sema/Sema.h (+7-48) 
- (added) clang/include/clang/Sema/SemaSYCL.h (+66) 
- (modified) clang/lib/Parse/ParseExpr.cpp (+3-2) 
- (modified) clang/lib/Sema/Sema.cpp (+4-2) 
- (modified) clang/lib/Sema/SemaExpr.cpp (-22) 
- (modified) clang/lib/Sema/SemaSYCL.cpp (+36-10) 
- (modified) clang/lib/Sema/TreeTransform.h (+3-1) 


``diff
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 9769d36900664c..e3e255a0dd76f8 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -184,6 +184,7 @@ class PseudoObjectExpr;
 class QualType;
 class SemaHLSL;
 class SemaOpenACC;
+class SemaSYCL;
 class StandardConversionSequence;
 class Stmt;
 class StringLiteral;
@@ -467,7 +468,6 @@ class Sema final : public SemaBase {
   // 37. Name Lookup for RISC-V Vector Intrinsic (SemaRISCVVectorLookup.cpp)
   // 38. CUDA (SemaCUDA.cpp)
   // 39. OpenMP Directives and Clauses (SemaOpenMP.cpp)
-  // 40. SYCL Constructs (SemaSYCL.cpp)
 
   /// \name Semantic Analysis
   /// Implementations are in Sema.cpp
@@ -974,6 +974,11 @@ class Sema final : public SemaBase {
 return *OpenACCPtr;
   }
 
+  SemaSYCL () {
+assert(SYCLPtr);
+return *SYCLPtr;
+  }
+
 protected:
   friend class Parser;
   friend class InitializationSequence;
@@ -1006,6 +1011,7 @@ class Sema final : public SemaBase {
 
   std::unique_ptr HLSLPtr;
   std::unique_ptr OpenACCPtr;
+  std::unique_ptr SYCLPtr;
 
   ///@}
 
@@ -5455,15 +5461,6 @@ class Sema final : public SemaBase {
   ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind);
   ExprResult ActOnIntegerConstant(SourceLocation Loc, uint64_t Val);
 
-  ExprResult BuildSYCLUniqueStableNameExpr(SourceLocation OpLoc,
-   SourceLocation LParen,
-   SourceLocation RParen,
-   TypeSourceInfo *TSI);
-  ExprResult ActOnSYCLUniqueStableNameExpr(SourceLocation OpLoc,
-   SourceLocation LParen,
-   SourceLocation RParen,
-   ParsedType ParsedTy);
-
   bool CheckLoopHintExpr(Expr *E, SourceLocation Loc);
 
   ExprResult ActOnNumericConstant(const Token , Scope *UDLScope = nullptr);
@@ -14516,44 +14513,6 @@ class Sema final : public SemaBase {
 OpenMPDirectiveKind CancelRegion);
 
   ///@}
-
-  //
-  //
-  // -
-  //
-  //
-
-  /// \name SYCL Constructs
-  /// Implementations are in SemaSYCL.cpp
-  ///@{
-
-public:
-  /// Creates a SemaDiagnosticBuilder that emits the diagnostic if the current
-  /// context is "used as device code".
-  ///
-  /// - If CurLexicalContext is a kernel function or it is known that the
-  ///   function will be emitted for the device, emits the diagnostics
-  ///   immediately.
-  /// - If CurLexicalContext is a function and we are compiling
-  ///   for the device, but we don't know that this function will be codegen'ed
-  ///   for devive yet, creates a diagnostic which is emitted if and when we
-  ///   realize that the function will be codegen'ed.
-  ///
-  /// Example usage:
-  ///
-  /// Diagnose __float128 type usage only from SYCL device code if the current
-  /// target doesn't support it
-  /// if (!S.Context.getTargetInfo().hasFloat128Type() &&
-  /// S.getLangOpts().SYCLIsDevice)
-  ///   SYCLDiagIfDeviceCode(Loc, diag::err_type_unsupported) << "__float128";
-  SemaDiagnosticBuilder SYCLDiagIfDeviceCode(SourceLocation Loc,
- unsigned DiagID);
-
-  void deepTypeCheckForSYCLDevice(SourceLocation UsedAt,
-  llvm::DenseSet Visited,
-  ValueDecl *DeclToCheck);
-
-  ///@}
 };
 
 DeductionFailureInfo
diff --git a/clang/include/clang/Sema/SemaSYCL.h 
b/clang/include/clang/Sema/SemaSYCL.h
new file mode 100644
index 00..93fc8c7d99a5e0
--- /dev/null
+++ b/clang/include/clang/Sema/SemaSYCL.h
@@ -0,0 +1,66 @@
+//===- SemaOpenACC.h 000- Semantic Analysis for SYCL constructs 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+/// \file
+/// This file declares 

[clang] [clang] Introduce `SemaSYCL` (PR #88086)

2024-04-08 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll created 
https://github.com/llvm/llvm-project/pull/88086

This patch moves SYCL-related `Sema` functions into new `SemaSYCL` class, 
following the recent example of OpenACC and HLSL. This is a part of the effort 
to split `Sema`. Additional context can be found in #82217, #84184, #87634.

>From 9a5c872a8cb7de103841538d251df2f4638a4f5e Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Tue, 9 Apr 2024 06:38:25 +0300
Subject: [PATCH] [clang] Introduce `SemaSYCL`

---
 clang/include/clang/Sema/Sema.h | 55 +++-
 clang/include/clang/Sema/SemaSYCL.h | 66 +
 clang/lib/Parse/ParseExpr.cpp   |  5 ++-
 clang/lib/Sema/Sema.cpp |  6 ++-
 clang/lib/Sema/SemaExpr.cpp | 22 --
 clang/lib/Sema/SemaSYCL.cpp | 46 +++-
 clang/lib/Sema/TreeTransform.h  |  4 +-
 7 files changed, 119 insertions(+), 85 deletions(-)
 create mode 100644 clang/include/clang/Sema/SemaSYCL.h

diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 9769d36900664c..e3e255a0dd76f8 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -184,6 +184,7 @@ class PseudoObjectExpr;
 class QualType;
 class SemaHLSL;
 class SemaOpenACC;
+class SemaSYCL;
 class StandardConversionSequence;
 class Stmt;
 class StringLiteral;
@@ -467,7 +468,6 @@ class Sema final : public SemaBase {
   // 37. Name Lookup for RISC-V Vector Intrinsic (SemaRISCVVectorLookup.cpp)
   // 38. CUDA (SemaCUDA.cpp)
   // 39. OpenMP Directives and Clauses (SemaOpenMP.cpp)
-  // 40. SYCL Constructs (SemaSYCL.cpp)
 
   /// \name Semantic Analysis
   /// Implementations are in Sema.cpp
@@ -974,6 +974,11 @@ class Sema final : public SemaBase {
 return *OpenACCPtr;
   }
 
+  SemaSYCL () {
+assert(SYCLPtr);
+return *SYCLPtr;
+  }
+
 protected:
   friend class Parser;
   friend class InitializationSequence;
@@ -1006,6 +1011,7 @@ class Sema final : public SemaBase {
 
   std::unique_ptr HLSLPtr;
   std::unique_ptr OpenACCPtr;
+  std::unique_ptr SYCLPtr;
 
   ///@}
 
@@ -5455,15 +5461,6 @@ class Sema final : public SemaBase {
   ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind);
   ExprResult ActOnIntegerConstant(SourceLocation Loc, uint64_t Val);
 
-  ExprResult BuildSYCLUniqueStableNameExpr(SourceLocation OpLoc,
-   SourceLocation LParen,
-   SourceLocation RParen,
-   TypeSourceInfo *TSI);
-  ExprResult ActOnSYCLUniqueStableNameExpr(SourceLocation OpLoc,
-   SourceLocation LParen,
-   SourceLocation RParen,
-   ParsedType ParsedTy);
-
   bool CheckLoopHintExpr(Expr *E, SourceLocation Loc);
 
   ExprResult ActOnNumericConstant(const Token , Scope *UDLScope = nullptr);
@@ -14516,44 +14513,6 @@ class Sema final : public SemaBase {
 OpenMPDirectiveKind CancelRegion);
 
   ///@}
-
-  //
-  //
-  // -
-  //
-  //
-
-  /// \name SYCL Constructs
-  /// Implementations are in SemaSYCL.cpp
-  ///@{
-
-public:
-  /// Creates a SemaDiagnosticBuilder that emits the diagnostic if the current
-  /// context is "used as device code".
-  ///
-  /// - If CurLexicalContext is a kernel function or it is known that the
-  ///   function will be emitted for the device, emits the diagnostics
-  ///   immediately.
-  /// - If CurLexicalContext is a function and we are compiling
-  ///   for the device, but we don't know that this function will be codegen'ed
-  ///   for devive yet, creates a diagnostic which is emitted if and when we
-  ///   realize that the function will be codegen'ed.
-  ///
-  /// Example usage:
-  ///
-  /// Diagnose __float128 type usage only from SYCL device code if the current
-  /// target doesn't support it
-  /// if (!S.Context.getTargetInfo().hasFloat128Type() &&
-  /// S.getLangOpts().SYCLIsDevice)
-  ///   SYCLDiagIfDeviceCode(Loc, diag::err_type_unsupported) << "__float128";
-  SemaDiagnosticBuilder SYCLDiagIfDeviceCode(SourceLocation Loc,
- unsigned DiagID);
-
-  void deepTypeCheckForSYCLDevice(SourceLocation UsedAt,
-  llvm::DenseSet Visited,
-  ValueDecl *DeclToCheck);
-
-  ///@}
 };
 
 DeductionFailureInfo
diff --git a/clang/include/clang/Sema/SemaSYCL.h 
b/clang/include/clang/Sema/SemaSYCL.h
new file mode 100644
index 00..93fc8c7d99a5e0
--- /dev/null
+++ b/clang/include/clang/Sema/SemaSYCL.h
@@ -0,0 +1,66 @@
+//===- SemaOpenACC.h 000- Semantic Analysis for SYCL constructs 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See 

[clang] [openmp] [Libomp] Place generated OpenMP headers into build resource directory (PR #88007)

2024-04-08 Thread Joseph Huber via cfe-commits

jhuber6 wrote:

> So the error is caused by your `c++` not supporting `__has_feature` 
> presumably. However I have no clue why that would happen due to this patch. I 
> believe in a few days @jdoerfert will flip the switch and we won't even allow 
> `libomptarget` to be built without using the runtimes support so this might 
> not be worth thinking about too hard.
> 
> Any suggestions for reproducing it?

Oh, I think I get it. We're adding the resource directory include to the 
include paths. This is not conflicting with the ones from GCC. Honestly we only 
need this for `ompt` stuff which I could just do directly I suppose.

https://github.com/llvm/llvm-project/pull/88007
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] instanceof is a keyword only in Java/JavaScript (PR #88085)

2024-04-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-format

Author: Owen Pan (owenca)


Changes

Fixes #87907.

---
Full diff: https://github.com/llvm/llvm-project/pull/88085.diff


2 Files Affected:

- (modified) clang/lib/Format/TokenAnnotator.cpp (+2-1) 
- (modified) clang/unittests/Format/TokenAnnotatorTest.cpp (+4) 


``diff
diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 9abd4282103b7b..628f70417866c3 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2354,7 +2354,8 @@ class AnnotatingParser {
 // Line.MightBeFunctionDecl can only be true after the parentheses of a
 // function declaration have been found. In this case, 'Current' is a
 // trailing token of this declaration and thus cannot be a name.
-if (Current.is(Keywords.kw_instanceof)) {
+if ((Style.isJavaScript() || Style.Language == FormatStyle::LK_Java) &&
+Current.is(Keywords.kw_instanceof)) {
   Current.setType(TT_BinaryOperator);
 } else if (isStartOfName(Current) &&
(!Line.MightBeFunctionDecl || Current.NestingLevel != 0)) {
diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index 5ba5e0fbd16f9e..e46a266ff36915 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -1769,6 +1769,10 @@ TEST_F(TokenAnnotatorTest, 
UnderstandsFunctionDeclarationNames) {
   EXPECT_TOKEN(Tokens[3], tok::identifier, TT_Unknown);
   EXPECT_TOKEN(Tokens[4], tok::l_paren, TT_FunctionTypeLParen);
 
+  Tokens = annotate("void instanceof();");
+  ASSERT_EQ(Tokens.size(), 6u);
+  EXPECT_TOKEN(Tokens[1], tok::identifier, TT_FunctionDeclarationName);
+
   Tokens = annotate("int iso_time(time_t);");
   ASSERT_EQ(Tokens.size(), 7u) << Tokens;
   EXPECT_TOKEN(Tokens[1], tok::identifier, TT_FunctionDeclarationName);

``




https://github.com/llvm/llvm-project/pull/88085
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] instanceof is a keyword only in Java/JavaScript (PR #88085)

2024-04-08 Thread Owen Pan via cfe-commits

https://github.com/owenca created 
https://github.com/llvm/llvm-project/pull/88085

Fixes #87907.

>From 0daef6caaac5d3779cda0d4cbbf9cd2514662b92 Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Mon, 8 Apr 2024 20:29:26 -0700
Subject: [PATCH] [clang-format] instanceof is a keyword only in
 Java/JavaScript

Fixes #87907.
---
 clang/lib/Format/TokenAnnotator.cpp   | 3 ++-
 clang/unittests/Format/TokenAnnotatorTest.cpp | 4 
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 9abd4282103b7b..628f70417866c3 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2354,7 +2354,8 @@ class AnnotatingParser {
 // Line.MightBeFunctionDecl can only be true after the parentheses of a
 // function declaration have been found. In this case, 'Current' is a
 // trailing token of this declaration and thus cannot be a name.
-if (Current.is(Keywords.kw_instanceof)) {
+if ((Style.isJavaScript() || Style.Language == FormatStyle::LK_Java) &&
+Current.is(Keywords.kw_instanceof)) {
   Current.setType(TT_BinaryOperator);
 } else if (isStartOfName(Current) &&
(!Line.MightBeFunctionDecl || Current.NestingLevel != 0)) {
diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index 5ba5e0fbd16f9e..e46a266ff36915 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -1769,6 +1769,10 @@ TEST_F(TokenAnnotatorTest, 
UnderstandsFunctionDeclarationNames) {
   EXPECT_TOKEN(Tokens[3], tok::identifier, TT_Unknown);
   EXPECT_TOKEN(Tokens[4], tok::l_paren, TT_FunctionTypeLParen);
 
+  Tokens = annotate("void instanceof();");
+  ASSERT_EQ(Tokens.size(), 6u);
+  EXPECT_TOKEN(Tokens[1], tok::identifier, TT_FunctionDeclarationName);
+
   Tokens = annotate("int iso_time(time_t);");
   ASSERT_EQ(Tokens.size(), 7u) << Tokens;
   EXPECT_TOKEN(Tokens[1], tok::identifier, TT_FunctionDeclarationName);

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


[clang] [openmp] [Libomp] Place generated OpenMP headers into build resource directory (PR #88007)

2024-04-08 Thread Joseph Huber via cfe-commits

jhuber6 wrote:

> Hey, @jhuber. This change broke the flang build.
> 
> When I revert the change, everything builds cleanly. So I reverted it in 
> merge request #88083.
> 
> After this change was added, I started getting messages like:
> 
> ```
> [4/205] Building CXX object 
> projects/openmp/libomptarget/plugins-nextgen/host/CMakeFiles/omptarget.rtl.x86_64.dir/dynamic_ffi/ffi.cpp.o
> FAILED: 
> projects/openmp/libomptarget/plugins-nextgen/host/CMakeFiles/omptarget.rtl.x86_64.dir/dynamic_ffi/ffi.cpp.o
>  
> /usr/bin/c++ -DDEBUG_PREFIX="\"TARGET x86_64 RTL\"" -DGTEST_HAS_RTTI=0 
> -DLIBOMPTARGET_NEXTGEN_GENERIC_PLUGIN_TRIPLE=\"x86_64-pc-linux-gnu\" 
> -DOMPT_SUPPORT=1 -DTARGET_ELF_ID=EM_X86_64 -DTARGET_NAME=x86_64 -D_DEBUG 
> -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS 
> -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
> -I/local/home/psteinfeld/up/build/projects/openmp/libomptarget/plugins-nextgen/host
>  
> -I/local/home/psteinfeld/up/llvm-project/openmp/libomptarget/plugins-nextgen/host
>  -I/local/home/psteinfeld/up/build/include 
> -I/local/home/psteinfeld/up/llvm-project/llvm/include 
> -I/local/home/psteinfeld/up/build/lib/clang/19/include 
> -I/local/home/psteinfeld/up/llvm-project/openmp/libomptarget/plugins-nextgen/host/dynamic_ffi
>  -I/local/home/psteinfeld/up/llvm-project/openmp/libomptarget/include 
> -I/local/home/psteinfeld/up/llvm-project/openmp/libomptarget/plugins-nextgen/common/include
>  -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden 
> -Werror=date-time -fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter 
> -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic 
> -Wno-long-long -Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull 
> -Wno-class-memaccess -Wno-noexcept-type -Wdelete-non-virtual-dtor 
> -Wno-comment -Wno-misleading-indentation -fdiagnostics-color 
> -ffunction-sections -fdata-sections -Wall -Wcast-qual -Wimplicit-fallthrough 
> -Wsign-compare -Wno-extra -Wno-pedantic -Wno-maybe-uninitialized 
> -fno-semantic-interposition -fdata-sections -O3 -DNDEBUG -std=c++17 -fPIC 
> -fvisibility=protected  -fno-exceptions -funwind-tables -fno-rtti 
> -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -fno-exceptions -fno-rtti 
> -MD -MT 
> projects/openmp/libomptarget/plugins-nextgen/host/CMakeFiles/omptarget.rtl.x86_64.dir/dynamic_ffi/ffi.cpp.o
>  -MF 
> projects/openmp/libomptarget/plugins-nextgen/host/CMakeFiles/omptarget.rtl.x86_64.dir/dynamic_ffi/ffi.cpp.o.d
>  -o 
> projects/openmp/libomptarget/plugins-nextgen/host/CMakeFiles/omptarget.rtl.x86_64.dir/dynamic_ffi/ffi.cpp.o
>  -c 
> /local/home/psteinfeld/up/llvm-project/openmp/libomptarget/plugins-nextgen/host/dynamic_ffi/ffi.cpp
> In file included from /usr/include/wchar.h:35,
>  from /usr/include/c++/8/cwchar:44,
>  from /usr/include/c++/8/bits/postypes.h:40,
>  from /usr/include/c++/8/bits/char_traits.h:40,
>  from /usr/include/c++/8/string:40,
>  from 
> /local/home/psteinfeld/up/llvm-project/llvm/include/llvm/Support/DynamicLibrary.h:16,
>  from 
> /local/home/psteinfeld/up/llvm-project/openmp/libomptarget/plugins-nextgen/host/dynamic_ffi/ffi.cpp:13:
> /local/home/psteinfeld/up/build/lib/clang/19/include/stddef.h:31:42: error: 
> missing binary operator before token "("
>  #if !defined(__STDDEF_H) || __has_feature(modules) ||
>   \
>   ^
> In file included from /usr/include/wchar.h:38,
>  from /usr/include/c++/8/cwchar:44,
>  from /usr/include/c++/8/bits/postypes.h:40,
>  from /usr/include/c++/8/bits/char_traits.h:40,
>  from /usr/include/c++/8/string:40,
>  from 
> /local/home/psteinfeld/up/llvm-project/llvm/include/llvm/Support/DynamicLibrary.h:16,
>  from 
> /local/home/psteinfeld/up/llvm-project/openmp/libomptarget/plugins-nextgen/host/dynamic_ffi/ffi.cpp:13:
> /local/home/psteinfeld/up/build/lib/clang/19/include/stdarg.h:31:42: error: 
> missing binary operator before token "("
> ```

In any case, the `flang` bot is going to need to be changed very soon if this 
is an error so I would recommend pinging whoever's in charge of that. The 
recommended method is `LLVM_ENABLE_RUNTIMES=openmp`.

https://github.com/llvm/llvm-project/pull/88007
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [openmp] Revert "[Libomp] Place generated OpenMP headers into build resource d… (PR #88083)

2024-04-08 Thread Pete Steinfeld via cfe-commits

https://github.com/psteinfeld closed 
https://github.com/llvm/llvm-project/pull/88083
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 25e3d2b - Revert "[Libomp] Place generated OpenMP headers into build resource d… (#88083)

2024-04-08 Thread via cfe-commits

Author: Pete Steinfeld
Date: 2024-04-08T20:20:27-07:00
New Revision: 25e3d2b0fc1e2b4df19d7f18fbdd04c154e1d0e8

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

LOG: Revert "[Libomp] Place generated OpenMP headers into build resource d… 
(#88083)

…irectory (#88007)"

This reverts commit 8671429151d5e67d3f21a737809953ae8bdfbfde.

This commit broke the flang build, so I'm reverting it. See the comments
in merge request #88007 for more information.

Added: 


Modified: 
clang/test/Headers/Inputs/include/stdint.h
openmp/runtime/src/CMakeLists.txt

Removed: 




diff  --git a/clang/test/Headers/Inputs/include/stdint.h 
b/clang/test/Headers/Inputs/include/stdint.h
index 67b27b8dfc7b92..5bf26a7b67b066 100644
--- a/clang/test/Headers/Inputs/include/stdint.h
+++ b/clang/test/Headers/Inputs/include/stdint.h
@@ -16,12 +16,4 @@ typedef unsigned __INTPTR_TYPE__ uintptr_t;
 #error Every target should have __INTPTR_TYPE__
 #endif
 
-#ifdef __INTPTR_MAX__
-#define  INTPTR_MAX__INTPTR_MAX__
-#endif
-
-#ifdef __UINTPTR_MAX__
-#define UINTPTR_MAX   __UINTPTR_MAX__
-#endif
-
 #endif /* STDINT_H */

diff  --git a/openmp/runtime/src/CMakeLists.txt 
b/openmp/runtime/src/CMakeLists.txt
index 000d02c33dc093..f05bcabb441742 100644
--- a/openmp/runtime/src/CMakeLists.txt
+++ b/openmp/runtime/src/CMakeLists.txt
@@ -10,19 +10,12 @@
 
 include(ExtendPath)
 
-# The generated headers will be placed in clang's resource directory if 
present.
-if(${OPENMP_STANDALONE_BUILD})
-  set(LIBOMP_HEADERS_INTDIR ${CMAKE_CURRENT_BINARY_DIR})
-else()
-  set(LIBOMP_HEADERS_INTDIR ${LLVM_BINARY_DIR}/${LIBOMP_HEADERS_INSTALL_PATH})
-endif()
-
 # Configure omp.h, kmp_config.h and omp-tools.h if necessary
-configure_file(${LIBOMP_INC_DIR}/omp.h.var ${LIBOMP_HEADERS_INTDIR}/omp.h 
@ONLY)
-configure_file(${LIBOMP_INC_DIR}/ompx.h.var ${LIBOMP_HEADERS_INTDIR}/ompx.h 
@ONLY)
-configure_file(kmp_config.h.cmake ${LIBOMP_HEADERS_INTDIR}/kmp_config.h @ONLY)
+configure_file(${LIBOMP_INC_DIR}/omp.h.var omp.h @ONLY)
+configure_file(${LIBOMP_INC_DIR}/ompx.h.var ompx.h @ONLY)
+configure_file(kmp_config.h.cmake kmp_config.h @ONLY)
 if(${LIBOMP_OMPT_SUPPORT})
-  configure_file(${LIBOMP_INC_DIR}/omp-tools.h.var 
${LIBOMP_HEADERS_INTDIR}/omp-tools.h @ONLY)
+  configure_file(${LIBOMP_INC_DIR}/omp-tools.h.var omp-tools.h @ONLY)
 endif()
 
 # Generate message catalog files: kmp_i18n_id.inc and kmp_i18n_default.inc
@@ -426,15 +419,15 @@ else()
 endif()
 install(
   FILES
-  ${LIBOMP_HEADERS_INTDIR}/omp.h
-  ${LIBOMP_HEADERS_INTDIR}/ompx.h
+  ${CMAKE_CURRENT_BINARY_DIR}/omp.h
+  ${CMAKE_CURRENT_BINARY_DIR}/ompx.h
   DESTINATION ${LIBOMP_HEADERS_INSTALL_PATH}
 )
 if(${LIBOMP_OMPT_SUPPORT})
-  install(FILES ${LIBOMP_HEADERS_INTDIR}/omp-tools.h DESTINATION 
${LIBOMP_HEADERS_INSTALL_PATH})
+  install(FILES ${CMAKE_CURRENT_BINARY_DIR}/omp-tools.h DESTINATION 
${LIBOMP_HEADERS_INSTALL_PATH})
   # install under legacy name ompt.h
-  install(FILES ${LIBOMP_HEADERS_INTDIR}/omp-tools.h DESTINATION 
${LIBOMP_HEADERS_INSTALL_PATH} RENAME ompt.h)
-  set(LIBOMP_OMP_TOOLS_INCLUDE_DIR ${LIBOMP_HEADERS_INTDIR} PARENT_SCOPE)
+  install(FILES ${CMAKE_CURRENT_BINARY_DIR}/omp-tools.h DESTINATION 
${LIBOMP_HEADERS_INSTALL_PATH} RENAME ompt.h)
+  set(LIBOMP_OMP_TOOLS_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)
 endif()
 if(${BUILD_FORTRAN_MODULES})
   set (destination ${LIBOMP_HEADERS_INSTALL_PATH})



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


[clang] [openmp] [Libomp] Place generated OpenMP headers into build resource directory (PR #88007)

2024-04-08 Thread Joseph Huber via cfe-commits

jhuber6 wrote:

> Hey, @jhuber. This change broke the flang build.
> 
> When I revert the change, everything builds cleanly. So I reverted it in 
> merge request #88083.
> 
> After this change was added, I started getting messages like:
> 
> ```
> [4/205] Building CXX object 
> projects/openmp/libomptarget/plugins-nextgen/host/CMakeFiles/omptarget.rtl.x86_64.dir/dynamic_ffi/ffi.cpp.o
> FAILED: 
> projects/openmp/libomptarget/plugins-nextgen/host/CMakeFiles/omptarget.rtl.x86_64.dir/dynamic_ffi/ffi.cpp.o
>  
> /usr/bin/c++ -DDEBUG_PREFIX="\"TARGET x86_64 RTL\"" -DGTEST_HAS_RTTI=0 
> -DLIBOMPTARGET_NEXTGEN_GENERIC_PLUGIN_TRIPLE=\"x86_64-pc-linux-gnu\" 
> -DOMPT_SUPPORT=1 -DTARGET_ELF_ID=EM_X86_64 -DTARGET_NAME=x86_64 -D_DEBUG 
> -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS 
> -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
> -I/local/home/psteinfeld/up/build/projects/openmp/libomptarget/plugins-nextgen/host
>  
> -I/local/home/psteinfeld/up/llvm-project/openmp/libomptarget/plugins-nextgen/host
>  -I/local/home/psteinfeld/up/build/include 
> -I/local/home/psteinfeld/up/llvm-project/llvm/include 
> -I/local/home/psteinfeld/up/build/lib/clang/19/include 
> -I/local/home/psteinfeld/up/llvm-project/openmp/libomptarget/plugins-nextgen/host/dynamic_ffi
>  -I/local/home/psteinfeld/up/llvm-project/openmp/libomptarget/include 
> -I/local/home/psteinfeld/up/llvm-project/openmp/libomptarget/plugins-nextgen/common/include
>  -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden 
> -Werror=date-time -fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter 
> -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic 
> -Wno-long-long -Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull 
> -Wno-class-memaccess -Wno-noexcept-type -Wdelete-non-virtual-dtor 
> -Wno-comment -Wno-misleading-indentation -fdiagnostics-color 
> -ffunction-sections -fdata-sections -Wall -Wcast-qual -Wimplicit-fallthrough 
> -Wsign-compare -Wno-extra -Wno-pedantic -Wno-maybe-uninitialized 
> -fno-semantic-interposition -fdata-sections -O3 -DNDEBUG -std=c++17 -fPIC 
> -fvisibility=protected  -fno-exceptions -funwind-tables -fno-rtti 
> -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -fno-exceptions -fno-rtti 
> -MD -MT 
> projects/openmp/libomptarget/plugins-nextgen/host/CMakeFiles/omptarget.rtl.x86_64.dir/dynamic_ffi/ffi.cpp.o
>  -MF 
> projects/openmp/libomptarget/plugins-nextgen/host/CMakeFiles/omptarget.rtl.x86_64.dir/dynamic_ffi/ffi.cpp.o.d
>  -o 
> projects/openmp/libomptarget/plugins-nextgen/host/CMakeFiles/omptarget.rtl.x86_64.dir/dynamic_ffi/ffi.cpp.o
>  -c 
> /local/home/psteinfeld/up/llvm-project/openmp/libomptarget/plugins-nextgen/host/dynamic_ffi/ffi.cpp
> In file included from /usr/include/wchar.h:35,
>  from /usr/include/c++/8/cwchar:44,
>  from /usr/include/c++/8/bits/postypes.h:40,
>  from /usr/include/c++/8/bits/char_traits.h:40,
>  from /usr/include/c++/8/string:40,
>  from 
> /local/home/psteinfeld/up/llvm-project/llvm/include/llvm/Support/DynamicLibrary.h:16,
>  from 
> /local/home/psteinfeld/up/llvm-project/openmp/libomptarget/plugins-nextgen/host/dynamic_ffi/ffi.cpp:13:
> /local/home/psteinfeld/up/build/lib/clang/19/include/stddef.h:31:42: error: 
> missing binary operator before token "("
>  #if !defined(__STDDEF_H) || __has_feature(modules) ||
>   \
>   ^
> In file included from /usr/include/wchar.h:38,
>  from /usr/include/c++/8/cwchar:44,
>  from /usr/include/c++/8/bits/postypes.h:40,
>  from /usr/include/c++/8/bits/char_traits.h:40,
>  from /usr/include/c++/8/string:40,
>  from 
> /local/home/psteinfeld/up/llvm-project/llvm/include/llvm/Support/DynamicLibrary.h:16,
>  from 
> /local/home/psteinfeld/up/llvm-project/openmp/libomptarget/plugins-nextgen/host/dynamic_ffi/ffi.cpp:13:
> /local/home/psteinfeld/up/build/lib/clang/19/include/stdarg.h:31:42: error: 
> missing binary operator before token "("
> ```

So the error is caused by your `c++` not supporting `__has_feature` presumably. 
However I have no clue why that would happen due to this patch. I believe in a 
few days @jdoerfert will flip the switch and we won't even allow `libomptarget` 
to be built without using the runtimes support so this might not be worth 
thinking about too hard.

Any suggestions for reproducing it?

https://github.com/llvm/llvm-project/pull/88007
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] Fix "[clang][UBSan] Add implicit conversion check for bitfields" (PR #87761)

2024-04-08 Thread Haonan Yang via cfe-commits

https://github.com/haonanya edited 
https://github.com/llvm/llvm-project/pull/87761
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [openmp] [Libomp] Place generated OpenMP headers into build resource directory (PR #88007)

2024-04-08 Thread Pete Steinfeld via cfe-commits

psteinfeld wrote:

Hey, @jhuber.  This change broke the flang build.  

When I revert the change, everything builds cleanly.  So I reverted it in merge 
request 

After this change was added, I started getting messages like:
```
[4/205] Building CXX object 
projects/openmp/libomptarget/plugins-nextgen/host/CMakeFiles/omptarget.rtl.x86_64.dir/dynamic_ffi/ffi.cpp.o
FAILED: 
projects/openmp/libomptarget/plugins-nextgen/host/CMakeFiles/omptarget.rtl.x86_64.dir/dynamic_ffi/ffi.cpp.o
 
/usr/bin/c++ -DDEBUG_PREFIX="\"TARGET x86_64 RTL\"" -DGTEST_HAS_RTTI=0 
-DLIBOMPTARGET_NEXTGEN_GENERIC_PLUGIN_TRIPLE=\"x86_64-pc-linux-gnu\" 
-DOMPT_SUPPORT=1 -DTARGET_ELF_ID=EM_X86_64 -DTARGET_NAME=x86_64 -D_DEBUG 
-D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS 
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/local/home/psteinfeld/up/build/projects/openmp/libomptarget/plugins-nextgen/host
 
-I/local/home/psteinfeld/up/llvm-project/openmp/libomptarget/plugins-nextgen/host
 -I/local/home/psteinfeld/up/build/include 
-I/local/home/psteinfeld/up/llvm-project/llvm/include 
-I/local/home/psteinfeld/up/build/lib/clang/19/include 
-I/local/home/psteinfeld/up/llvm-project/openmp/libomptarget/plugins-nextgen/host/dynamic_ffi
 -I/local/home/psteinfeld/up/llvm-project/openmp/libomptarget/include 
-I/local/home/psteinfeld/up/llvm-project/openmp/libomptarget/plugins-nextgen/common/include
 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden 
-Werror=date-time -fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic 
-Wno-long-long -Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull 
-Wno-class-memaccess -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno-comment 
-Wno-misleading-indentation -fdiagnostics-color -ffunction-sections 
-fdata-sections -Wall -Wcast-qual -Wimplicit-fallthrough -Wsign-compare 
-Wno-extra -Wno-pedantic -Wno-maybe-uninitialized -fno-semantic-interposition 
-fdata-sections -O3 -DNDEBUG -std=c++17 -fPIC -fvisibility=protected  
-fno-exceptions -funwind-tables -fno-rtti -fno-exceptions -funwind-tables 
-fno-rtti -UNDEBUG -fno-exceptions -fno-rtti -MD -MT 
projects/openmp/libomptarget/plugins-nextgen/host/CMakeFiles/omptarget.rtl.x86_64.dir/dynamic_ffi/ffi.cpp.o
 -MF 
projects/openmp/libomptarget/plugins-nextgen/host/CMakeFiles/omptarget.rtl.x86_64.dir/dynamic_ffi/ffi.cpp.o.d
 -o 
projects/openmp/libomptarget/plugins-nextgen/host/CMakeFiles/omptarget.rtl.x86_64.dir/dynamic_ffi/ffi.cpp.o
 -c 
/local/home/psteinfeld/up/llvm-project/openmp/libomptarget/plugins-nextgen/host/dynamic_ffi/ffi.cpp
In file included from /usr/include/wchar.h:35,
 from /usr/include/c++/8/cwchar:44,
 from /usr/include/c++/8/bits/postypes.h:40,
 from /usr/include/c++/8/bits/char_traits.h:40,
 from /usr/include/c++/8/string:40,
 from 
/local/home/psteinfeld/up/llvm-project/llvm/include/llvm/Support/DynamicLibrary.h:16,
 from 
/local/home/psteinfeld/up/llvm-project/openmp/libomptarget/plugins-nextgen/host/dynamic_ffi/ffi.cpp:13:
/local/home/psteinfeld/up/build/lib/clang/19/include/stddef.h:31:42: error: 
missing binary operator before token "("
 #if !defined(__STDDEF_H) || __has_feature(modules) ||  
\
  ^
In file included from /usr/include/wchar.h:38,
 from /usr/include/c++/8/cwchar:44,
 from /usr/include/c++/8/bits/postypes.h:40,
 from /usr/include/c++/8/bits/char_traits.h:40,
 from /usr/include/c++/8/string:40,
 from 
/local/home/psteinfeld/up/llvm-project/llvm/include/llvm/Support/DynamicLibrary.h:16,
 from 
/local/home/psteinfeld/up/llvm-project/openmp/libomptarget/plugins-nextgen/host/dynamic_ffi/ffi.cpp:13:
/local/home/psteinfeld/up/build/lib/clang/19/include/stdarg.h:31:42: error: 
missing binary operator before token "("
```


https://github.com/llvm/llvm-project/pull/88007
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [openmp] Revert "[Libomp] Place generated OpenMP headers into build resource d… (PR #88083)

2024-04-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Pete Steinfeld (psteinfeld)


Changes

…irectory (#88007)"

This reverts commit 8671429151d5e67d3f21a737809953ae8bdfbfde.

This commit broke the flang build, so I'm reverting it.  See the comments in 
merge request #88007 for more information.

---
Full diff: https://github.com/llvm/llvm-project/pull/88083.diff


2 Files Affected:

- (modified) clang/test/Headers/Inputs/include/stdint.h (-8) 
- (modified) openmp/runtime/src/CMakeLists.txt (+9-16) 


``diff
diff --git a/clang/test/Headers/Inputs/include/stdint.h 
b/clang/test/Headers/Inputs/include/stdint.h
index 67b27b8dfc7b92..5bf26a7b67b066 100644
--- a/clang/test/Headers/Inputs/include/stdint.h
+++ b/clang/test/Headers/Inputs/include/stdint.h
@@ -16,12 +16,4 @@ typedef unsigned __INTPTR_TYPE__ uintptr_t;
 #error Every target should have __INTPTR_TYPE__
 #endif
 
-#ifdef __INTPTR_MAX__
-#define  INTPTR_MAX__INTPTR_MAX__
-#endif
-
-#ifdef __UINTPTR_MAX__
-#define UINTPTR_MAX   __UINTPTR_MAX__
-#endif
-
 #endif /* STDINT_H */
diff --git a/openmp/runtime/src/CMakeLists.txt 
b/openmp/runtime/src/CMakeLists.txt
index 000d02c33dc093..f05bcabb441742 100644
--- a/openmp/runtime/src/CMakeLists.txt
+++ b/openmp/runtime/src/CMakeLists.txt
@@ -10,19 +10,12 @@
 
 include(ExtendPath)
 
-# The generated headers will be placed in clang's resource directory if 
present.
-if(${OPENMP_STANDALONE_BUILD})
-  set(LIBOMP_HEADERS_INTDIR ${CMAKE_CURRENT_BINARY_DIR})
-else()
-  set(LIBOMP_HEADERS_INTDIR ${LLVM_BINARY_DIR}/${LIBOMP_HEADERS_INSTALL_PATH})
-endif()
-
 # Configure omp.h, kmp_config.h and omp-tools.h if necessary
-configure_file(${LIBOMP_INC_DIR}/omp.h.var ${LIBOMP_HEADERS_INTDIR}/omp.h 
@ONLY)
-configure_file(${LIBOMP_INC_DIR}/ompx.h.var ${LIBOMP_HEADERS_INTDIR}/ompx.h 
@ONLY)
-configure_file(kmp_config.h.cmake ${LIBOMP_HEADERS_INTDIR}/kmp_config.h @ONLY)
+configure_file(${LIBOMP_INC_DIR}/omp.h.var omp.h @ONLY)
+configure_file(${LIBOMP_INC_DIR}/ompx.h.var ompx.h @ONLY)
+configure_file(kmp_config.h.cmake kmp_config.h @ONLY)
 if(${LIBOMP_OMPT_SUPPORT})
-  configure_file(${LIBOMP_INC_DIR}/omp-tools.h.var 
${LIBOMP_HEADERS_INTDIR}/omp-tools.h @ONLY)
+  configure_file(${LIBOMP_INC_DIR}/omp-tools.h.var omp-tools.h @ONLY)
 endif()
 
 # Generate message catalog files: kmp_i18n_id.inc and kmp_i18n_default.inc
@@ -426,15 +419,15 @@ else()
 endif()
 install(
   FILES
-  ${LIBOMP_HEADERS_INTDIR}/omp.h
-  ${LIBOMP_HEADERS_INTDIR}/ompx.h
+  ${CMAKE_CURRENT_BINARY_DIR}/omp.h
+  ${CMAKE_CURRENT_BINARY_DIR}/ompx.h
   DESTINATION ${LIBOMP_HEADERS_INSTALL_PATH}
 )
 if(${LIBOMP_OMPT_SUPPORT})
-  install(FILES ${LIBOMP_HEADERS_INTDIR}/omp-tools.h DESTINATION 
${LIBOMP_HEADERS_INSTALL_PATH})
+  install(FILES ${CMAKE_CURRENT_BINARY_DIR}/omp-tools.h DESTINATION 
${LIBOMP_HEADERS_INSTALL_PATH})
   # install under legacy name ompt.h
-  install(FILES ${LIBOMP_HEADERS_INTDIR}/omp-tools.h DESTINATION 
${LIBOMP_HEADERS_INSTALL_PATH} RENAME ompt.h)
-  set(LIBOMP_OMP_TOOLS_INCLUDE_DIR ${LIBOMP_HEADERS_INTDIR} PARENT_SCOPE)
+  install(FILES ${CMAKE_CURRENT_BINARY_DIR}/omp-tools.h DESTINATION 
${LIBOMP_HEADERS_INSTALL_PATH} RENAME ompt.h)
+  set(LIBOMP_OMP_TOOLS_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)
 endif()
 if(${BUILD_FORTRAN_MODULES})
   set (destination ${LIBOMP_HEADERS_INSTALL_PATH})

``




https://github.com/llvm/llvm-project/pull/88083
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] Fix "[clang][UBSan] Add implicit conversion check for bitfields" (PR #87761)

2024-04-08 Thread Haonan Yang via cfe-commits

https://github.com/haonanya edited 
https://github.com/llvm/llvm-project/pull/87761
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [openmp] Revert "[Libomp] Place generated OpenMP headers into build resource d… (PR #88083)

2024-04-08 Thread Pete Steinfeld via cfe-commits

https://github.com/psteinfeld created 
https://github.com/llvm/llvm-project/pull/88083

…irectory (#88007)"

This reverts commit 8671429151d5e67d3f21a737809953ae8bdfbfde.

This commit broke the flang build, so I'm reverting it.  See the comments in 
merge request #88007 for more information.

>From e3e26a846a411a91c4537cffc08f293027488679 Mon Sep 17 00:00:00 2001
From: Peter Steinfeld 
Date: Mon, 8 Apr 2024 20:08:26 -0700
Subject: [PATCH] Revert "[Libomp] Place generated OpenMP headers into build
 resource directory (#88007)"

This reverts commit 8671429151d5e67d3f21a737809953ae8bdfbfde.

This commit broke the flang build, so I'm reverting it.  See the
comments in merge request #88007 for more information.
---
 clang/test/Headers/Inputs/include/stdint.h |  8 ---
 openmp/runtime/src/CMakeLists.txt  | 25 --
 2 files changed, 9 insertions(+), 24 deletions(-)

diff --git a/clang/test/Headers/Inputs/include/stdint.h 
b/clang/test/Headers/Inputs/include/stdint.h
index 67b27b8dfc7b92..5bf26a7b67b066 100644
--- a/clang/test/Headers/Inputs/include/stdint.h
+++ b/clang/test/Headers/Inputs/include/stdint.h
@@ -16,12 +16,4 @@ typedef unsigned __INTPTR_TYPE__ uintptr_t;
 #error Every target should have __INTPTR_TYPE__
 #endif
 
-#ifdef __INTPTR_MAX__
-#define  INTPTR_MAX__INTPTR_MAX__
-#endif
-
-#ifdef __UINTPTR_MAX__
-#define UINTPTR_MAX   __UINTPTR_MAX__
-#endif
-
 #endif /* STDINT_H */
diff --git a/openmp/runtime/src/CMakeLists.txt 
b/openmp/runtime/src/CMakeLists.txt
index 000d02c33dc093..f05bcabb441742 100644
--- a/openmp/runtime/src/CMakeLists.txt
+++ b/openmp/runtime/src/CMakeLists.txt
@@ -10,19 +10,12 @@
 
 include(ExtendPath)
 
-# The generated headers will be placed in clang's resource directory if 
present.
-if(${OPENMP_STANDALONE_BUILD})
-  set(LIBOMP_HEADERS_INTDIR ${CMAKE_CURRENT_BINARY_DIR})
-else()
-  set(LIBOMP_HEADERS_INTDIR ${LLVM_BINARY_DIR}/${LIBOMP_HEADERS_INSTALL_PATH})
-endif()
-
 # Configure omp.h, kmp_config.h and omp-tools.h if necessary
-configure_file(${LIBOMP_INC_DIR}/omp.h.var ${LIBOMP_HEADERS_INTDIR}/omp.h 
@ONLY)
-configure_file(${LIBOMP_INC_DIR}/ompx.h.var ${LIBOMP_HEADERS_INTDIR}/ompx.h 
@ONLY)
-configure_file(kmp_config.h.cmake ${LIBOMP_HEADERS_INTDIR}/kmp_config.h @ONLY)
+configure_file(${LIBOMP_INC_DIR}/omp.h.var omp.h @ONLY)
+configure_file(${LIBOMP_INC_DIR}/ompx.h.var ompx.h @ONLY)
+configure_file(kmp_config.h.cmake kmp_config.h @ONLY)
 if(${LIBOMP_OMPT_SUPPORT})
-  configure_file(${LIBOMP_INC_DIR}/omp-tools.h.var 
${LIBOMP_HEADERS_INTDIR}/omp-tools.h @ONLY)
+  configure_file(${LIBOMP_INC_DIR}/omp-tools.h.var omp-tools.h @ONLY)
 endif()
 
 # Generate message catalog files: kmp_i18n_id.inc and kmp_i18n_default.inc
@@ -426,15 +419,15 @@ else()
 endif()
 install(
   FILES
-  ${LIBOMP_HEADERS_INTDIR}/omp.h
-  ${LIBOMP_HEADERS_INTDIR}/ompx.h
+  ${CMAKE_CURRENT_BINARY_DIR}/omp.h
+  ${CMAKE_CURRENT_BINARY_DIR}/ompx.h
   DESTINATION ${LIBOMP_HEADERS_INSTALL_PATH}
 )
 if(${LIBOMP_OMPT_SUPPORT})
-  install(FILES ${LIBOMP_HEADERS_INTDIR}/omp-tools.h DESTINATION 
${LIBOMP_HEADERS_INSTALL_PATH})
+  install(FILES ${CMAKE_CURRENT_BINARY_DIR}/omp-tools.h DESTINATION 
${LIBOMP_HEADERS_INSTALL_PATH})
   # install under legacy name ompt.h
-  install(FILES ${LIBOMP_HEADERS_INTDIR}/omp-tools.h DESTINATION 
${LIBOMP_HEADERS_INSTALL_PATH} RENAME ompt.h)
-  set(LIBOMP_OMP_TOOLS_INCLUDE_DIR ${LIBOMP_HEADERS_INTDIR} PARENT_SCOPE)
+  install(FILES ${CMAKE_CURRENT_BINARY_DIR}/omp-tools.h DESTINATION 
${LIBOMP_HEADERS_INSTALL_PATH} RENAME ompt.h)
+  set(LIBOMP_OMP_TOOLS_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)
 endif()
 if(${BUILD_FORTRAN_MODULES})
   set (destination ${LIBOMP_HEADERS_INSTALL_PATH})

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


[clang] [compiler-rt] Fix "[clang][UBSan] Add implicit conversion check for bitfields" (PR #87761)

2024-04-08 Thread Haonan Yang via cfe-commits


@@ -0,0 +1,94 @@
+// RUN: %clang -x c++ -fsanitize=implicit-bitfield-conversion -target 
x86_64-linux -S -emit-llvm -o - %s | FileCheck %s 
--check-prefixes=CHECK,CHECK-BITFIELD-CONVERSION
+// RUN: %clang -x c++ -fsanitize=implicit-integer-conversion -target 
x86_64-linux -S -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK
+// RUN: %clang -x c++ -fsanitize=implicit-conversion -target x86_64-linux -S 
-emit-llvm -o - %s | FileCheck %s 
--check-prefixes=CHECK,CHECK-BITFIELD-CONVERSION
+
+struct S {
+  int a:3;
+  char b:2;
+};
+
+class C : public S {
+  public:
+short c:3;
+};
+
+S s;
+C c;
+
+// CHECK-LABEL: define{{.*}} void @{{.*foo1.*}}
+void foo1(int x) {
+  s.a = x;
+  // CHECK: store i8 %{{.*}}
+  // CHECK-BITFIELD-CONVERSION: [[BFRESULTSHL:%.*]] = shl i8 {{.*}}, 5
+  // CHECK-BITFIELD-CONVERSION-NEXT: [[BFRESULTASHR:%.*]] = ashr i8 
[[BFRESULTSHL]], 5
+  // CHECK-BITFIELD-CONVERSION-NEXT: [[BFRESULTCAST:%.*]] = sext i8 
[[BFRESULTASHR]] to i32
+  // CHECK-BITFIELD-CONVERSION: call void @__ubsan_handle_implicit_conversion
+  // CHECK-BITFIELD-CONVERSION-NEXT: br label %[[CONT:.*]], !nosanitize !6

haonanya wrote:

Is the check "!nosanitize !6" necessary? Are we sure it's always !6? Thanks 
very much.

https://github.com/llvm/llvm-project/pull/87761
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [mlir] [Offload][NFC] Remove `omp_` prefix from offloading entries (PR #88071)

2024-04-08 Thread Joseph Huber via cfe-commits

https://github.com/jhuber6 updated 
https://github.com/llvm/llvm-project/pull/88071

>From c94d444b4317706c7434853c0c3490826bdbc110 Mon Sep 17 00:00:00 2001
From: Joseph Huber 
Date: Mon, 8 Apr 2024 19:10:37 -0500
Subject: [PATCH] [Offload][NFC] Remove `omp_` prefix from offloading entries

Summary:
These entires are generic for offloading with the new driver now. Having
the `omp` prefix was a historical artifact and is confusing when used
for CUDA. This patch just renames them for now, future patches will
rework the binary format to make it more common.
---
 clang/test/CodeGenCUDA/offloading-entries.cu  | 82 +--
 .../OpenMP/declare_target_link_codegen.cpp| 10 +--
 .../declare_target_visibility_codegen.cpp |  8 +-
 .../OpenMP/target_codegen_registration.cpp| 48 +--
 clang/test/OpenMP/target_indirect_codegen.cpp |  8 +-
 llvm/lib/Frontend/Offloading/Utility.cpp  |  6 +-
 .../Frontend/OpenMPIRBuilderTest.cpp  | 10 +--
 .../omptarget-declare-target-llvm-host.mlir   | 60 +++---
 8 files changed, 116 insertions(+), 116 deletions(-)

diff --git a/clang/test/CodeGenCUDA/offloading-entries.cu 
b/clang/test/CodeGenCUDA/offloading-entries.cu
index 4f5cf65ecd0bde..ec21f018607ff0 100644
--- a/clang/test/CodeGenCUDA/offloading-entries.cu
+++ b/clang/test/CodeGenCUDA/offloading-entries.cu
@@ -1,4 +1,4 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-globals --global-value-regex ".omp_offloading.entry.*"
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-globals --global-value-regex ".offloading.entry.*"
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-linux-gnu -fgpu-rdc \
 // RUN:   --offload-new-driver -emit-llvm -o - -x cuda  %s | FileCheck \
 // RUN:   --check-prefix=CUDA %s
@@ -15,49 +15,49 @@
 #include "Inputs/cuda.h"
 
 //.
-// CUDA: @.omp_offloading.entry_name = internal unnamed_addr constant [8 x i8] 
c"_Z3foov\00"
-// CUDA: @.omp_offloading.entry._Z3foov = weak constant 
%struct.__tgt_offload_entry { ptr @_Z18__device_stub__foov, ptr 
@.omp_offloading.entry_name, i64 0, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
-// CUDA: @.omp_offloading.entry_name.1 = internal unnamed_addr constant [11 x 
i8] c"_Z6kernelv\00"
-// CUDA: @.omp_offloading.entry._Z6kernelv = weak constant 
%struct.__tgt_offload_entry { ptr @_Z21__device_stub__kernelv, ptr 
@.omp_offloading.entry_name.1, i64 0, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
-// CUDA: @.omp_offloading.entry_name.2 = internal unnamed_addr constant [4 x 
i8] c"var\00"
-// CUDA: @.omp_offloading.entry.var = weak constant 
%struct.__tgt_offload_entry { ptr @var, ptr @.omp_offloading.entry_name.2, i64 
4, i32 0, i32 0 }, section "cuda_offloading_entries", align 1
-// CUDA: @.omp_offloading.entry_name.3 = internal unnamed_addr constant [5 x 
i8] c"surf\00"
-// CUDA: @.omp_offloading.entry.surf = weak constant 
%struct.__tgt_offload_entry { ptr @surf, ptr @.omp_offloading.entry_name.3, i64 
4, i32 2, i32 1 }, section "cuda_offloading_entries", align 1
-// CUDA: @.omp_offloading.entry_name.4 = internal unnamed_addr constant [4 x 
i8] c"tex\00"
-// CUDA: @.omp_offloading.entry.tex = weak constant 
%struct.__tgt_offload_entry { ptr @tex, ptr @.omp_offloading.entry_name.4, i64 
4, i32 3, i32 1 }, section "cuda_offloading_entries", align 1
+// CUDA: @.offloading.entry_name = internal unnamed_addr constant [8 x i8] 
c"_Z3foov\00"
+// CUDA: @.offloading.entry._Z3foov = weak constant 
%struct.__tgt_offload_entry { ptr @_Z18__device_stub__foov, ptr 
@.offloading.entry_name, i64 0, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
+// CUDA: @.offloading.entry_name.1 = internal unnamed_addr constant [11 x i8] 
c"_Z6kernelv\00"
+// CUDA: @.offloading.entry._Z6kernelv = weak constant 
%struct.__tgt_offload_entry { ptr @_Z21__device_stub__kernelv, ptr 
@.offloading.entry_name.1, i64 0, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
+// CUDA: @.offloading.entry_name.2 = internal unnamed_addr constant [4 x i8] 
c"var\00"
+// CUDA: @.offloading.entry.var = weak constant %struct.__tgt_offload_entry { 
ptr @var, ptr @.offloading.entry_name.2, i64 4, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
+// CUDA: @.offloading.entry_name.3 = internal unnamed_addr constant [5 x i8] 
c"surf\00"
+// CUDA: @.offloading.entry.surf = weak constant %struct.__tgt_offload_entry { 
ptr @surf, ptr @.offloading.entry_name.3, i64 4, i32 2, i32 1 }, section 
"cuda_offloading_entries", align 1
+// CUDA: @.offloading.entry_name.4 = internal unnamed_addr constant [4 x i8] 
c"tex\00"
+// CUDA: @.offloading.entry.tex = weak constant %struct.__tgt_offload_entry { 
ptr @tex, ptr @.offloading.entry_name.4, i64 4, i32 3, i32 1 }, section 
"cuda_offloading_entries", align 1
 //.
-// HIP: @.omp_offloading.entry_name = internal unnamed_addr constant [8 x i8] 
c"_Z3foov\00"
-// HIP: 

[clang] [llvm] [AMDGPU] Add Clang builtins for amdgcn s_ttrace intrinsics (PR #88076)

2024-04-08 Thread Corbin Robeck via cfe-commits

https://github.com/CRobeck updated 
https://github.com/llvm/llvm-project/pull/88076

>From 1e2cab61cbf46e5cc73d7ee6523dcce1a75c7549 Mon Sep 17 00:00:00 2001
From: Corbin Robeck 
Date: Mon, 8 Apr 2024 19:58:57 -0500
Subject: [PATCH 1/3] add clang builtins for amdgcn s_ttrace intrinsics

---
 clang/include/clang/Basic/BuiltinsAMDGPU.def | 2 ++
 llvm/include/llvm/IR/IntrinsicsAMDGPU.td | 3 +++
 2 files changed, 5 insertions(+)

diff --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def 
b/clang/include/clang/Basic/BuiltinsAMDGPU.def
index c660582cc98e66..d2912d271d4005 100644
--- a/clang/include/clang/Basic/BuiltinsAMDGPU.def
+++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def
@@ -61,6 +61,8 @@ BUILTIN(__builtin_amdgcn_s_waitcnt, "vIi", "n")
 BUILTIN(__builtin_amdgcn_s_sendmsg, "vIiUi", "n")
 BUILTIN(__builtin_amdgcn_s_sendmsghalt, "vIiUi", "n")
 BUILTIN(__builtin_amdgcn_s_barrier, "v", "n")
+BUILTIN(__builtin_amdgcn_s_ttracedata, "v", "n")
+BUILTIN(__builtin_amdgcn_s_ttracedata_imm, "v", "n")
 BUILTIN(__builtin_amdgcn_wave_barrier, "v", "n")
 BUILTIN(__builtin_amdgcn_sched_barrier, "vIi", "n")
 BUILTIN(__builtin_amdgcn_sched_group_barrier, "vIiIiIi", "n")
diff --git a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td 
b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
index 6bbc13f1de86e2..ee9a5d7a343980 100644
--- a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
+++ b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
@@ -1887,9 +1887,12 @@ def int_amdgcn_s_setprio :
 IntrHasSideEffects]>;
 
 def int_amdgcn_s_ttracedata :
+  ClangBuiltin<"__builtin_amdgcn_s_ttracedata">,
   DefaultAttrsIntrinsic<[], [llvm_i32_ty],
 [IntrNoMem, IntrHasSideEffects]>;
+
 def int_amdgcn_s_ttracedata_imm :
+  ClangBuiltin<"__builtin_amdgcn_s_ttracedata_imm">,
   DefaultAttrsIntrinsic<[], [llvm_i16_ty],
 [IntrNoMem, IntrHasSideEffects, ImmArg>]>;
 

>From 8ad802d418ee9f2aea4a1ce56e3b67f750f59a4d Mon Sep 17 00:00:00 2001
From: Corbin Robeck 
Date: Mon, 8 Apr 2024 21:42:23 -0500
Subject: [PATCH 2/3] fix type issue

---
 clang/include/clang/Basic/BuiltinsAMDGPU.def  |  4 ++--
 .../CodeGenOpenCL/builtins-amdgcn-gfx12.cl| 21 +++
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def 
b/clang/include/clang/Basic/BuiltinsAMDGPU.def
index d2912d271d4005..302888adb47a17 100644
--- a/clang/include/clang/Basic/BuiltinsAMDGPU.def
+++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def
@@ -61,8 +61,8 @@ BUILTIN(__builtin_amdgcn_s_waitcnt, "vIi", "n")
 BUILTIN(__builtin_amdgcn_s_sendmsg, "vIiUi", "n")
 BUILTIN(__builtin_amdgcn_s_sendmsghalt, "vIiUi", "n")
 BUILTIN(__builtin_amdgcn_s_barrier, "v", "n")
-BUILTIN(__builtin_amdgcn_s_ttracedata, "v", "n")
-BUILTIN(__builtin_amdgcn_s_ttracedata_imm, "v", "n")
+BUILTIN(__builtin_amdgcn_s_ttracedata, "vi", "n")
+BUILTIN(__builtin_amdgcn_s_ttracedata_imm, "vIs", "n")
 BUILTIN(__builtin_amdgcn_wave_barrier, "v", "n")
 BUILTIN(__builtin_amdgcn_sched_barrier, "vIi", "n")
 BUILTIN(__builtin_amdgcn_sched_group_barrier, "vIiIiIi", "n")
diff --git a/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx12.cl 
b/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx12.cl
index ebd367bba0cdc1..61fdd9ae135033 100644
--- a/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx12.cl
+++ b/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx12.cl
@@ -235,3 +235,24 @@ unsigned test_s_get_barrier_state(int a)
   unsigned State = __builtin_amdgcn_s_get_barrier_state(a);
   return State;
 }
+
+// CHECK-LABEL: @test_s_ttracedata(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:call void @llvm.amdgcn.s.ttracedata()
+// CHECK-NEXT:ret void
+//
+void test_s_ttracedata()
+{
+  __builtin_amdgcn_s_ttracedata();
+}
+
+
+// CHECK-LABEL: @test_s_ttracedata_imm(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:call void @llvm.amdgcn.s.ttracedata_imm()
+// CHECK-NEXT:ret void
+//
+void test_s_ttracedata_imm()
+{
+  __builtin_amdgcn_s_ttracedata_imm();
+}

>From af4f8e63bc58e1e4ae1d532d55909659ed080aa1 Mon Sep 17 00:00:00 2001
From: Corbin Robeck 
Date: Mon, 8 Apr 2024 21:43:06 -0500
Subject: [PATCH 3/3] add ttrace builtin test

---
 clang/test/CodeGenOpenCL/builtins-amdgcn-gfx12.cl | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx12.cl 
b/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx12.cl
index 61fdd9ae135033..26c0ee48306237 100644
--- a/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx12.cl
+++ b/clang/test/CodeGenOpenCL/builtins-amdgcn-gfx12.cl
@@ -238,21 +238,22 @@ unsigned test_s_get_barrier_state(int a)
 
 // CHECK-LABEL: @test_s_ttracedata(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:call void @llvm.amdgcn.s.ttracedata()
+// CHECK-NEXT:call void @llvm.amdgcn.s.ttracedata(i32 1)
 // CHECK-NEXT:ret void
 //
 void test_s_ttracedata()
 {
-  __builtin_amdgcn_s_ttracedata();
+  __builtin_amdgcn_s_ttracedata(1);
 }
 
-
 // CHECK-LABEL: @test_s_ttracedata_imm(
 // CHECK-NEXT:  

[clang] [Clang] Reduce the size of Decl and classes derived from it (PR #87361)

2024-04-08 Thread Chuanqi Xu via cfe-commits


@@ -268,17 +268,34 @@ class alignas(8) Decl {
   ///   }
   ///   void A::f(); // SemanticDC == namespace 'A'
   ///// LexicalDC == global namespace
-  llvm::PointerUnion DeclCtx;
+  llvm::PointerIntPair<

ChuanqiXu9 wrote:

+1 for more comments. I spent more time to understand the structure here. Also 
maybe we can make the code self explained by:

```suggestion
using DeclCtxTy = llvm::PointerUnion;
using DeclCtxAndHasAttrTy = llvm::PointerIntPair, 1,
   bool>;
using DeclCtxAndHasAttrTyOrInvalidDeclTy = ...
```

https://github.com/llvm/llvm-project/pull/87361
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Sema] Fix the lambda call expression inside of a type alias declaration (PR #82310)

2024-04-08 Thread Younan Zhang via cfe-commits

zyn0217 wrote:

@jcsxky At the glance of the stacktrace, I suspect we probably need some 
mechanism of deferral codegen while instantiating the enclosing struct. Can you 
please file a separate issue?

https://github.com/llvm/llvm-project/pull/82310
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [Offload][NFC] Remove `omp_` prefix from offloading entries (PR #88071)

2024-04-08 Thread Joseph Huber via cfe-commits

https://github.com/jhuber6 updated 
https://github.com/llvm/llvm-project/pull/88071

>From 198e77ad14ff83d2ed9ea80a1dcecafa1b1336a0 Mon Sep 17 00:00:00 2001
From: Joseph Huber 
Date: Mon, 8 Apr 2024 19:10:37 -0500
Subject: [PATCH] [Offload][NFC] Remove `omp_` prefix from offloading entries

Summary:
These entires are generic for offloading with the new driver now. Having
the `omp` prefix was a historical artifact and is confusing when used
for CUDA. This patch just renames them for now, future patches will
rework the binary format to make it more common.
---
 clang/test/CodeGenCUDA/offloading-entries.cu  | 82 +--
 .../OpenMP/declare_target_link_codegen.cpp| 10 +--
 .../declare_target_visibility_codegen.cpp |  8 +-
 .../OpenMP/target_codegen_registration.cpp| 48 +--
 clang/test/OpenMP/target_indirect_codegen.cpp |  8 +-
 llvm/lib/Frontend/Offloading/Utility.cpp  |  6 +-
 .../Frontend/OpenMPIRBuilderTest.cpp  | 10 +--
 7 files changed, 86 insertions(+), 86 deletions(-)

diff --git a/clang/test/CodeGenCUDA/offloading-entries.cu 
b/clang/test/CodeGenCUDA/offloading-entries.cu
index 4f5cf65ecd0bde..ec21f018607ff0 100644
--- a/clang/test/CodeGenCUDA/offloading-entries.cu
+++ b/clang/test/CodeGenCUDA/offloading-entries.cu
@@ -1,4 +1,4 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-globals --global-value-regex ".omp_offloading.entry.*"
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-globals --global-value-regex ".offloading.entry.*"
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-linux-gnu -fgpu-rdc \
 // RUN:   --offload-new-driver -emit-llvm -o - -x cuda  %s | FileCheck \
 // RUN:   --check-prefix=CUDA %s
@@ -15,49 +15,49 @@
 #include "Inputs/cuda.h"
 
 //.
-// CUDA: @.omp_offloading.entry_name = internal unnamed_addr constant [8 x i8] 
c"_Z3foov\00"
-// CUDA: @.omp_offloading.entry._Z3foov = weak constant 
%struct.__tgt_offload_entry { ptr @_Z18__device_stub__foov, ptr 
@.omp_offloading.entry_name, i64 0, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
-// CUDA: @.omp_offloading.entry_name.1 = internal unnamed_addr constant [11 x 
i8] c"_Z6kernelv\00"
-// CUDA: @.omp_offloading.entry._Z6kernelv = weak constant 
%struct.__tgt_offload_entry { ptr @_Z21__device_stub__kernelv, ptr 
@.omp_offloading.entry_name.1, i64 0, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
-// CUDA: @.omp_offloading.entry_name.2 = internal unnamed_addr constant [4 x 
i8] c"var\00"
-// CUDA: @.omp_offloading.entry.var = weak constant 
%struct.__tgt_offload_entry { ptr @var, ptr @.omp_offloading.entry_name.2, i64 
4, i32 0, i32 0 }, section "cuda_offloading_entries", align 1
-// CUDA: @.omp_offloading.entry_name.3 = internal unnamed_addr constant [5 x 
i8] c"surf\00"
-// CUDA: @.omp_offloading.entry.surf = weak constant 
%struct.__tgt_offload_entry { ptr @surf, ptr @.omp_offloading.entry_name.3, i64 
4, i32 2, i32 1 }, section "cuda_offloading_entries", align 1
-// CUDA: @.omp_offloading.entry_name.4 = internal unnamed_addr constant [4 x 
i8] c"tex\00"
-// CUDA: @.omp_offloading.entry.tex = weak constant 
%struct.__tgt_offload_entry { ptr @tex, ptr @.omp_offloading.entry_name.4, i64 
4, i32 3, i32 1 }, section "cuda_offloading_entries", align 1
+// CUDA: @.offloading.entry_name = internal unnamed_addr constant [8 x i8] 
c"_Z3foov\00"
+// CUDA: @.offloading.entry._Z3foov = weak constant 
%struct.__tgt_offload_entry { ptr @_Z18__device_stub__foov, ptr 
@.offloading.entry_name, i64 0, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
+// CUDA: @.offloading.entry_name.1 = internal unnamed_addr constant [11 x i8] 
c"_Z6kernelv\00"
+// CUDA: @.offloading.entry._Z6kernelv = weak constant 
%struct.__tgt_offload_entry { ptr @_Z21__device_stub__kernelv, ptr 
@.offloading.entry_name.1, i64 0, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
+// CUDA: @.offloading.entry_name.2 = internal unnamed_addr constant [4 x i8] 
c"var\00"
+// CUDA: @.offloading.entry.var = weak constant %struct.__tgt_offload_entry { 
ptr @var, ptr @.offloading.entry_name.2, i64 4, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
+// CUDA: @.offloading.entry_name.3 = internal unnamed_addr constant [5 x i8] 
c"surf\00"
+// CUDA: @.offloading.entry.surf = weak constant %struct.__tgt_offload_entry { 
ptr @surf, ptr @.offloading.entry_name.3, i64 4, i32 2, i32 1 }, section 
"cuda_offloading_entries", align 1
+// CUDA: @.offloading.entry_name.4 = internal unnamed_addr constant [4 x i8] 
c"tex\00"
+// CUDA: @.offloading.entry.tex = weak constant %struct.__tgt_offload_entry { 
ptr @tex, ptr @.offloading.entry_name.4, i64 4, i32 3, i32 1 }, section 
"cuda_offloading_entries", align 1
 //.
-// HIP: @.omp_offloading.entry_name = internal unnamed_addr constant [8 x i8] 
c"_Z3foov\00"
-// HIP: @.omp_offloading.entry._Z3foov = weak constant 
%struct.__tgt_offload_entry { ptr 

[clang] [Sema][NFC] Cleanups after 843cc474f (PR #87996)

2024-04-08 Thread Younan Zhang via cfe-commits

https://github.com/zyn0217 closed 
https://github.com/llvm/llvm-project/pull/87996
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] f7d9337 - [Sema][NFC] Cleanups after 843cc474f (#87996)

2024-04-08 Thread via cfe-commits

Author: Younan Zhang
Date: 2024-04-09T09:53:58+08:00
New Revision: f7d93373969b2b757f5d5ef5e157dabe3bb9b0ae

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

LOG: [Sema][NFC] Cleanups after 843cc474f (#87996)

I forgot to tidy up these lines that should've been done in the previous
commit, specifically:

1. Merge two `CodeSynthesisContext`s into one in `CheckTemplateIdType`.
2. Remove some gratuitous `Sema::` specifiers.
3. Rename the parameter `Template` to `Entity` to avoid confusion.

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Frontend/FrontendActions.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 3fe2b6dd422a54..9769d36900664c 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -10077,7 +10077,7 @@ class Sema final : public SemaBase {
 
 /// Note that we are instantiating a type alias template declaration.
 InstantiatingTemplate(Sema , SourceLocation PointOfInstantiation,
-  TypeAliasTemplateDecl *Template,
+  TypeAliasTemplateDecl *Entity,
   ArrayRef TemplateArgs,
   SourceRange InstantiationRange = SourceRange());
 

diff  --git a/clang/lib/Frontend/FrontendActions.cpp 
b/clang/lib/Frontend/FrontendActions.cpp
index 7ee6ccf396a891..58fcb2217b05d8 100644
--- a/clang/lib/Frontend/FrontendActions.cpp
+++ b/clang/lib/Frontend/FrontendActions.cpp
@@ -453,7 +453,7 @@ class DefaultTemplateInstCallback : public 
TemplateInstantiationCallback {
   return "BuildingBuiltinDumpStructCall";
 case CodeSynthesisContext::BuildingDeductionGuides:
   return "BuildingDeductionGuides";
-case Sema::CodeSynthesisContext::TypeAliasTemplateInstantiation:
+case CodeSynthesisContext::TypeAliasTemplateInstantiation:
   return "TypeAliasTemplateInstantiation";
 }
 return "";

diff  --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 73030cf4b72203..2013799b5eb816 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -4494,15 +4494,13 @@ QualType Sema::CheckTemplateIdType(TemplateName Name,
 AliasTemplate->getTemplateParameters()->getDepth());
 
 LocalInstantiationScope Scope(*this);
-InstantiatingTemplate Inst(*this, TemplateLoc, Template);
+InstantiatingTemplate Inst(
+*this, /*PointOfInstantiation=*/TemplateLoc,
+/*Entity=*/AliasTemplate,
+/*TemplateArgs=*/TemplateArgLists.getInnermost());
 if (Inst.isInvalid())
   return QualType();
 
-InstantiatingTemplate InstTemplate(
-*this, /*PointOfInstantiation=*/AliasTemplate->getBeginLoc(),
-/*Template=*/AliasTemplate,
-/*TemplateArgs=*/TemplateArgLists.getInnermost());
-
 std::optional SavedContext;
 if (!AliasTemplate->getDeclContext()->isFileContext())
   SavedContext.emplace(*this, AliasTemplate->getDeclContext());

diff  --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index d7b7291091ecb8..a265fd1c46a63e 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -737,11 +737,11 @@ Sema::InstantiatingTemplate::InstantiatingTemplate(
 
 Sema::InstantiatingTemplate::InstantiatingTemplate(
 Sema , SourceLocation PointOfInstantiation,
-TypeAliasTemplateDecl *Template, ArrayRef TemplateArgs,
+TypeAliasTemplateDecl *Entity, ArrayRef TemplateArgs,
 SourceRange InstantiationRange)
 : InstantiatingTemplate(
-  SemaRef, Sema::CodeSynthesisContext::TypeAliasTemplateInstantiation,
-  PointOfInstantiation, InstantiationRange, /*Entity=*/Template,
+  SemaRef, CodeSynthesisContext::TypeAliasTemplateInstantiation,
+  PointOfInstantiation, InstantiationRange, /*Entity=*/Entity,
   /*Template=*/nullptr, TemplateArgs) {}
 
 Sema::InstantiatingTemplate::InstantiatingTemplate(
@@ -983,11 +983,6 @@ void Sema::PrintInstantiationStack() {
 Diags.Report(Active->PointOfInstantiation,
  diag::note_template_class_instantiation_here)
 << CTD << Active->InstantiationRange;
-  } else {
-Diags.Report(Active->PointOfInstantiation,
- diag::note_template_type_alias_instantiation_here)
-  << cast(D)
-  << Active->InstantiationRange;
   }
   break;
 }
@@ -1262,6 +1257,10 @@ void Sema::PrintInstantiationStack() {
diag::note_building_deduction_guide_here);
   break;
 case 

[clang] [llvm] [Offload][NFC] Remove `omp_` prefix from offloading entries (PR #88071)

2024-04-08 Thread Joseph Huber via cfe-commits

jhuber6 wrote:

> How about `llvm.offload`? This might need broader discussion but I'm fine 
> either way.

I don't think it's too important here since these are effectively internal 
variables. However in the future I want to combine `cuda_offload_entires` and 
friends into just `llvm_offload_entries`.

https://github.com/llvm/llvm-project/pull/88071
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [Offload][NFC] Remove `omp_` prefix from offloading entries (PR #88071)

2024-04-08 Thread Joseph Huber via cfe-commits

https://github.com/jhuber6 updated 
https://github.com/llvm/llvm-project/pull/88071

>From 24c3253093491d0fbe297bc10cba8552b7bef665 Mon Sep 17 00:00:00 2001
From: Joseph Huber 
Date: Mon, 8 Apr 2024 19:10:37 -0500
Subject: [PATCH] [Offload][NFC] Remove `omp_` prefix from offloading entries

Summary:
These entires are generic for offloading with the new driver now. Having
the `omp` prefix was a historical artifact and is confusing when used
for CUDA. This patch just renames them for now, future patches will
rework the binary format to make it more common.
---
 clang/test/CodeGenCUDA/offloading-entries.cu  | 82 +--
 .../OpenMP/declare_target_link_codegen.cpp| 10 +--
 .../declare_target_visibility_codegen.cpp |  8 +-
 .../OpenMP/target_codegen_registration.cpp| 48 +--
 clang/test/OpenMP/target_indirect_codegen.cpp |  8 +-
 llvm/lib/Frontend/Offloading/Utility.cpp  |  6 +-
 .../Frontend/OpenMPIRBuilderTest.cpp  |  8 +-
 7 files changed, 85 insertions(+), 85 deletions(-)

diff --git a/clang/test/CodeGenCUDA/offloading-entries.cu 
b/clang/test/CodeGenCUDA/offloading-entries.cu
index 4f5cf65ecd0bde..ec21f018607ff0 100644
--- a/clang/test/CodeGenCUDA/offloading-entries.cu
+++ b/clang/test/CodeGenCUDA/offloading-entries.cu
@@ -1,4 +1,4 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-globals --global-value-regex ".omp_offloading.entry.*"
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-globals --global-value-regex ".offloading.entry.*"
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-linux-gnu -fgpu-rdc \
 // RUN:   --offload-new-driver -emit-llvm -o - -x cuda  %s | FileCheck \
 // RUN:   --check-prefix=CUDA %s
@@ -15,49 +15,49 @@
 #include "Inputs/cuda.h"
 
 //.
-// CUDA: @.omp_offloading.entry_name = internal unnamed_addr constant [8 x i8] 
c"_Z3foov\00"
-// CUDA: @.omp_offloading.entry._Z3foov = weak constant 
%struct.__tgt_offload_entry { ptr @_Z18__device_stub__foov, ptr 
@.omp_offloading.entry_name, i64 0, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
-// CUDA: @.omp_offloading.entry_name.1 = internal unnamed_addr constant [11 x 
i8] c"_Z6kernelv\00"
-// CUDA: @.omp_offloading.entry._Z6kernelv = weak constant 
%struct.__tgt_offload_entry { ptr @_Z21__device_stub__kernelv, ptr 
@.omp_offloading.entry_name.1, i64 0, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
-// CUDA: @.omp_offloading.entry_name.2 = internal unnamed_addr constant [4 x 
i8] c"var\00"
-// CUDA: @.omp_offloading.entry.var = weak constant 
%struct.__tgt_offload_entry { ptr @var, ptr @.omp_offloading.entry_name.2, i64 
4, i32 0, i32 0 }, section "cuda_offloading_entries", align 1
-// CUDA: @.omp_offloading.entry_name.3 = internal unnamed_addr constant [5 x 
i8] c"surf\00"
-// CUDA: @.omp_offloading.entry.surf = weak constant 
%struct.__tgt_offload_entry { ptr @surf, ptr @.omp_offloading.entry_name.3, i64 
4, i32 2, i32 1 }, section "cuda_offloading_entries", align 1
-// CUDA: @.omp_offloading.entry_name.4 = internal unnamed_addr constant [4 x 
i8] c"tex\00"
-// CUDA: @.omp_offloading.entry.tex = weak constant 
%struct.__tgt_offload_entry { ptr @tex, ptr @.omp_offloading.entry_name.4, i64 
4, i32 3, i32 1 }, section "cuda_offloading_entries", align 1
+// CUDA: @.offloading.entry_name = internal unnamed_addr constant [8 x i8] 
c"_Z3foov\00"
+// CUDA: @.offloading.entry._Z3foov = weak constant 
%struct.__tgt_offload_entry { ptr @_Z18__device_stub__foov, ptr 
@.offloading.entry_name, i64 0, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
+// CUDA: @.offloading.entry_name.1 = internal unnamed_addr constant [11 x i8] 
c"_Z6kernelv\00"
+// CUDA: @.offloading.entry._Z6kernelv = weak constant 
%struct.__tgt_offload_entry { ptr @_Z21__device_stub__kernelv, ptr 
@.offloading.entry_name.1, i64 0, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
+// CUDA: @.offloading.entry_name.2 = internal unnamed_addr constant [4 x i8] 
c"var\00"
+// CUDA: @.offloading.entry.var = weak constant %struct.__tgt_offload_entry { 
ptr @var, ptr @.offloading.entry_name.2, i64 4, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
+// CUDA: @.offloading.entry_name.3 = internal unnamed_addr constant [5 x i8] 
c"surf\00"
+// CUDA: @.offloading.entry.surf = weak constant %struct.__tgt_offload_entry { 
ptr @surf, ptr @.offloading.entry_name.3, i64 4, i32 2, i32 1 }, section 
"cuda_offloading_entries", align 1
+// CUDA: @.offloading.entry_name.4 = internal unnamed_addr constant [4 x i8] 
c"tex\00"
+// CUDA: @.offloading.entry.tex = weak constant %struct.__tgt_offload_entry { 
ptr @tex, ptr @.offloading.entry_name.4, i64 4, i32 3, i32 1 }, section 
"cuda_offloading_entries", align 1
 //.
-// HIP: @.omp_offloading.entry_name = internal unnamed_addr constant [8 x i8] 
c"_Z3foov\00"
-// HIP: @.omp_offloading.entry._Z3foov = weak constant 
%struct.__tgt_offload_entry { ptr 

[clang] [llvm] [AMDGPU] Add Clang builtins for amdgcn s_ttrace intrinsics (PR #88076)

2024-04-08 Thread Corbin Robeck via cfe-commits

CRobeck wrote:

Probably want to add a test in: 
clang/test/CodeGenOpenCL/builtins-amdgcn-gfx12.cl
as well.

https://github.com/llvm/llvm-project/pull/88076
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [Offload][NFC] Remove `omp_` prefix from offloading entries (PR #88071)

2024-04-08 Thread Shilei Tian via cfe-commits

shiltian wrote:

How about `llvm.offload`? This might need broader discussion but I'm fine 
either way.

https://github.com/llvm/llvm-project/pull/88071
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Sema] Fix the lambda call expression inside of a type alias declaration (PR #82310)

2024-04-08 Thread Qizhi Hu via cfe-commits

jcsxky wrote:

> > Still crash on
> > ```c++
> > template constexpr auto x = F();
> > template constexpr int a() { return 1; }
> > 
> > template 
> > struct A {
> > using Func = decltype(
> > [](T) {
> > return x<[] constexpr { return a(); }>;
> > // return x<[] constexpr { return b(); }>;
> > }.template operator()('2')
> > );
> > };
> > A::Func y;
> > ```
> 
> That is a distinct case: Func does _not_ form a `TypeAliasTemplateDecl`, and 
> thus it is _not_ supposed to be covered by this PR. Please submit a new issue 
> for it.

Consider this one,
```cpp
template constexpr auto x = F();
template constexpr int a() { return 1; }

template 
struct A {
template
using Func = decltype(
[](T) {
return x<[] constexpr { return a(); }>;
}.template operator()('2')
);
};
A::Func y;
```
`Func` is a `TypeAliasTemplateDecl` and crashes as well.

https://github.com/llvm/llvm-project/pull/82310
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [RISCV][FMV] Support target_clones (PR #85786)

2024-04-08 Thread Jessica Clarke via cfe-commits

https://github.com/jrtc27 edited https://github.com/llvm/llvm-project/pull/85786
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [RISCV][FMV] Support target_clones (PR #85786)

2024-04-08 Thread Jessica Clarke via cfe-commits


@@ -0,0 +1,14 @@
+// RUN: not %clang_cc1 -triple riscv64-linux-gnu -target-feature +i -S 
-emit-llvm -o - %s 2>&1 | FileCheck %s --check-prefix=CHECK-UNSUPPORT-EXT
+// RUN: not %clang_cc1 -triple riscv64 -target-feature +i -S -emit-llvm -o - 
%s 2>&1 | FileCheck %s --check-prefix=CHECK-UNSUPPORT-OS
+
+// CHECK-UNSUPPORT-EXT: error: Unsupport 'zicsr' for _riscv_hwprobe
+__attribute__((target_clones("default", "arch=+zicsr"))) int foo1(void) {
+  return 1;
+}
+
+// CHECK-UNSUPPORT-OS: error: Only Linux support _riscv_hwprobe

jrtc27 wrote:

That's not the right error message still. " is only 
supported on Linux" isn't the point, the point is that the current 
implementation only supports Linux because it is written to use that specific 
system call. Other OSes can and likely will provide alternative interfaces that 
could equally be used.

https://github.com/llvm/llvm-project/pull/85786
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [RISCV][FMV] Support target_clones (PR #85786)

2024-04-08 Thread Craig Topper via cfe-commits


@@ -14156,6 +14157,84 @@ 
CodeGenFunction::EmitAArch64CpuSupports(ArrayRef FeaturesStrs) {
   return Result;
 }
 
+llvm::SmallVector
+CodeGenFunction::EmitRISCVExtSupports(ArrayRef FeaturesStrs) {
+  auto BaseExtReqs = llvm::RISCV::getBaseExtensionKey(FeaturesStrs);
+  auto IMACompatibleExtReqs =
+  llvm::RISCV::getIMACompatibleExtensionKey(FeaturesStrs);
+
+  // check whether all FeatureStrs are available for hwprobe.
+  llvm::SmallVector UnsupportByHwprobe;
+  llvm::StringSet<> ImpliedExtBySupportExt;
+  for (unsigned Idx = 0; Idx < FeaturesStrs.size(); Idx++) {
+if (BaseExtReqs[Idx] == 0 && IMACompatibleExtReqs[Idx] == 0)
+  UnsupportByHwprobe.push_back(FeaturesStrs[Idx]);
+else
+  ImpliedExtBySupportExt.insert(FeaturesStrs[Idx].str());
+  }
+
+  // Repeatly find ImpliedExts until no longer found new.
+  bool Changed = true;
+  while (Changed) {
+unsigned Size = ImpliedExtBySupportExt.size();
+for (auto Ext : ImpliedExtBySupportExt.keys()) {
+  auto ImpliedExts = llvm::RISCV::getImpliedExts(Ext);
+  for (auto ImpliedExt : ImpliedExts)
+ImpliedExtBySupportExt.insert(ImpliedExt);
+}
+if (Size == ImpliedExtBySupportExt.size())
+  Changed = false;
+  }
+
+  // FIXME: Could hwprobe guarantee that the hardware will support the Implied
+  // extension?
+  for (unsigned Idx = 0; Idx < UnsupportByHwprobe.size(); Idx++) {
+if (!llvm::is_contained(ImpliedExtBySupportExt, UnsupportByHwprobe[Idx]))
+  CGM.getDiags().Report(diag::err_extension_unsupport_riscv_hwprobe)
+  << UnsupportByHwprobe[Idx];
+  }
+
+  StructType *structType =

topperc wrote:

Variable name should be capitalized

https://github.com/llvm/llvm-project/pull/85786
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [RISCV][FMV] Support target_clones (PR #85786)

2024-04-08 Thread Craig Topper via cfe-commits


@@ -14156,6 +14157,84 @@ 
CodeGenFunction::EmitAArch64CpuSupports(ArrayRef FeaturesStrs) {
   return Result;
 }
 
+llvm::SmallVector
+CodeGenFunction::EmitRISCVExtSupports(ArrayRef FeaturesStrs) {
+  auto BaseExtReqs = llvm::RISCV::getBaseExtensionKey(FeaturesStrs);
+  auto IMACompatibleExtReqs =
+  llvm::RISCV::getIMACompatibleExtensionKey(FeaturesStrs);
+
+  // check whether all FeatureStrs are available for hwprobe.
+  llvm::SmallVector UnsupportByHwprobe;
+  llvm::StringSet<> ImpliedExtBySupportExt;
+  for (unsigned Idx = 0; Idx < FeaturesStrs.size(); Idx++) {
+if (BaseExtReqs[Idx] == 0 && IMACompatibleExtReqs[Idx] == 0)
+  UnsupportByHwprobe.push_back(FeaturesStrs[Idx]);
+else
+  ImpliedExtBySupportExt.insert(FeaturesStrs[Idx].str());
+  }
+
+  // Repeatly find ImpliedExts until no longer found new.

topperc wrote:

found -> find

https://github.com/llvm/llvm-project/pull/85786
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [RISCV][FMV] Support target_clones (PR #85786)

2024-04-08 Thread Craig Topper via cfe-commits


@@ -14156,6 +14157,84 @@ 
CodeGenFunction::EmitAArch64CpuSupports(ArrayRef FeaturesStrs) {
   return Result;
 }
 
+llvm::SmallVector
+CodeGenFunction::EmitRISCVExtSupports(ArrayRef FeaturesStrs) {
+  auto BaseExtReqs = llvm::RISCV::getBaseExtensionKey(FeaturesStrs);
+  auto IMACompatibleExtReqs =
+  llvm::RISCV::getIMACompatibleExtensionKey(FeaturesStrs);
+
+  // check whether all FeatureStrs are available for hwprobe.
+  llvm::SmallVector UnsupportByHwprobe;
+  llvm::StringSet<> ImpliedExtBySupportExt;
+  for (unsigned Idx = 0; Idx < FeaturesStrs.size(); Idx++) {
+if (BaseExtReqs[Idx] == 0 && IMACompatibleExtReqs[Idx] == 0)
+  UnsupportByHwprobe.push_back(FeaturesStrs[Idx]);
+else
+  ImpliedExtBySupportExt.insert(FeaturesStrs[Idx].str());
+  }
+
+  // Repeatly find ImpliedExts until no longer found new.
+  bool Changed = true;
+  while (Changed) {
+unsigned Size = ImpliedExtBySupportExt.size();
+for (auto Ext : ImpliedExtBySupportExt.keys()) {
+  auto ImpliedExts = llvm::RISCV::getImpliedExts(Ext);
+  for (auto ImpliedExt : ImpliedExts)
+ImpliedExtBySupportExt.insert(ImpliedExt);
+}
+if (Size == ImpliedExtBySupportExt.size())

topperc wrote:

Can you use the return value from `insert` to tell if the insert happened?

https://github.com/llvm/llvm-project/pull/85786
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [RISCV][FMV] Support target_clones (PR #85786)

2024-04-08 Thread Craig Topper via cfe-commits


@@ -14156,6 +14157,84 @@ 
CodeGenFunction::EmitAArch64CpuSupports(ArrayRef FeaturesStrs) {
   return Result;
 }
 
+llvm::SmallVector
+CodeGenFunction::EmitRISCVExtSupports(ArrayRef FeaturesStrs) {
+  auto BaseExtReqs = llvm::RISCV::getBaseExtensionKey(FeaturesStrs);
+  auto IMACompatibleExtReqs =
+  llvm::RISCV::getIMACompatibleExtensionKey(FeaturesStrs);
+
+  // check whether all FeatureStrs are available for hwprobe.

topperc wrote:

check->Check

https://github.com/llvm/llvm-project/pull/85786
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [AMDGPU] Add Clang builtins for amdgcn s_ttrace intrinsics (PR #88076)

2024-04-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Corbin Robeck (CRobeck)


Changes



---
Full diff: https://github.com/llvm/llvm-project/pull/88076.diff


2 Files Affected:

- (modified) clang/include/clang/Basic/BuiltinsAMDGPU.def (+2) 
- (modified) llvm/include/llvm/IR/IntrinsicsAMDGPU.td (+3) 


``diff
diff --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def 
b/clang/include/clang/Basic/BuiltinsAMDGPU.def
index c660582cc98e66..d2912d271d4005 100644
--- a/clang/include/clang/Basic/BuiltinsAMDGPU.def
+++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def
@@ -61,6 +61,8 @@ BUILTIN(__builtin_amdgcn_s_waitcnt, "vIi", "n")
 BUILTIN(__builtin_amdgcn_s_sendmsg, "vIiUi", "n")
 BUILTIN(__builtin_amdgcn_s_sendmsghalt, "vIiUi", "n")
 BUILTIN(__builtin_amdgcn_s_barrier, "v", "n")
+BUILTIN(__builtin_amdgcn_s_ttracedata, "v", "n")
+BUILTIN(__builtin_amdgcn_s_ttracedata_imm, "v", "n")
 BUILTIN(__builtin_amdgcn_wave_barrier, "v", "n")
 BUILTIN(__builtin_amdgcn_sched_barrier, "vIi", "n")
 BUILTIN(__builtin_amdgcn_sched_group_barrier, "vIiIiIi", "n")
diff --git a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td 
b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
index 6bbc13f1de86e2..ee9a5d7a343980 100644
--- a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
+++ b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
@@ -1887,9 +1887,12 @@ def int_amdgcn_s_setprio :
 IntrHasSideEffects]>;
 
 def int_amdgcn_s_ttracedata :
+  ClangBuiltin<"__builtin_amdgcn_s_ttracedata">,
   DefaultAttrsIntrinsic<[], [llvm_i32_ty],
 [IntrNoMem, IntrHasSideEffects]>;
+
 def int_amdgcn_s_ttracedata_imm :
+  ClangBuiltin<"__builtin_amdgcn_s_ttracedata_imm">,
   DefaultAttrsIntrinsic<[], [llvm_i16_ty],
 [IntrNoMem, IntrHasSideEffects, ImmArg>]>;
 

``




https://github.com/llvm/llvm-project/pull/88076
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [AMDGPU] Add Clang builtins for amdgcn s_ttrace intrinsics (PR #88076)

2024-04-08 Thread Corbin Robeck via cfe-commits

https://github.com/CRobeck edited 
https://github.com/llvm/llvm-project/pull/88076
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [AMDGPU] Add cCang builtins for amdgcn s_ttrace intrinsics (PR #88076)

2024-04-08 Thread Corbin Robeck via cfe-commits

https://github.com/CRobeck created 
https://github.com/llvm/llvm-project/pull/88076

None

>From 1e2cab61cbf46e5cc73d7ee6523dcce1a75c7549 Mon Sep 17 00:00:00 2001
From: Corbin Robeck 
Date: Mon, 8 Apr 2024 19:58:57 -0500
Subject: [PATCH] add clang builtins for amdgcn s_ttrace intrinsics

---
 clang/include/clang/Basic/BuiltinsAMDGPU.def | 2 ++
 llvm/include/llvm/IR/IntrinsicsAMDGPU.td | 3 +++
 2 files changed, 5 insertions(+)

diff --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def 
b/clang/include/clang/Basic/BuiltinsAMDGPU.def
index c660582cc98e66..d2912d271d4005 100644
--- a/clang/include/clang/Basic/BuiltinsAMDGPU.def
+++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def
@@ -61,6 +61,8 @@ BUILTIN(__builtin_amdgcn_s_waitcnt, "vIi", "n")
 BUILTIN(__builtin_amdgcn_s_sendmsg, "vIiUi", "n")
 BUILTIN(__builtin_amdgcn_s_sendmsghalt, "vIiUi", "n")
 BUILTIN(__builtin_amdgcn_s_barrier, "v", "n")
+BUILTIN(__builtin_amdgcn_s_ttracedata, "v", "n")
+BUILTIN(__builtin_amdgcn_s_ttracedata_imm, "v", "n")
 BUILTIN(__builtin_amdgcn_wave_barrier, "v", "n")
 BUILTIN(__builtin_amdgcn_sched_barrier, "vIi", "n")
 BUILTIN(__builtin_amdgcn_sched_group_barrier, "vIiIiIi", "n")
diff --git a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td 
b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
index 6bbc13f1de86e2..ee9a5d7a343980 100644
--- a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
+++ b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td
@@ -1887,9 +1887,12 @@ def int_amdgcn_s_setprio :
 IntrHasSideEffects]>;
 
 def int_amdgcn_s_ttracedata :
+  ClangBuiltin<"__builtin_amdgcn_s_ttracedata">,
   DefaultAttrsIntrinsic<[], [llvm_i32_ty],
 [IntrNoMem, IntrHasSideEffects]>;
+
 def int_amdgcn_s_ttracedata_imm :
+  ClangBuiltin<"__builtin_amdgcn_s_ttracedata_imm">,
   DefaultAttrsIntrinsic<[], [llvm_i16_ty],
 [IntrNoMem, IntrHasSideEffects, ImmArg>]>;
 

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


[clang] [llvm] [RISCV][FMV] Support target_clones (PR #85786)

2024-04-08 Thread Craig Topper via cfe-commits


@@ -0,0 +1,14 @@
+// RUN: not %clang_cc1 -triple riscv64-linux-gnu -target-feature +i -S 
-emit-llvm -o - %s 2>&1 | FileCheck %s --check-prefix=CHECK-UNSUPPORT-EXT
+// RUN: not %clang_cc1 -triple riscv64 -target-feature +i -S -emit-llvm -o - 
%s 2>&1 | FileCheck %s --check-prefix=CHECK-UNSUPPORT-OS
+
+// CHECK-UNSUPPORT-EXT: error: Unsupport 'zicsr' for _riscv_hwprobe
+__attribute__((target_clones("default", "arch=+zicsr"))) int foo1(void) {
+  return 1;
+}
+
+// CHECK-UNSUPPORT-OS: error: Only Linux support _riscv_hwprobe

topperc wrote:

`_riscv_hwprobe is only supported on Linux`

https://github.com/llvm/llvm-project/pull/85786
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [RISCV][FMV] Support target_clones (PR #85786)

2024-04-08 Thread Craig Topper via cfe-commits


@@ -0,0 +1,14 @@
+// RUN: not %clang_cc1 -triple riscv64-linux-gnu -target-feature +i -S 
-emit-llvm -o - %s 2>&1 | FileCheck %s --check-prefix=CHECK-UNSUPPORT-EXT
+// RUN: not %clang_cc1 -triple riscv64 -target-feature +i -S -emit-llvm -o - 
%s 2>&1 | FileCheck %s --check-prefix=CHECK-UNSUPPORT-OS
+
+// CHECK-UNSUPPORT-EXT: error: Unsupport 'zicsr' for _riscv_hwprobe

topperc wrote:

`Unsupported extension 'zicsr' for _riscv_hwprobe`?

https://github.com/llvm/llvm-project/pull/85786
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [Offload][NFC] Remove `omp_` prefix from offloading entries (PR #88071)

2024-04-08 Thread Joseph Huber via cfe-commits

https://github.com/jhuber6 updated 
https://github.com/llvm/llvm-project/pull/88071

>From e236a4351c198f261e544970d4355f749db11fd7 Mon Sep 17 00:00:00 2001
From: Joseph Huber 
Date: Mon, 8 Apr 2024 19:10:37 -0500
Subject: [PATCH] [Offload][NFC] Remove `omp_` prefix from offloading entries

Summary:
These entires are generic for offloading with the new driver now. Having
the `omp` prefix was a historical artifact and is confusing when used
for CUDA. This patch just renames them for now, future patches will
rework the binary format to make it more common.
---
 clang/test/CodeGenCUDA/offloading-entries.cu  | 82 +--
 .../OpenMP/declare_target_link_codegen.cpp| 10 +--
 .../declare_target_visibility_codegen.cpp |  8 +-
 .../OpenMP/target_codegen_registration.cpp| 48 +--
 clang/test/OpenMP/target_indirect_codegen.cpp |  8 +-
 llvm/lib/Frontend/Offloading/Utility.cpp  |  6 +-
 6 files changed, 81 insertions(+), 81 deletions(-)

diff --git a/clang/test/CodeGenCUDA/offloading-entries.cu 
b/clang/test/CodeGenCUDA/offloading-entries.cu
index 4f5cf65ecd0bde..ec21f018607ff0 100644
--- a/clang/test/CodeGenCUDA/offloading-entries.cu
+++ b/clang/test/CodeGenCUDA/offloading-entries.cu
@@ -1,4 +1,4 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-globals --global-value-regex ".omp_offloading.entry.*"
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-globals --global-value-regex ".offloading.entry.*"
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-linux-gnu -fgpu-rdc \
 // RUN:   --offload-new-driver -emit-llvm -o - -x cuda  %s | FileCheck \
 // RUN:   --check-prefix=CUDA %s
@@ -15,49 +15,49 @@
 #include "Inputs/cuda.h"
 
 //.
-// CUDA: @.omp_offloading.entry_name = internal unnamed_addr constant [8 x i8] 
c"_Z3foov\00"
-// CUDA: @.omp_offloading.entry._Z3foov = weak constant 
%struct.__tgt_offload_entry { ptr @_Z18__device_stub__foov, ptr 
@.omp_offloading.entry_name, i64 0, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
-// CUDA: @.omp_offloading.entry_name.1 = internal unnamed_addr constant [11 x 
i8] c"_Z6kernelv\00"
-// CUDA: @.omp_offloading.entry._Z6kernelv = weak constant 
%struct.__tgt_offload_entry { ptr @_Z21__device_stub__kernelv, ptr 
@.omp_offloading.entry_name.1, i64 0, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
-// CUDA: @.omp_offloading.entry_name.2 = internal unnamed_addr constant [4 x 
i8] c"var\00"
-// CUDA: @.omp_offloading.entry.var = weak constant 
%struct.__tgt_offload_entry { ptr @var, ptr @.omp_offloading.entry_name.2, i64 
4, i32 0, i32 0 }, section "cuda_offloading_entries", align 1
-// CUDA: @.omp_offloading.entry_name.3 = internal unnamed_addr constant [5 x 
i8] c"surf\00"
-// CUDA: @.omp_offloading.entry.surf = weak constant 
%struct.__tgt_offload_entry { ptr @surf, ptr @.omp_offloading.entry_name.3, i64 
4, i32 2, i32 1 }, section "cuda_offloading_entries", align 1
-// CUDA: @.omp_offloading.entry_name.4 = internal unnamed_addr constant [4 x 
i8] c"tex\00"
-// CUDA: @.omp_offloading.entry.tex = weak constant 
%struct.__tgt_offload_entry { ptr @tex, ptr @.omp_offloading.entry_name.4, i64 
4, i32 3, i32 1 }, section "cuda_offloading_entries", align 1
+// CUDA: @.offloading.entry_name = internal unnamed_addr constant [8 x i8] 
c"_Z3foov\00"
+// CUDA: @.offloading.entry._Z3foov = weak constant 
%struct.__tgt_offload_entry { ptr @_Z18__device_stub__foov, ptr 
@.offloading.entry_name, i64 0, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
+// CUDA: @.offloading.entry_name.1 = internal unnamed_addr constant [11 x i8] 
c"_Z6kernelv\00"
+// CUDA: @.offloading.entry._Z6kernelv = weak constant 
%struct.__tgt_offload_entry { ptr @_Z21__device_stub__kernelv, ptr 
@.offloading.entry_name.1, i64 0, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
+// CUDA: @.offloading.entry_name.2 = internal unnamed_addr constant [4 x i8] 
c"var\00"
+// CUDA: @.offloading.entry.var = weak constant %struct.__tgt_offload_entry { 
ptr @var, ptr @.offloading.entry_name.2, i64 4, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
+// CUDA: @.offloading.entry_name.3 = internal unnamed_addr constant [5 x i8] 
c"surf\00"
+// CUDA: @.offloading.entry.surf = weak constant %struct.__tgt_offload_entry { 
ptr @surf, ptr @.offloading.entry_name.3, i64 4, i32 2, i32 1 }, section 
"cuda_offloading_entries", align 1
+// CUDA: @.offloading.entry_name.4 = internal unnamed_addr constant [4 x i8] 
c"tex\00"
+// CUDA: @.offloading.entry.tex = weak constant %struct.__tgt_offload_entry { 
ptr @tex, ptr @.offloading.entry_name.4, i64 4, i32 3, i32 1 }, section 
"cuda_offloading_entries", align 1
 //.
-// HIP: @.omp_offloading.entry_name = internal unnamed_addr constant [8 x i8] 
c"_Z3foov\00"
-// HIP: @.omp_offloading.entry._Z3foov = weak constant 
%struct.__tgt_offload_entry { ptr @_Z3foov, ptr @.omp_offloading.entry_name, 
i64 0, i32 0, i32 

[clang] [clang][c++20] Fix code coverage mapping crash with generalized NTTPs (PR #85837)

2024-04-08 Thread Andrey Ali Khan Bolshakov via cfe-commits

bolshakov-a wrote:

@erichkeane, @cor3ntin, @Endilll, @efriedma-quic ping.

https://github.com/llvm/llvm-project/pull/85837
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [AMDGPU] Emit a waitcnt instruction after each memory instruction (PR #79236)

2024-04-08 Thread Jun Wang via cfe-commits

jwanggit86 wrote:

Added a testcase that has flat_atomic_swap, which is an atomic without return.

https://github.com/llvm/llvm-project/pull/79236
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [Offload][NFC] Remove `omp_` prefix from offloading entries (PR #88071)

2024-04-08 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 1950ebd17bbf1f2ad2a3799cd5966412ccfee9c4 
651ebdc8b9875bc336aed345d61df8a9395fd6d7 -- 
clang/test/OpenMP/declare_target_link_codegen.cpp 
clang/test/OpenMP/declare_target_visibility_codegen.cpp 
clang/test/OpenMP/target_codegen_registration.cpp 
clang/test/OpenMP/target_indirect_codegen.cpp 
llvm/lib/Frontend/Offloading/Utility.cpp
``





View the diff from clang-format here.


``diff
diff --git a/llvm/lib/Frontend/Offloading/Utility.cpp 
b/llvm/lib/Frontend/Offloading/Utility.cpp
index ea7bfa88e0..919b9462e3 100644
--- a/llvm/lib/Frontend/Offloading/Utility.cpp
+++ b/llvm/lib/Frontend/Offloading/Utility.cpp
@@ -40,8 +40,8 @@ offloading::getOffloadingEntryInitializer(Module , Constant 
*Addr,
 
   Constant *AddrName = ConstantDataArray::getString(M.getContext(), Name);
 
-  StringRef Prefix = Triple.isNVPTX() ? "$offloading$entry_name"
-  : ".offloading.entry_name";
+  StringRef Prefix =
+  Triple.isNVPTX() ? "$offloading$entry_name" : ".offloading.entry_name";
 
   // Create the constant string used to look up the symbol in the device.
   auto *Str =

``




https://github.com/llvm/llvm-project/pull/88071
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [Offload][NFC] Remove `omp_` prefix from offloading entries (PR #88071)

2024-04-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Joseph Huber (jhuber6)


Changes

Summary:
These entires are generic for offloading with the new driver now. Having
the `omp` prefix was a historical artifact and is confusing when used
for CUDA. This patch just renames them for now, future patches will
rework the binary format to make it more common.


---

Patch is 30.63 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/88071.diff


6 Files Affected:

- (modified) clang/test/CodeGenCUDA/offloading-entries.cu (+41-41) 
- (modified) clang/test/OpenMP/declare_target_link_codegen.cpp (+5-5) 
- (modified) clang/test/OpenMP/declare_target_visibility_codegen.cpp (+4-4) 
- (modified) clang/test/OpenMP/target_codegen_registration.cpp (+24-24) 
- (modified) clang/test/OpenMP/target_indirect_codegen.cpp (+4-4) 
- (modified) llvm/lib/Frontend/Offloading/Utility.cpp (+3-3) 


``diff
diff --git a/clang/test/CodeGenCUDA/offloading-entries.cu 
b/clang/test/CodeGenCUDA/offloading-entries.cu
index 4f5cf65ecd0bde..ec21f018607ff0 100644
--- a/clang/test/CodeGenCUDA/offloading-entries.cu
+++ b/clang/test/CodeGenCUDA/offloading-entries.cu
@@ -1,4 +1,4 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-globals --global-value-regex ".omp_offloading.entry.*"
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-globals --global-value-regex ".offloading.entry.*"
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-linux-gnu -fgpu-rdc \
 // RUN:   --offload-new-driver -emit-llvm -o - -x cuda  %s | FileCheck \
 // RUN:   --check-prefix=CUDA %s
@@ -15,49 +15,49 @@
 #include "Inputs/cuda.h"
 
 //.
-// CUDA: @.omp_offloading.entry_name = internal unnamed_addr constant [8 x i8] 
c"_Z3foov\00"
-// CUDA: @.omp_offloading.entry._Z3foov = weak constant 
%struct.__tgt_offload_entry { ptr @_Z18__device_stub__foov, ptr 
@.omp_offloading.entry_name, i64 0, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
-// CUDA: @.omp_offloading.entry_name.1 = internal unnamed_addr constant [11 x 
i8] c"_Z6kernelv\00"
-// CUDA: @.omp_offloading.entry._Z6kernelv = weak constant 
%struct.__tgt_offload_entry { ptr @_Z21__device_stub__kernelv, ptr 
@.omp_offloading.entry_name.1, i64 0, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
-// CUDA: @.omp_offloading.entry_name.2 = internal unnamed_addr constant [4 x 
i8] c"var\00"
-// CUDA: @.omp_offloading.entry.var = weak constant 
%struct.__tgt_offload_entry { ptr @var, ptr @.omp_offloading.entry_name.2, i64 
4, i32 0, i32 0 }, section "cuda_offloading_entries", align 1
-// CUDA: @.omp_offloading.entry_name.3 = internal unnamed_addr constant [5 x 
i8] c"surf\00"
-// CUDA: @.omp_offloading.entry.surf = weak constant 
%struct.__tgt_offload_entry { ptr @surf, ptr @.omp_offloading.entry_name.3, i64 
4, i32 2, i32 1 }, section "cuda_offloading_entries", align 1
-// CUDA: @.omp_offloading.entry_name.4 = internal unnamed_addr constant [4 x 
i8] c"tex\00"
-// CUDA: @.omp_offloading.entry.tex = weak constant 
%struct.__tgt_offload_entry { ptr @tex, ptr @.omp_offloading.entry_name.4, i64 
4, i32 3, i32 1 }, section "cuda_offloading_entries", align 1
+// CUDA: @.offloading.entry_name = internal unnamed_addr constant [8 x i8] 
c"_Z3foov\00"
+// CUDA: @.offloading.entry._Z3foov = weak constant 
%struct.__tgt_offload_entry { ptr @_Z18__device_stub__foov, ptr 
@.offloading.entry_name, i64 0, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
+// CUDA: @.offloading.entry_name.1 = internal unnamed_addr constant [11 x i8] 
c"_Z6kernelv\00"
+// CUDA: @.offloading.entry._Z6kernelv = weak constant 
%struct.__tgt_offload_entry { ptr @_Z21__device_stub__kernelv, ptr 
@.offloading.entry_name.1, i64 0, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
+// CUDA: @.offloading.entry_name.2 = internal unnamed_addr constant [4 x i8] 
c"var\00"
+// CUDA: @.offloading.entry.var = weak constant %struct.__tgt_offload_entry { 
ptr @var, ptr @.offloading.entry_name.2, i64 4, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
+// CUDA: @.offloading.entry_name.3 = internal unnamed_addr constant [5 x i8] 
c"surf\00"
+// CUDA: @.offloading.entry.surf = weak constant %struct.__tgt_offload_entry { 
ptr @surf, ptr @.offloading.entry_name.3, i64 4, i32 2, i32 1 }, section 
"cuda_offloading_entries", align 1
+// CUDA: @.offloading.entry_name.4 = internal unnamed_addr constant [4 x i8] 
c"tex\00"
+// CUDA: @.offloading.entry.tex = weak constant %struct.__tgt_offload_entry { 
ptr @tex, ptr @.offloading.entry_name.4, i64 4, i32 3, i32 1 }, section 
"cuda_offloading_entries", align 1
 //.
-// HIP: @.omp_offloading.entry_name = internal unnamed_addr constant [8 x i8] 
c"_Z3foov\00"
-// HIP: @.omp_offloading.entry._Z3foov = weak constant 
%struct.__tgt_offload_entry { ptr @_Z3foov, ptr @.omp_offloading.entry_name, 
i64 0, i32 0, i32 0 }, section 

[clang] [llvm] [Offload][NFC] Remove `omp_` prefix from offloading entries (PR #88071)

2024-04-08 Thread Joseph Huber via cfe-commits

https://github.com/jhuber6 created 
https://github.com/llvm/llvm-project/pull/88071

Summary:
These entires are generic for offloading with the new driver now. Having
the `omp` prefix was a historical artifact and is confusing when used
for CUDA. This patch just renames them for now, future patches will
rework the binary format to make it more common.


>From 651ebdc8b9875bc336aed345d61df8a9395fd6d7 Mon Sep 17 00:00:00 2001
From: Joseph Huber 
Date: Mon, 8 Apr 2024 19:10:37 -0500
Subject: [PATCH] [Offload][NFC] Remove `omp_` prefix from offloading entries

Summary:
These entires are generic for offloading with the new driver now. Having
the `omp` prefix was a historical artifact and is confusing when used
for CUDA. This patch just renames them for now, future patches will
rework the binary format to make it more common.
---
 clang/test/CodeGenCUDA/offloading-entries.cu  | 82 +--
 .../OpenMP/declare_target_link_codegen.cpp| 10 +--
 .../declare_target_visibility_codegen.cpp |  8 +-
 .../OpenMP/target_codegen_registration.cpp| 48 +--
 clang/test/OpenMP/target_indirect_codegen.cpp |  8 +-
 llvm/lib/Frontend/Offloading/Utility.cpp  |  6 +-
 6 files changed, 81 insertions(+), 81 deletions(-)

diff --git a/clang/test/CodeGenCUDA/offloading-entries.cu 
b/clang/test/CodeGenCUDA/offloading-entries.cu
index 4f5cf65ecd0bde..ec21f018607ff0 100644
--- a/clang/test/CodeGenCUDA/offloading-entries.cu
+++ b/clang/test/CodeGenCUDA/offloading-entries.cu
@@ -1,4 +1,4 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-globals --global-value-regex ".omp_offloading.entry.*"
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --check-globals --global-value-regex ".offloading.entry.*"
 // RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-linux-gnu -fgpu-rdc \
 // RUN:   --offload-new-driver -emit-llvm -o - -x cuda  %s | FileCheck \
 // RUN:   --check-prefix=CUDA %s
@@ -15,49 +15,49 @@
 #include "Inputs/cuda.h"
 
 //.
-// CUDA: @.omp_offloading.entry_name = internal unnamed_addr constant [8 x i8] 
c"_Z3foov\00"
-// CUDA: @.omp_offloading.entry._Z3foov = weak constant 
%struct.__tgt_offload_entry { ptr @_Z18__device_stub__foov, ptr 
@.omp_offloading.entry_name, i64 0, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
-// CUDA: @.omp_offloading.entry_name.1 = internal unnamed_addr constant [11 x 
i8] c"_Z6kernelv\00"
-// CUDA: @.omp_offloading.entry._Z6kernelv = weak constant 
%struct.__tgt_offload_entry { ptr @_Z21__device_stub__kernelv, ptr 
@.omp_offloading.entry_name.1, i64 0, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
-// CUDA: @.omp_offloading.entry_name.2 = internal unnamed_addr constant [4 x 
i8] c"var\00"
-// CUDA: @.omp_offloading.entry.var = weak constant 
%struct.__tgt_offload_entry { ptr @var, ptr @.omp_offloading.entry_name.2, i64 
4, i32 0, i32 0 }, section "cuda_offloading_entries", align 1
-// CUDA: @.omp_offloading.entry_name.3 = internal unnamed_addr constant [5 x 
i8] c"surf\00"
-// CUDA: @.omp_offloading.entry.surf = weak constant 
%struct.__tgt_offload_entry { ptr @surf, ptr @.omp_offloading.entry_name.3, i64 
4, i32 2, i32 1 }, section "cuda_offloading_entries", align 1
-// CUDA: @.omp_offloading.entry_name.4 = internal unnamed_addr constant [4 x 
i8] c"tex\00"
-// CUDA: @.omp_offloading.entry.tex = weak constant 
%struct.__tgt_offload_entry { ptr @tex, ptr @.omp_offloading.entry_name.4, i64 
4, i32 3, i32 1 }, section "cuda_offloading_entries", align 1
+// CUDA: @.offloading.entry_name = internal unnamed_addr constant [8 x i8] 
c"_Z3foov\00"
+// CUDA: @.offloading.entry._Z3foov = weak constant 
%struct.__tgt_offload_entry { ptr @_Z18__device_stub__foov, ptr 
@.offloading.entry_name, i64 0, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
+// CUDA: @.offloading.entry_name.1 = internal unnamed_addr constant [11 x i8] 
c"_Z6kernelv\00"
+// CUDA: @.offloading.entry._Z6kernelv = weak constant 
%struct.__tgt_offload_entry { ptr @_Z21__device_stub__kernelv, ptr 
@.offloading.entry_name.1, i64 0, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
+// CUDA: @.offloading.entry_name.2 = internal unnamed_addr constant [4 x i8] 
c"var\00"
+// CUDA: @.offloading.entry.var = weak constant %struct.__tgt_offload_entry { 
ptr @var, ptr @.offloading.entry_name.2, i64 4, i32 0, i32 0 }, section 
"cuda_offloading_entries", align 1
+// CUDA: @.offloading.entry_name.3 = internal unnamed_addr constant [5 x i8] 
c"surf\00"
+// CUDA: @.offloading.entry.surf = weak constant %struct.__tgt_offload_entry { 
ptr @surf, ptr @.offloading.entry_name.3, i64 4, i32 2, i32 1 }, section 
"cuda_offloading_entries", align 1
+// CUDA: @.offloading.entry_name.4 = internal unnamed_addr constant [4 x i8] 
c"tex\00"
+// CUDA: @.offloading.entry.tex = weak constant %struct.__tgt_offload_entry { 
ptr @tex, ptr @.offloading.entry_name.4, i64 4, i32 3, i32 1 }, section 

[clang] ccdebba - [Driver] Ensure ToolChain::LibraryPaths is not empty for non-Darwin

2024-04-08 Thread via cfe-commits

Author: Fangrui Song
Date: 2024-04-08T16:51:34-07:00
New Revision: ccdebbae4d77d3efc236af92c22941de5d437e01

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

LOG: [Driver] Ensure ToolChain::LibraryPaths is not empty for non-Darwin

Follow-up to #81037.

ToolChain::LibraryPaths holds the new compiler-rt library directory
(e.g. `/tmp/Debug/lib/clang/19/lib/x86_64-unknown-linux-gnu`). However,
it might be empty when the directory does not exist (due to the `if
(getVFS().exists(P))` change in https://reviews.llvm.org/D158475).

If neither the old/new compiler-rt library directories exists, we would
suggest the undesired old compiler-rt file name:

```
% /tmp/Debug/bin/clang++ a.cc -fsanitize=memory -o a
ld.lld: error: cannot open 
/tmp/Debug/lib/clang/19/lib/linux/libclang_rt.msan-x86_64.a: No such file or 
directory
clang++: error: linker command failed with exit code 1 (use -v to see 
invocation)
```

With this change, we will correctly suggest the new compiler-rt file name.

Fix #87150

Pull Request: https://github.com/llvm/llvm-project/pull/87866

Added: 


Modified: 
clang/lib/Driver/ToolChain.cpp
clang/test/Driver/arm-compiler-rt.c
clang/test/Driver/cl-link.c
clang/test/Driver/compiler-rt-unwind.c
clang/test/Driver/coverage-ld.c
clang/test/Driver/instrprof-ld.c
clang/test/Driver/linux-ld.c
clang/test/Driver/mingw-sanitizers.c
clang/test/Driver/msp430-toolchain.c
clang/test/Driver/print-libgcc-file-name-clangrt.c
clang/test/Driver/print-runtime-dir.c
clang/test/Driver/riscv32-toolchain-extra.c
clang/test/Driver/riscv32-toolchain.c
clang/test/Driver/riscv64-toolchain-extra.c
clang/test/Driver/riscv64-toolchain.c
clang/test/Driver/sanitizer-ld.c
clang/test/Driver/wasm-toolchain.c
clang/test/Driver/wasm-toolchain.cpp
clang/test/Driver/windows-cross.c
clang/test/Driver/zos-ld.c
flang/test/Driver/msvc-dependent-lib-flags.f90

Removed: 




diff  --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 03450fc0f57b93..237092ed07e5dc 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -796,7 +796,13 @@ ToolChain::getTargetSubDirPath(StringRef BaseDir) const {
 std::optional ToolChain::getRuntimePath() const {
   SmallString<128> P(D.ResourceDir);
   llvm::sys::path::append(P, "lib");
-  return getTargetSubDirPath(P);
+  if (auto Ret = getTargetSubDirPath(P))
+return Ret;
+  // Darwin does not use per-target runtime directory.
+  if (Triple.isOSDarwin())
+return {};
+  llvm::sys::path::append(P, Triple.str());
+  return std::string(P);
 }
 
 std::optional ToolChain::getStdlibPath() const {

diff  --git a/clang/test/Driver/arm-compiler-rt.c 
b/clang/test/Driver/arm-compiler-rt.c
index 5e9e528400d08e..cb6c29f48a7814 100644
--- a/clang/test/Driver/arm-compiler-rt.c
+++ b/clang/test/Driver/arm-compiler-rt.c
@@ -10,47 +10,47 @@
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -rtlib=compiler-rt -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix ARM-GNUEABI
-// ARM-GNUEABI: "{{.*[/\\]}}libclang_rt.builtins-arm.a"
+// ARM-GNUEABI: "{{.*[/\\]}}libclang_rt.builtins.a"
 
 // RUN: %clang -target arm-linux-gnueabi \
 // RUN: --sysroot=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -rtlib=compiler-rt -mfloat-abi=hard -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix ARM-GNUEABI-ABI
-// ARM-GNUEABI-ABI: "{{.*[/\\]}}libclang_rt.builtins-armhf.a"
+// ARM-GNUEABI-ABI: "{{.*[/\\]}}libclang_rt.builtins.a"
 
 // RUN: %clang -target arm-linux-gnueabihf \
 // RUN: --sysroot=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -rtlib=compiler-rt -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix ARM-GNUEABIHF
-// ARM-GNUEABIHF: "{{.*[/\\]}}libclang_rt.builtins-armhf.a"
+// ARM-GNUEABIHF: "{{.*[/\\]}}libclang_rt.builtins.a"
 
 // RUN: %clang -target arm-linux-gnueabihf \
 // RUN: --sysroot=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -rtlib=compiler-rt -mfloat-abi=soft -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix ARM-GNUEABIHF-ABI
-// ARM-GNUEABIHF-ABI: "{{.*[/\\]}}libclang_rt.builtins-arm.a"
+// ARM-GNUEABIHF-ABI: "{{.*[/\\]}}libclang_rt.builtins.a"
 
 // RUN: %clang -target arm-windows-itanium \
 // RUN: --sysroot=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -rtlib=compiler-rt -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix ARM-WINDOWS
-// ARM-WINDOWS: 

[clang] [Driver] Ensure ToolChain::LibraryPaths is not empty for non-Darwin (PR #87866)

2024-04-08 Thread Fangrui Song via cfe-commits

https://github.com/MaskRay closed 
https://github.com/llvm/llvm-project/pull/87866
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Ensure ToolChain::LibraryPaths is not empty for non-Darwin (PR #87866)

2024-04-08 Thread Fangrui Song via cfe-commits

https://github.com/MaskRay edited 
https://github.com/llvm/llvm-project/pull/87866
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Ensure ToolChain::LibraryPaths is not empty for non-Darwin (PR #87866)

2024-04-08 Thread Fangrui Song via cfe-commits

https://github.com/MaskRay updated 
https://github.com/llvm/llvm-project/pull/87866

>From 2847b8be2e4938c03aea57609842e2fee776d916 Mon Sep 17 00:00:00 2001
From: Fangrui Song 
Date: Fri, 5 Apr 2024 21:51:37 -0700
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.5-bogner
---
 clang/lib/Driver/ToolChain.cpp|  8 -
 clang/test/Driver/arm-compiler-rt.c   | 14 -
 clang/test/Driver/cl-link.c   | 16 +-
 clang/test/Driver/compiler-rt-unwind.c|  6 ++--
 clang/test/Driver/coverage-ld.c   |  8 ++---
 clang/test/Driver/instrprof-ld.c  | 16 +-
 clang/test/Driver/linux-ld.c  |  6 ++--
 clang/test/Driver/mingw-sanitizers.c  | 16 +-
 clang/test/Driver/msp430-toolchain.c  |  4 +--
 .../Driver/print-libgcc-file-name-clangrt.c   | 12 
 clang/test/Driver/print-runtime-dir.c |  6 
 clang/test/Driver/riscv32-toolchain-extra.c   |  6 ++--
 clang/test/Driver/riscv32-toolchain.c |  6 ++--
 clang/test/Driver/riscv64-toolchain-extra.c   |  6 ++--
 clang/test/Driver/riscv64-toolchain.c |  6 ++--
 clang/test/Driver/sanitizer-ld.c  | 30 +--
 clang/test/Driver/wasm-toolchain.c| 18 +--
 clang/test/Driver/wasm-toolchain.cpp  | 16 +-
 clang/test/Driver/windows-cross.c | 18 +--
 clang/test/Driver/zos-ld.c| 12 
 20 files changed, 115 insertions(+), 115 deletions(-)

diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 03450fc0f57b93..237092ed07e5dc 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -796,7 +796,13 @@ ToolChain::getTargetSubDirPath(StringRef BaseDir) const {
 std::optional ToolChain::getRuntimePath() const {
   SmallString<128> P(D.ResourceDir);
   llvm::sys::path::append(P, "lib");
-  return getTargetSubDirPath(P);
+  if (auto Ret = getTargetSubDirPath(P))
+return Ret;
+  // Darwin does not use per-target runtime directory.
+  if (Triple.isOSDarwin())
+return {};
+  llvm::sys::path::append(P, Triple.str());
+  return std::string(P);
 }
 
 std::optional ToolChain::getStdlibPath() const {
diff --git a/clang/test/Driver/arm-compiler-rt.c 
b/clang/test/Driver/arm-compiler-rt.c
index 5e9e528400d08e..cb6c29f48a7814 100644
--- a/clang/test/Driver/arm-compiler-rt.c
+++ b/clang/test/Driver/arm-compiler-rt.c
@@ -10,47 +10,47 @@
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -rtlib=compiler-rt -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix ARM-GNUEABI
-// ARM-GNUEABI: "{{.*[/\\]}}libclang_rt.builtins-arm.a"
+// ARM-GNUEABI: "{{.*[/\\]}}libclang_rt.builtins.a"
 
 // RUN: %clang -target arm-linux-gnueabi \
 // RUN: --sysroot=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -rtlib=compiler-rt -mfloat-abi=hard -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix ARM-GNUEABI-ABI
-// ARM-GNUEABI-ABI: "{{.*[/\\]}}libclang_rt.builtins-armhf.a"
+// ARM-GNUEABI-ABI: "{{.*[/\\]}}libclang_rt.builtins.a"
 
 // RUN: %clang -target arm-linux-gnueabihf \
 // RUN: --sysroot=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -rtlib=compiler-rt -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix ARM-GNUEABIHF
-// ARM-GNUEABIHF: "{{.*[/\\]}}libclang_rt.builtins-armhf.a"
+// ARM-GNUEABIHF: "{{.*[/\\]}}libclang_rt.builtins.a"
 
 // RUN: %clang -target arm-linux-gnueabihf \
 // RUN: --sysroot=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -rtlib=compiler-rt -mfloat-abi=soft -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix ARM-GNUEABIHF-ABI
-// ARM-GNUEABIHF-ABI: "{{.*[/\\]}}libclang_rt.builtins-arm.a"
+// ARM-GNUEABIHF-ABI: "{{.*[/\\]}}libclang_rt.builtins.a"
 
 // RUN: %clang -target arm-windows-itanium \
 // RUN: --sysroot=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -rtlib=compiler-rt -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix ARM-WINDOWS
-// ARM-WINDOWS: "{{.*[/\\]}}clang_rt.builtins-arm.lib"
+// ARM-WINDOWS: "{{.*[/\\]}}clang_rt.builtins.lib"
 
 // RUN: %clang -target arm-linux-androideabi \
 // RUN: --sysroot=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -rtlib=compiler-rt -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix ARM-ANDROID
-// ARM-ANDROID: "{{.*[/\\]}}libclang_rt.builtins-arm-android.a"
+// ARM-ANDROID: "{{.*[/\\]}}libclang_rt.builtins.a"
 
 // RUN: not %clang 

[clang] [clang-tools-extra] [libcxx] [clang] Enable sized deallocation by default in C++14 onwards (PR #83774)

2024-04-08 Thread Fangrui Song via cfe-commits

https://github.com/MaskRay edited 
https://github.com/llvm/llvm-project/pull/83774
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-tools-extra] [libcxx] [clang] Enable sized deallocation by default in C++14 onwards (PR #83774)

2024-04-08 Thread Fangrui Song via cfe-commits


@@ -7238,10 +7238,15 @@ void Clang::ConstructJob(Compilation , const 
JobAction ,
   Args.addOptInFlag(CmdArgs, options::OPT_frelaxed_template_template_args,
 options::OPT_fno_relaxed_template_template_args);
 
-  // -fsized-deallocation is off by default, as it is an ABI-breaking change 
for
-  // most platforms.
-  Args.addOptInFlag(CmdArgs, options::OPT_fsized_deallocation,
-options::OPT_fno_sized_deallocation);
+  // -fsized-deallocation is on by default in C++14 onwards and otherwise off
+  // by default.
+  if (Arg *A = Args.getLastArg(options::OPT_fsized_deallocation,
+   options::OPT_fno_sized_deallocation)) {
+if (A->getOption().matches(options::OPT_fno_sized_deallocation))
+  CmdArgs.push_back("-fno-sized-deallocation");

MaskRay wrote:

We should not pass -fno-sized-deallocation to cc1, as -fno-sized-deallocation 
is not a cc1 option and will cause a failure.

https://github.com/llvm/llvm-project/pull/83774
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang][llvm] Remove "implicit-section-name" attribute (PR #87906)

2024-04-08 Thread Arthur Eubanks via cfe-commits

https://github.com/aeubanks edited 
https://github.com/llvm/llvm-project/pull/87906
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang][llvm] Remove "implicit-section-name" attribute (PR #87906)

2024-04-08 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

> I'd suggest adding bitcode upgrade if it isn't too hard (I don't think it 
> should be?)

done



https://github.com/llvm/llvm-project/pull/87906
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang][llvm] Remove "implicit-section-name" attribute (PR #87906)

2024-04-08 Thread Arthur Eubanks via cfe-commits

https://github.com/aeubanks updated 
https://github.com/llvm/llvm-project/pull/87906

>From 7a9df42b4c4f4f1b02dc3158d24800f3d4b68d8f Mon Sep 17 00:00:00 2001
From: Arthur Eubanks 
Date: Sun, 7 Apr 2024 05:29:36 +
Subject: [PATCH 1/2] [clang][llvm] Remove "implicit-section-name" attribute

D33412/D33413 introduced this to support a clang pragma to set section
names for a symbol depending on if it would be placed in
bss/data/rodata/text, which may not be known until the backend. However,
for text we know that only functions will go there, so just
directly set the section in clang instead of going through a
completely separate attribute.
---
 clang/lib/CodeGen/CodeGenModule.cpp   |  2 +-
 clang/test/CodeGen/clang-sections-attribute.c |  3 ---
 clang/test/CodeGenCXX/clang-sections.cpp  | 18 ++---
 llvm/lib/CodeGen/TargetInstrInfo.cpp  |  3 +--
 .../CodeGen/TargetLoweringObjectFileImpl.cpp  | 11 +---
 llvm/lib/Target/TargetLoweringObjectFile.cpp  |  5 
 .../CodeGen/AArch64/clang-section-macho.ll| 22 ---
 llvm/test/CodeGen/ARM/clang-section.ll| 24 -
 .../Generic/machine-function-splitter.ll  | 27 +++
 .../basic-block-sections-pragma-sections.ll   |  4 +--
 10 files changed, 15 insertions(+), 104 deletions(-)
 delete mode 100644 llvm/test/CodeGen/AArch64/clang-section-macho.ll

diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 00b3bfcaa0bc25..f4dbfe7a21f83c 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -2627,7 +2627,7 @@ void CodeGenModule::setNonAliasAttributes(GlobalDecl GD,
 addUsedGlobal(F);
   if (auto *SA = D->getAttr())
 if (!D->getAttr())
-  F->addFnAttr("implicit-section-name", SA->getName());
+  F->setSection(SA->getName());
 
   llvm::AttrBuilder Attrs(F->getContext());
   if (GetCPUAndFeaturesAttributes(GD, Attrs)) {
diff --git a/clang/test/CodeGen/clang-sections-attribute.c 
b/clang/test/CodeGen/clang-sections-attribute.c
index 70ed24ed07a280..768bdd4d87649e 100644
--- a/clang/test/CodeGen/clang-sections-attribute.c
+++ b/clang/test/CodeGen/clang-sections-attribute.c
@@ -69,8 +69,5 @@ static int int_zvar;
 // CHECK: define internal void @int_fun() #0 section ".int_fun_attr"
 // CHECK: define internal void @int_fun2() #0 section ".int_fun2_attr"
 //
-// Function attributes should not include implicit-section-name.
-// CHECK-NOT: attributes #0 = {{.*}}implicit-section-name
-//
 // No other attribute group should be present in the file.
 // CHECK-NOT: attributes #1
diff --git a/clang/test/CodeGenCXX/clang-sections.cpp 
b/clang/test/CodeGenCXX/clang-sections.cpp
index a444f2d0cae59c..aa159e552b1b3c 100644
--- a/clang/test/CodeGenCXX/clang-sections.cpp
+++ b/clang/test/CodeGenCXX/clang-sections.cpp
@@ -81,24 +81,22 @@ int hoo(void) {
 //CHECK: @p ={{.*}} constant i32 7, align 4
 //CHECK: @_ZL5fptrs = internal constant [2 x ptr] [ptr @foo, ptr @goo], align 
{{4|8}} #3
 
-//CHECK: define{{.*}} i32 @foo() #5 {
-//CHECK: define{{.*}} i32 @goo() #6 {
-//CHECK: declare i32 @zoo(ptr noundef, ptr noundef) #7
-//CHECK: define{{.*}} i32 @hoo() #8 {
+//ELF: define{{.*}} i32 @foo(){{.*}} section "my_text.1" {
+//ELF: define{{.*}} i32 @goo(){{.*}} section "my_text.2" {
+//MACHO: define{{.*}} i32 @foo(){{.*}} section "__TEXT,__mytext1" {
+//MACHO: define{{.*}} i32 @goo(){{.*}} section "__TEXT,__mytext2" {
+
+// ensure zoo/hoo don't have a section
+//CHECK: declare i32 @zoo(ptr noundef, ptr noundef) #6{{$}}
+//CHECK: define{{.*}} i32 @hoo() #5 {
 
 //ELF: attributes #0 = { "bss-section"="my_bss.1" "data-section"="my_data.1" 
"rodata-section"="my_rodata.1" }
 //ELF: attributes #1 = { "data-section"="my_data.1" 
"rodata-section"="my_rodata.1" }
 //ELF: attributes #2 = { "bss-section"="my_bss.2" 
"rodata-section"="my_rodata.1" }
 //ELF: attributes #3 = { "bss-section"="my_bss.2" "data-section"="my_data.2" 
"relro-section"="my_relro.2" "rodata-section"="my_rodata.2" }
 //ELF: attributes #4 = { "relro-section"="my_relro.2" }
-//ELF: attributes #5 = { {{.*"implicit-section-name"="my_text.1".*}} }
-//ELF: attributes #6 = { {{.*"implicit-section-name"="my_text.2".*}} }
 //MACHO: attributes #0 = { "bss-section"="__BSS,__mybss1" 
"data-section"="__DATA,__mydata1" "rodata-section"="__RODATA,__myrodata1" }
 //MACHO: attributes #1 = { "data-section"="__DATA,__mydata1" 
"rodata-section"="__RODATA,__myrodata1" }
 //MACHO: attributes #2 = { "bss-section"="__BSS,__mybss2" 
"rodata-section"="__RODATA,__myrodata1" }
 //MACHO: attributes #3 = { "bss-section"="__BSS,__mybss2" 
"data-section"="__DATA,__mydata2" "relro-section"="__RELRO,__myrelro2" 
"rodata-section"="__RODATA,__myrodata2" }
 //MACHO: attributes #4 = { "relro-section"="__RELRO,__myrelro2" }
-//MACHO: attributes #5 = { {{.*"implicit-section-name"="__TEXT,__mytext1".*}} }
-//MACHO: attributes #6 = { 

[clang] [Clang][CodeGen] Fix `CanSkipVTablePointerInitialization` for dynamic classes with a trivial anonymous union (PR #84651)

2024-04-08 Thread Eli Friedman via cfe-commits

https://github.com/efriedma-quic closed 
https://github.com/llvm/llvm-project/pull/84651
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] f94bbfe - [Clang][CodeGen] Fix `CanSkipVTablePointerInitialization` for dynamic classes with a trivial anonymous union (#84651)

2024-04-08 Thread via cfe-commits

Author: Max Winkler
Date: 2024-04-08T15:24:08-07:00
New Revision: f94bbfed7cf08f60e20756dce8965d2c6ed70ea1

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

LOG: [Clang][CodeGen] Fix `CanSkipVTablePointerInitialization` for dynamic 
classes with a trivial anonymous union (#84651)

Hit this when trying upgrade an old project of mine. I couldn't find a
corresponding existing issue for this when spelunking the open issues
here on github.
Thankfully I can work-around it today with the `[[clang::no_destroy]]`
attribute for my use case. However it should still be properly fixed.

### Issue and History ###

https://godbolt.org/z/EYnhce8MK for reference.
All subsequent text below refers to the example in the godbolt above.

Anonymous unions never have their destructor invoked automatically.
Therefore we can skip vtable initialization of the destructor of a
dynamic class if that destructor effectively does no work.

This worked previously as the following check would be hit and return
true for the trivial anonymous union,
https://github.com/llvm/llvm-project/blob/release/18.x/clang/lib/CodeGen/CGClass.cpp#L1348,
resulting in the code skipping vtable initialization.

This was broken here
https://github.com/llvm/llvm-project/commit/982bbf404eba2d968afda5c674d4821652159c53
in relation to comments made on this review here
https://reviews.llvm.org/D10508.

### Fixes ###

The check the code is doing is correct however the return value is
inverted. We want to return true here since a field with anonymous union
never has its destructor invoked and thus effectively has a trivial
destructor body from the perspective of requiring vtable init in the
parent dynamic class.

Also added some extra missing unit tests to test for this use case and a
couple others.

Added: 


Modified: 
clang/lib/CodeGen/CGClass.cpp
clang/test/CodeGenCXX/skip-vtable-pointer-initialization.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp
index 8c1c8ee455d2e6..b3077292f4a206 100644
--- a/clang/lib/CodeGen/CGClass.cpp
+++ b/clang/lib/CodeGen/CGClass.cpp
@@ -1404,7 +1404,7 @@ FieldHasTrivialDestructorBody(ASTContext ,
 
   // The destructor for an implicit anonymous union member is never invoked.
   if (FieldClassDecl->isUnion() && FieldClassDecl->isAnonymousStructOrUnion())
-return false;
+return true;
 
   return HasTrivialDestructorBody(Context, FieldClassDecl, FieldClassDecl);
 }

diff  --git a/clang/test/CodeGenCXX/skip-vtable-pointer-initialization.cpp 
b/clang/test/CodeGenCXX/skip-vtable-pointer-initialization.cpp
index c001ce9b755d14..714ce3e67be7c6 100644
--- a/clang/test/CodeGenCXX/skip-vtable-pointer-initialization.cpp
+++ b/clang/test/CodeGenCXX/skip-vtable-pointer-initialization.cpp
@@ -198,3 +198,65 @@ struct C : virtual B {
 C::~C() {}
 
 }
+
+namespace Test10 {
+
+// Check that we don't initialize the vtable pointer in A::~A(), since the 
class has an anonymous union which
+// never has its destructor invoked.
+struct A {
+virtual void f();
+~A();
+
+union
+{
+int i;
+unsigned u;
+};
+};
+
+// CHECK-LABEL: define{{.*}} void @_ZN6Test101AD2Ev
+// CHECK-NOT: store ptr getelementptr inbounds ({ [3 x ptr] }, ptr 
@_ZTVN6Test101AE, i32 0, inrange i32 0, i32 2), ptr
+A::~A() {
+}
+
+}
+
+namespace Test11 {
+
+// Check that we don't initialize the vtable pointer in A::~A(), even if the 
base class has a non trivial destructor.
+struct Field {
+~Field();
+};
+
+struct A : public Field {
+virtual void f();
+~A();
+};
+
+// CHECK-LABEL: define{{.*}} void @_ZN6Test111AD2Ev
+// CHECK-NOT: store ptr getelementptr inbounds ({ [3 x ptr] }, ptr 
@_ZTVN6Test111AE, i32 0, inrange i32 0, i32 2), ptr
+A::~A() {
+}
+
+}
+
+namespace Test12 {
+
+// Check that we don't initialize the vtable pointer in A::~A(), since the 
class has an anonymous struct with trivial fields.
+struct A {
+virtual void f();
+~A();
+
+struct
+{
+int i;
+unsigned u;
+};
+};
+
+// CHECK-LABEL: define{{.*}} void @_ZN6Test121AD2Ev
+// CHECK-NOT: store ptr getelementptr inbounds ({ [3 x ptr] }, ptr 
@_ZTVN6Test121AE, i32 0, inrange i32 0, i32 2), ptr
+A::~A() {
+}
+
+}



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


[clang] [Clang][CodeGen] Fix `CanSkipVTablePointerInitialization` for dynamic classes with a trivial anonymous union (PR #84651)

2024-04-08 Thread Eli Friedman via cfe-commits

https://github.com/efriedma-quic approved this pull request.

LGTM

https://github.com/llvm/llvm-project/pull/84651
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang] Add support for scalable vectors in __builtin_reduce_* functions (PR #87750)

2024-04-08 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

Given there isn't any target-independent way to construct such a type, it feels 
sort of redundant.  (A user could easily implement this themselves.)  But I 
can't think of a reason to avoid adding this.

Please update documentation and add a release note.

https://github.com/llvm/llvm-project/pull/87750
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Revert "[AArch64] Add support for -ffixed-x30" (PR #88019)

2024-04-08 Thread Eli Friedman via cfe-commits

https://github.com/efriedma-quic closed 
https://github.com/llvm/llvm-project/pull/88019
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7ad481e - Revert "[AArch64] Add support for -ffixed-x30" (#88019)

2024-04-08 Thread via cfe-commits

Author: Eli Friedman
Date: 2024-04-08T15:16:00-07:00
New Revision: 7ad481e76c9bee5b9895ebfa0fdb52f31cb7de77

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

LOG: Revert "[AArch64] Add support for -ffixed-x30" (#88019)

This reverts commit e770153865c53c4fd72a68f23acff33c24e42a08.

This wasn't reviewed, and the functionality in question was
intentionally rejected the last time it was discussed in
https://reviews.llvm.org/D56305 .

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
clang/test/Driver/aarch64-fixed-x-register.c
llvm/lib/Target/AArch64/AArch64.td
llvm/test/CodeGen/AArch64/arm64-platform-reg.ll

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index 3e6e29584df3ac..2cd2b35ee51bc6 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -402,9 +402,6 @@ void aarch64::getAArch64TargetFeatures(const Driver ,
   if (Args.hasArg(options::OPT_ffixed_x28))
 Features.push_back("+reserve-x28");
 
-  if (Args.hasArg(options::OPT_ffixed_x30))
-Features.push_back("+reserve-x30");
-
   if (Args.hasArg(options::OPT_fcall_saved_x8))
 Features.push_back("+call-saved-x8");
 

diff  --git a/clang/test/Driver/aarch64-fixed-x-register.c 
b/clang/test/Driver/aarch64-fixed-x-register.c
index 29024fde412543..7fc3e3e61105df 100644
--- a/clang/test/Driver/aarch64-fixed-x-register.c
+++ b/clang/test/Driver/aarch64-fixed-x-register.c
@@ -94,10 +94,6 @@
 // RUN: FileCheck --check-prefix=CHECK-FIXED-X28 < %t %s
 // CHECK-FIXED-X28: "-target-feature" "+reserve-x28"
 
-// RUN: %clang --target=aarch64-none-gnu -ffixed-x30 -### %s 2> %t
-// RUN: FileCheck --check-prefix=CHECK-FIXED-X30 < %t %s
-// CHECK-FIXED-X30: "-target-feature" "+reserve-x30"
-
 // Test multiple of reserve-x# options together.
 // RUN: %clang --target=aarch64-none-gnu \
 // RUN: -ffixed-x1 \

diff  --git a/llvm/lib/Target/AArch64/AArch64.td 
b/llvm/lib/Target/AArch64/AArch64.td
index 3af427d526f80c..741c97a3dc009b 100644
--- a/llvm/lib/Target/AArch64/AArch64.td
+++ b/llvm/lib/Target/AArch64/AArch64.td
@@ -212,7 +212,7 @@ def FeatureStrictAlign : SubtargetFeature<"strict-align",
   "Disallow all unaligned memory "
   "access">;
 
-foreach i = {1-7,9-15,18,20-28,30} in
+foreach i = {1-7,9-15,18,20-28} in
 def FeatureReserveX#i : SubtargetFeature<"reserve-x"#i, 
"ReserveXRegister["#i#"]", "true",
  "Reserve X"#i#", making it 
unavailable "
  "as a GPR">;

diff  --git a/llvm/test/CodeGen/AArch64/arm64-platform-reg.ll 
b/llvm/test/CodeGen/AArch64/arm64-platform-reg.ll
index c598306c2de301..3df2ef7aa59fc8 100644
--- a/llvm/test/CodeGen/AArch64/arm64-platform-reg.ll
+++ b/llvm/test/CodeGen/AArch64/arm64-platform-reg.ll
@@ -34,7 +34,6 @@
 ; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x26 -o - %s | FileCheck %s 
--check-prefixes=CHECK-RESERVE,CHECK-RESERVE-X26
 ; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x27 -o - %s | FileCheck %s 
--check-prefixes=CHECK-RESERVE,CHECK-RESERVE-X27
 ; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x28 -o - %s | FileCheck %s 
--check-prefixes=CHECK-RESERVE,CHECK-RESERVE-X28
-; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x30 -o - %s | FileCheck %s 
--check-prefixes=CHECK-RESERVE,CHECK-RESERVE-X30
 
 ; Test multiple of reserve-x# options together.
 ; RUN: llc -mtriple=arm64-linux-gnu \
@@ -73,7 +72,6 @@
 ; RUN: -mattr=+reserve-x26 \
 ; RUN: -mattr=+reserve-x27 \
 ; RUN: -mattr=+reserve-x28 \
-; RUN: -mattr=+reserve-x30 \
 ; RUN: -reserve-regs-for-regalloc=X8,X16,X17,X19 \
 ; RUN: -o - %s | FileCheck %s \
 ; RUN: --check-prefix=CHECK-RESERVE \
@@ -104,8 +102,7 @@
 ; RUN: --check-prefix=CHECK-RESERVE-X25 \
 ; RUN: --check-prefix=CHECK-RESERVE-X26 \
 ; RUN: --check-prefix=CHECK-RESERVE-X27 \
-; RUN: --check-prefix=CHECK-RESERVE-X28 \
-; RUN: --check-prefix=CHECK-RESERVE-X30
+; RUN: --check-prefix=CHECK-RESERVE-X28
 
 ; x18 is reserved as a platform register on Darwin but not on other
 ; systems. Create loads of register pressure and make sure this is respected.
@@ -152,7 +149,6 @@ define void @keep_live() {
 ; CHECK-RESERVE-X26-NOT: ldr x26
 ; CHECK-RESERVE-X27-NOT: ldr x27
 ; CHECK-RESERVE-X28-NOT: ldr x28
-; CHECK-RESERVE-X30-NOT: ldr x30
 ; CHECK-RESERVE: Spill
 ; CHECK-RESERVE-NOT: ldr fp
 ; CHECK-RESERVE-X1-NOT: ldr x1,
@@ -182,7 +178,6 @@ define void @keep_live() {
 ; CHECK-RESERVE-X26-NOT: ldr x26
 ; CHECK-RESERVE-X27-NOT: ldr x27
 ; CHECK-RESERVE-X28-NOT: ldr x28
-; CHECK-RESERVE-X30-NOT: ldr x30
 ; CHECK-RESERVE: ret
   ret void
 }




[clang] [compiler-rt] Fix "[clang][UBSan] Add implicit conversion check for bitfields" (PR #87761)

2024-04-08 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

ok
please paste here what ever looks like real failure from the patch
buildbot does not sent me, as I am not on the blame list

https://github.com/llvm/llvm-project/pull/87761
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang][llvm] Remove "implicit-section-name" attribute (PR #87906)

2024-04-08 Thread Eli Friedman via cfe-commits

efriedma-quic wrote:

I'd suggest adding bitcode upgrade if it isn't too hard (I don't think it 
should be?)

Otherwise looks fine.

https://github.com/llvm/llvm-project/pull/87906
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ARM64EC] Fix compilation of intrin.h in ARM64EC mode. (PR #87717)

2024-04-08 Thread Eli Friedman via cfe-commits

https://github.com/efriedma-quic closed 
https://github.com/llvm/llvm-project/pull/87717
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 1950ebd - [ARM64EC] Fix compilation of intrin.h in ARM64EC mode. (#87717)

2024-04-08 Thread via cfe-commits

Author: Eli Friedman
Date: 2024-04-08T15:03:34-07:00
New Revision: 1950ebd17bbf1f2ad2a3799cd5966412ccfee9c4

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

LOG: [ARM64EC] Fix compilation of intrin.h in ARM64EC mode. (#87717)

intrin.h checks for x86_64. But the "x86_64" define is also defined for
ARM64EC, and we don't support all the intrinsics in ARM64EC mode. Fix
the preprocessor checks to handle this correctly. (If we actually need
some of these intrinsics in ARM64EC mode, we can revisit later.)

Not exactly sure how I didn't run into this issue before now... I think
I've built code that requires these headers, but maybe not since the
define fix landed.

Added: 


Modified: 
clang/lib/Headers/intrin.h
clang/lib/Headers/intrin0.h
clang/test/Headers/ms-intrin.cpp

Removed: 




diff  --git a/clang/lib/Headers/intrin.h b/clang/lib/Headers/intrin.h
index fd27955fbe002d..e890dcd7feeb8d 100644
--- a/clang/lib/Headers/intrin.h
+++ b/clang/lib/Headers/intrin.h
@@ -18,7 +18,7 @@
 #include 
 
 /* First include the standard intrinsics. */
-#if defined(__i386__) || defined(__x86_64__)
+#if defined(__i386__) || (defined(__x86_64__) && !defined(__arm64ec__))
 #include 
 #endif
 
@@ -166,7 +166,7 @@ unsigned __int32 xbegin(void);
 void _xend(void);
 
 /* These additional intrinsics are turned on in x64/amd64/x86_64 mode. */
-#ifdef __x86_64__
+#if defined(__x86_64__) && !defined(__arm64ec__)
 void __addgsbyte(unsigned long, unsigned char);
 void __addgsdword(unsigned long, unsigned long);
 void __addgsqword(unsigned long, unsigned __int64);
@@ -236,7 +236,8 @@ __int64 _mul128(__int64, __int64, __int64 *);
 
/**\
 |* movs, stos
 
\**/
-#if defined(__i386__) || defined(__x86_64__)
+
+#if defined(__i386__) || (defined(__x86_64__) && !defined(__arm64ec__))
 static __inline__ void __DEFAULT_FN_ATTRS __movsb(unsigned char *__dst,
   unsigned char const *__src,
   size_t __n) {
@@ -305,7 +306,7 @@ static __inline__ void __DEFAULT_FN_ATTRS __stosw(unsigned 
short *__dst,
: "memory");
 }
 #endif
-#ifdef __x86_64__
+#if defined(__x86_64__) && !defined(__arm64ec__)
 static __inline__ void __DEFAULT_FN_ATTRS __movsq(
 unsigned long long *__dst, unsigned long long const *__src, size_t __n) {
   __asm__ __volatile__("rep movsq"
@@ -324,7 +325,7 @@ static __inline__ void __DEFAULT_FN_ATTRS __stosq(unsigned 
__int64 *__dst,
 
/**\
 |* Misc
 
\**/
-#if defined(__i386__) || defined(__x86_64__)
+#if defined(__i386__) || (defined(__x86_64__) && !defined(__arm64ec__))
 static __inline__ void __DEFAULT_FN_ATTRS __halt(void) {
   __asm__ volatile("hlt");
 }
@@ -339,7 +340,7 @@ static __inline__ void __DEFAULT_FN_ATTRS __nop(void) {
 
/**\
 |* MS AArch64 specific
 
\**/
-#if defined(__aarch64__)
+#if defined(__aarch64__) || defined(__arm64ec__)
 unsigned __int64 __getReg(int);
 long _InterlockedAdd(long volatile *Addend, long Value);
 __int64 _InterlockedAdd64(__int64 volatile *Addend, __int64 Value);
@@ -383,7 +384,7 @@ void __cdecl __prefetch(void *);
 
/**\
 |* Privileged intrinsics
 
\**/
-#if defined(__i386__) || defined(__x86_64__)
+#if defined(__i386__) || (defined(__x86_64__) && !defined(__arm64ec__))
 static __inline__ unsigned __int64 __DEFAULT_FN_ATTRS
 __readmsr(unsigned long __register) {
   // Loads the contents of a 64-bit model specific register (MSR) specified in
@@ -397,7 +398,6 @@ __readmsr(unsigned long __register) {
   __asm__ ("rdmsr" : "=d"(__edx), "=a"(__eax) : "c"(__register));
   return (((unsigned __int64)__edx) << 32) | (unsigned __int64)__eax;
 }
-#endif
 
 static __inline__ unsigned __LPTRINT_TYPE__ __DEFAULT_FN_ATTRS __readcr3(void) 
{
   unsigned __LPTRINT_TYPE__ __cr3_val;
@@ -413,6 +413,7 @@ static __inline__ void __DEFAULT_FN_ATTRS
 __writecr3(unsigned __INTPTR_TYPE__ __cr3_val) {
   __asm__ ("mov {%0, %%cr3|cr3, %0}" : : "r"(__cr3_val) : "memory");
 }
+#endif
 
 #ifdef __cplusplus
 }

diff  --git a/clang/lib/Headers/intrin0.h b/clang/lib/Headers/intrin0.h
index 31f362ec84d5c5..866c8896617d22 100644
--- a/clang/lib/Headers/intrin0.h
+++ 

[clang-tools-extra] [clang-tidy] Ignore non-forwarded arguments if they are unnamed (PR #87832)

2024-04-08 Thread Danny Mösch via cfe-commits

https://github.com/SimplyDanny closed 
https://github.com/llvm/llvm-project/pull/87832
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 16b3e43 - [clang-tidy] Ignore non-forwarded arguments if they are unused (#87832)

2024-04-08 Thread via cfe-commits

Author: Danny Mösch
Date: 2024-04-08T23:54:29+02:00
New Revision: 16b3e43a030b0322e0d81debba3d63f145c8fd0b

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

LOG: [clang-tidy] Ignore non-forwarded arguments if they are unused (#87832)

Added: 


Modified: 
clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.cpp
clang-tools-extra/docs/ReleaseNotes.rst

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/missing-std-forward.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.cpp 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.cpp
index 87fd8adf997082..bbb35228ce47fb 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.cpp
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/MissingStdForwardCheck.cpp
@@ -9,8 +9,8 @@
 #include "MissingStdForwardCheck.h"
 #include "../utils/Matchers.h"
 #include "clang/AST/ASTContext.h"
-#include "clang/AST/ExprConcepts.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Basic/IdentifierTable.h"
 
 using namespace clang::ast_matchers;
 
@@ -79,6 +79,11 @@ AST_MATCHER_P(LambdaExpr, hasCaptureDefaultKind, 
LambdaCaptureDefault, Kind) {
   return Node.getCaptureDefault() == Kind;
 }
 
+AST_MATCHER(VarDecl, hasIdentifier) {
+  const IdentifierInfo *ID = Node.getIdentifier();
+  return ID != NULL && !ID->isPlaceholder();
+}
+
 } // namespace
 
 void MissingStdForwardCheck::registerMatchers(MatchFinder *Finder) {
@@ -125,12 +130,14 @@ void MissingStdForwardCheck::registerMatchers(MatchFinder 
*Finder) {
hasAncestor(expr(hasUnevaluatedContext());
 
   Finder->addMatcher(
-  parmVarDecl(parmVarDecl().bind("param"), isTemplateTypeParameter(),
-  hasAncestor(functionDecl().bind("func")),
-  hasAncestor(functionDecl(
-  isDefinition(), equalsBoundNode("func"), ToParam,
-  unless(anyOf(isDeleted(), hasDescendant(std::move(
-ForwardCallMatcher))),
+  parmVarDecl(
+  parmVarDecl().bind("param"), hasIdentifier(),
+  unless(hasAttr(attr::Kind::Unused)), isTemplateTypeParameter(),
+  hasAncestor(functionDecl().bind("func")),
+  hasAncestor(functionDecl(
+  isDefinition(), equalsBoundNode("func"), ToParam,
+  unless(anyOf(isDeleted(),
+   hasDescendant(std::move(ForwardCallMatcher))),
   this);
 }
 

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index bdd53f06e7e2f8..a7193e90c38da2 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -179,8 +179,9 @@ Changes in existing checks
 
 - Improved :doc:`cppcoreguidelines-missing-std-forward
   ` check by no longer
-  giving false positives for deleted functions and fix false negative when some
-  parameters are forwarded, but other aren't.
+  giving false positives for deleted functions, by fixing false negatives when 
only
+  a few parameters are forwarded and by ignoring parameters without a name 
(unused
+  arguments).
 
 - Improved :doc:`cppcoreguidelines-owning-memory
   ` check to properly handle

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/missing-std-forward.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/missing-std-forward.cpp
index 9a50eabf619bd5..8116db58c937d4 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/missing-std-forward.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/missing-std-forward.cpp
@@ -198,3 +198,16 @@ struct S {
 };
 
 } // namespace deleted_functions
+
+namespace unused_arguments {
+
+template
+void unused_argument1(F&&) {}
+
+template
+void unused_argument2([[maybe_unused]] F&& f) {}
+
+template
+void unused_argument3(F&& _) {}
+
+} // namespace unused_arguments



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


[clang] [clang-tools-extra] [Clang][Sema] Diagnose class member access expressions naming non-existent members of the current instantiation prior to instantiation in the absence of dependent base clas

2024-04-08 Thread Erich Keane via cfe-commits

https://github.com/erichkeane approved this pull request.


https://github.com/llvm/llvm-project/pull/84050
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Sema] Fix crash when 'this' is used in a dependent class scope function template specialization that instantiates to a static member function (PR #87541)

2024-04-08 Thread Erich Keane via cfe-commits

erichkeane wrote:

I'm OK with this, but would like @cor3ntin to take another look since he 
engaged earlier.


https://github.com/llvm/llvm-project/pull/87541
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][NFC] Adjust TBAA Base Info API (PR #73263)

2024-04-08 Thread Nathan Sidwell via cfe-commits

https://github.com/urnathan closed 
https://github.com/llvm/llvm-project/pull/73263
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 50a6738 - [clang][NFC] Adjust TBAA Base Info API (#73263)

2024-04-08 Thread via cfe-commits

Author: Nathan Sidwell
Date: 2024-04-08T17:32:13-04:00
New Revision: 50a6738636d1b1dda0c5887cf0623ee084854272

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

LOG: [clang][NFC] Adjust TBAA Base Info API (#73263)

A couple of cleanups.

1) remove an unnecessary check from isValidBaseType.

2) Add a new internal entrypoint 'getValidBaseTypeInfo', for uses where the 
type is known to be valid.

Added: 


Modified: 
clang/lib/CodeGen/CodeGenTBAA.cpp
clang/lib/CodeGen/CodeGenTBAA.h

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenTBAA.cpp 
b/clang/lib/CodeGen/CodeGenTBAA.cpp
index 837bf725da388a..da689ee6a13d70 100644
--- a/clang/lib/CodeGen/CodeGenTBAA.cpp
+++ b/clang/lib/CodeGen/CodeGenTBAA.cpp
@@ -98,8 +98,6 @@ static bool TypeHasMayAlias(QualType QTy) {
 
 /// Check if the given type is a valid base type to be used in access tags.
 static bool isValidBaseType(QualType QTy) {
-  if (QTy->isReferenceType())
-return false;
   if (const RecordType *TTy = QTy->getAs()) {
 const RecordDecl *RD = TTy->getDecl()->getDefinition();
 // Incomplete types are not valid base access types.
@@ -243,9 +241,10 @@ llvm::MDNode *CodeGenTBAA::getTypeInfo(QualType QTy) {
   // aggregate will result into the may-alias access descriptor, meaning all
   // subsequent accesses to direct and indirect members of that aggregate will
   // be considered may-alias too.
-  // TODO: Combine getTypeInfo() and getBaseTypeInfo() into a single function.
+  // TODO: Combine getTypeInfo() and getValidBaseTypeInfo() into a single
+  // function.
   if (isValidBaseType(QTy))
-return getBaseTypeInfo(QTy);
+return getValidBaseTypeInfo(QTy);
 
   const Type *Ty = Context.getCanonicalType(QTy).getTypePtr();
   if (llvm::MDNode *N = MetadataCache[Ty])
@@ -394,7 +393,7 @@ llvm::MDNode *CodeGenTBAA::getBaseTypeInfoHelper(const Type 
*Ty) {
 if (BaseRD->isEmpty())
   continue;
 llvm::MDNode *TypeNode = isValidBaseType(BaseQTy)
- ? getBaseTypeInfo(BaseQTy)
+ ? getValidBaseTypeInfo(BaseQTy)
  : getTypeInfo(BaseQTy);
 if (!TypeNode)
   return nullptr;
@@ -418,8 +417,9 @@ llvm::MDNode *CodeGenTBAA::getBaseTypeInfoHelper(const Type 
*Ty) {
   if (Field->isZeroSize(Context) || Field->isUnnamedBitfield())
 continue;
   QualType FieldQTy = Field->getType();
-  llvm::MDNode *TypeNode = isValidBaseType(FieldQTy) ?
-  getBaseTypeInfo(FieldQTy) : getTypeInfo(FieldQTy);
+  llvm::MDNode *TypeNode = isValidBaseType(FieldQTy)
+   ? getValidBaseTypeInfo(FieldQTy)
+   : getTypeInfo(FieldQTy);
   if (!TypeNode)
 return nullptr;
 
@@ -456,9 +456,8 @@ llvm::MDNode *CodeGenTBAA::getBaseTypeInfoHelper(const Type 
*Ty) {
   return nullptr;
 }
 
-llvm::MDNode *CodeGenTBAA::getBaseTypeInfo(QualType QTy) {
-  if (!isValidBaseType(QTy))
-return nullptr;
+llvm::MDNode *CodeGenTBAA::getValidBaseTypeInfo(QualType QTy) {
+  assert(isValidBaseType(QTy) && "Must be a valid base type");
 
   const Type *Ty = Context.getCanonicalType(QTy).getTypePtr();
 
@@ -477,6 +476,10 @@ llvm::MDNode *CodeGenTBAA::getBaseTypeInfo(QualType QTy) {
   return TypeNode;
 }
 
+llvm::MDNode *CodeGenTBAA::getBaseTypeInfo(QualType QTy) {
+  return isValidBaseType(QTy) ? getValidBaseTypeInfo(QTy) : nullptr;
+}
+
 llvm::MDNode *CodeGenTBAA::getAccessTagInfo(TBAAAccessInfo Info) {
   assert(!Info.isIncomplete() && "Access to an object of an incomplete type!");
 

diff  --git a/clang/lib/CodeGen/CodeGenTBAA.h b/clang/lib/CodeGen/CodeGenTBAA.h
index aa6da2731a4163..5d9ecec3ff0fe2 100644
--- a/clang/lib/CodeGen/CodeGenTBAA.h
+++ b/clang/lib/CodeGen/CodeGenTBAA.h
@@ -168,6 +168,10 @@ class CodeGenTBAA {
   /// used to describe accesses to objects of the given base type.
   llvm::MDNode *getBaseTypeInfoHelper(const Type *Ty);
 
+  /// getValidBaseTypeInfo - Return metadata that describes the given base
+  /// access type. The type must be suitable.
+  llvm::MDNode *getValidBaseTypeInfo(QualType QTy);
+
 public:
   CodeGenTBAA(ASTContext , CodeGenTypes , llvm::Module ,
   const CodeGenOptions , const LangOptions ,
@@ -190,8 +194,9 @@ class CodeGenTBAA {
   /// the given type.
   llvm::MDNode *getTBAAStructInfo(QualType QTy);
 
-  /// getBaseTypeInfo - Get metadata that describes the given base access type.
-  /// Return null if the type is not suitable for use in TBAA access tags.
+  /// getBaseTypeInfo - Get metadata that describes the given base access
+  /// type. Return null if the type is not suitable for use in TBAA access
+  /// tags.
   llvm::MDNode *getBaseTypeInfo(QualType QTy);
 
   

[clang] Update __cpp_concepts macro (PR #87998)

2024-04-08 Thread Erich Keane via cfe-commits

https://github.com/erichkeane updated 
https://github.com/llvm/llvm-project/pull/87998

>From 477ca3032a26467dfb67ef5d2f9b54bb2f958a33 Mon Sep 17 00:00:00 2001
From: erichkeane 
Date: Mon, 8 Apr 2024 07:28:50 -0700
Subject: [PATCH 1/2] Update __cpp_concepts macro

After discussion with a few others, and seeing the state of our concepts
support, I believe it is worth trying to see if we can update this for
Clang19.  The forcing function is that libstdc++'s  header is
guarded by this macro, so we need to update it to support that.
---
 clang/docs/ReleaseNotes.rst |  5 +
 clang/lib/Frontend/InitPreprocessor.cpp |  5 +
 clang/test/Lexer/cxx-features.cpp   |  2 +-
 clang/www/cxx_status.html   | 12 ++--
 4 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 28e8ddb3c41c3e..4f02459ca1f09f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -110,6 +110,11 @@ C++20 Feature Support
   templates (`P1814R0 `_).
   (#GH54051).
 
+- __cpp_concepts macro now updated to `202002L`, as we are confident that,
+  modulo a handful of bugs and core issues, that our concepts implementation is
+  sufficient. This should enable libstdc++'s `` to work correctly in
+  clang.
+
 C++23 Feature Support
 ^
 
diff --git a/clang/lib/Frontend/InitPreprocessor.cpp 
b/clang/lib/Frontend/InitPreprocessor.cpp
index 48ad92063bd461..84069e96f41464 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -720,10 +720,7 @@ static void InitializeCPlusPlusFeatureTestMacros(const 
LangOptions ,
   if (LangOpts.CPlusPlus20) {
 Builder.defineMacro("__cpp_aggregate_paren_init", "201902L");
 
-// P0848 is implemented, but we're still waiting for other concepts
-// issues to be addressed before bumping __cpp_concepts up to 202002L.
-// Refer to the discussion of this at https://reviews.llvm.org/D128619.
-Builder.defineMacro("__cpp_concepts", "201907L");
+Builder.defineMacro("__cpp_concepts", "202002");
 Builder.defineMacro("__cpp_conditional_explicit", "201806L");
 Builder.defineMacro("__cpp_consteval", "202211L");
 Builder.defineMacro("__cpp_constexpr_dynamic_alloc", "201907L");
diff --git a/clang/test/Lexer/cxx-features.cpp 
b/clang/test/Lexer/cxx-features.cpp
index 9496746c6fd663..1de32498cd345b 100644
--- a/clang/test/Lexer/cxx-features.cpp
+++ b/clang/test/Lexer/cxx-features.cpp
@@ -85,7 +85,7 @@
 #error "wrong value for __cpp_char8_t"
 #endif
 
-#if check(concepts, 0, 0, 0, 0, 201907, 201907, 201907)
+#if check(concepts, 0, 0, 0, 0, 202002, 202002, 202002)
 #error "wrong value for __cpp_concepts"
 #endif
 
diff --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html
index c1d95dadbb27e2..130148c7420fa1 100755
--- a/clang/www/cxx_status.html
+++ b/clang/www/cxx_status.html
@@ -544,16 +544,8 @@ C++20 implementation status
   

 https://wg21.link/p0848r3;>P0848R3
-
-  
-Clang 16 (Partial)
-Because of other concepts implementation deficits, the 
__cpp_concepts macro is not yet set to 202002L.
-Also, the related defect reports https://wg21.link/cwg1496;>DR1496 and
-https://wg21.link/cwg1734;>DR1734 are not yet 
implemented. Accordingly, deleted
-special member functions are treated as eligible even though they 
shouldn't be.
-  
-
-
+Clang 19
+  
   
 https://wg21.link/p1616r1;>P1616R1
 Clang 10

>From d9a0b262c2e2f4bfcc6d6adfc401cd7743075093 Mon Sep 17 00:00:00 2001
From: erichkeane 
Date: Mon, 8 Apr 2024 14:24:41 -0700
Subject: [PATCH 2/2] update release notes as suggested

---
 clang/docs/ReleaseNotes.rst | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 4f02459ca1f09f..7647a2898de650 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -110,10 +110,9 @@ C++20 Feature Support
   templates (`P1814R0 `_).
   (#GH54051).
 
-- __cpp_concepts macro now updated to `202002L`, as we are confident that,
-  modulo a handful of bugs and core issues, that our concepts implementation is
-  sufficient. This should enable libstdc++'s `` to work correctly in
-  clang.
+- We have sufficient confidence and experience with the concepts implementation
+  to update the ``__cpp_concepts`` macro to `202002L`. This enables
+   from libstdc++ to work correctly with Clang.
 
 C++23 Feature Support
 ^

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


[clang] [compiler-rt] Fix "[clang][UBSan] Add implicit conversion check for bitfields" (PR #87761)

2024-04-08 Thread Axel Lundberg via cfe-commits

Zonotora wrote:

@vitalybuka  Well, this is awkward, fails due to:

https://lab.llvm.org/buildbot/#/builders/127/builds/64260
C:\b\slave\sanitizer-windows\llvm-project\compiler-rt\test\ubsan\TestCases\ImplicitConversion\bitfield-conversion.c:36:3:
 error: unknown type name '_Bool'

Some other testcases failing as well. Seems to be flaky, no?

https://github.com/llvm/llvm-project/pull/87761
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Sema] Fix crash when 'this' is used in a dependent class scope function template specialization that instantiates to a static member function (PR #87541)

2024-04-08 Thread Krystian Stasiowski via cfe-commits

sdkrystian wrote:

Ping @erichkeane :)

https://github.com/llvm/llvm-project/pull/87541
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Sema] Implement approved resolution for CWG2858 (PR #88042)

2024-04-08 Thread Erich Keane via cfe-commits

https://github.com/erichkeane approved this pull request.

This seems right to me, thanks!

https://github.com/llvm/llvm-project/pull/88042
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Sema] Implement approved resolution for CWG2858 (PR #88042)

2024-04-08 Thread Krystian Stasiowski via cfe-commits

https://github.com/sdkrystian edited 
https://github.com/llvm/llvm-project/pull/88042
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Sema] Implement approved resolution for CWG2858 (PR #88042)

2024-04-08 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Krystian Stasiowski (sdkrystian)


Changes

The approved resolution for 
[CWG2858](https://cplusplus.github.io/CWG/issues/2858.html) changes 
[[expr.prim.id.qual] p2 sentence 
2](https://eel.is/c++draft/expr.prim.id.qual#2) to read:
 A declarative _nested-name-specifier_ shall not have a 
_computed-type-specifier_.

This patch implements the approved resolution. Since we don't consider 
_nested-name-specifiers_ in friend declarations to be declarative (yet), it 
currently isn't possible to write a test that would produce this diagnostic 
(`diagnoseQualifiedDeclaration` is never called if the `DeclContext` can't be 
computed). Nevertheless, tests were added which will produce the diagnostic 
once we start calling `diagnoseQualifiedDeclaration` for friend declarations. 

---
Full diff: https://github.com/llvm/llvm-project/pull/88042.diff


3 Files Affected:

- (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+3-4) 
- (modified) clang/lib/Sema/SemaDecl.cpp (+6-7) 
- (modified) 
clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp (+16) 


``diff
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index a1dda2d2461c31..2b9077173aa426 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2402,10 +2402,6 @@ def err_selected_explicit_constructor : Error<
 def note_explicit_ctor_deduction_guide_here : Note<
   "explicit %select{constructor|deduction guide}0 declared here">;
 
-// C++11 decltype
-def err_decltype_in_declarator : Error<
-"'decltype' cannot be used to name a declaration">;
-
 // C++11 auto
 def warn_cxx98_compat_auto_type_specifier : Warning<
   "'auto' type specifier is incompatible with C++98">,
@@ -8302,6 +8298,9 @@ def ext_template_after_declarative_nns : ExtWarn<
 def ext_alias_template_in_declarative_nns : ExtWarn<
   "a declarative nested name specifier cannot name an alias template">,
   InGroup>;
+def err_computed_type_in_declarative_nns  : Error<
+  "%select{a pack indexing type|'decltype'}0 cannot be used in "
+  "a declarative nested name specifier">;
 
 def err_no_typeid_with_fno_rtti : Error<
   "use of typeid requires -frtti">;
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index c790dab72dd721..1ba6b3beb1c758 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -6335,16 +6335,15 @@ bool Sema::diagnoseQualifiedDeclaration(CXXScopeSpec 
, DeclContext *DC,
 if (TST->isDependentType() && TST->isTypeAlias())
   Diag(Loc, diag::ext_alias_template_in_declarative_nns)
   << SpecLoc.getLocalSourceRange();
-  } else if (T->isDecltypeType()) {
+  } else if (T->isDecltypeType() || T->getAsAdjusted()) {
 // C++23 [expr.prim.id.qual]p2:
 //   [...] A declarative nested-name-specifier shall not have a
-//   decltype-specifier.
+//   computed-type-specifier.
 //
-// FIXME: This wording appears to be defective as it does not forbid
-// declarative nested-name-specifiers with pack-index-specifiers.
-// See https://github.com/cplusplus/CWG/issues/499.
-Diag(Loc, diag::err_decltype_in_declarator)
-<< SpecLoc.getTypeLoc().getSourceRange();
+// CWG2858 changed this from 'decltype-specifier' to
+// 'computed-type-specifier'.
+Diag(Loc, diag::err_computed_type_in_declarative_nns)
+<< T->isDecltypeType() << SpecLoc.getTypeLoc().getSourceRange();
   }
 }
   } while ((SpecLoc = SpecLoc.getPrefix()));
diff --git 
a/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp 
b/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp
index c73ffa55a26a31..5da13cc22abef2 100644
--- a/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -std=c++2c -verify %s
 
 template
 struct A {
@@ -27,3 +28,18 @@ namespace N {
 
 template
 void N::E::f() { } // expected-warning {{a declarative nested name 
specifier cannot name an alias template}}
+
+#if __cplusplus > 202302L
+template
+struct A {
+  // FIXME: The nested-name-specifier in the following friend declarations are 
declarative,
+  // but we don't treat them as such (yet).
+  friend void Ts...[0]::f();
+  template
+  friend void Ts...[0]::g();
+
+  friend struct Ts...[0]::B;
+  template
+  friend struct Ts...[0]::C; // expected-warning{{is not supported; ignoring 
this friend declaration}}
+};
+#endif

``




https://github.com/llvm/llvm-project/pull/88042
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Sema] Implement approved resolution for CWG2858 (PR #88042)

2024-04-08 Thread Krystian Stasiowski via cfe-commits

https://github.com/sdkrystian updated 
https://github.com/llvm/llvm-project/pull/88042

>From 9c3b78f1f37049224f31e3bcd07ae8d762b760d1 Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski 
Date: Mon, 8 Apr 2024 09:46:08 -0400
Subject: [PATCH] [Clang][Sema] Implement approved resolution for CWG2858

---
 clang/include/clang/Basic/DiagnosticSemaKinds.td |  7 +++
 clang/lib/Sema/SemaDecl.cpp  | 13 ++---
 .../expr.prim.id/expr.prim.id.qual/p3.cpp| 16 
 3 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index a1dda2d2461c31..2b9077173aa426 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2402,10 +2402,6 @@ def err_selected_explicit_constructor : Error<
 def note_explicit_ctor_deduction_guide_here : Note<
   "explicit %select{constructor|deduction guide}0 declared here">;
 
-// C++11 decltype
-def err_decltype_in_declarator : Error<
-"'decltype' cannot be used to name a declaration">;
-
 // C++11 auto
 def warn_cxx98_compat_auto_type_specifier : Warning<
   "'auto' type specifier is incompatible with C++98">,
@@ -8302,6 +8298,9 @@ def ext_template_after_declarative_nns : ExtWarn<
 def ext_alias_template_in_declarative_nns : ExtWarn<
   "a declarative nested name specifier cannot name an alias template">,
   InGroup>;
+def err_computed_type_in_declarative_nns  : Error<
+  "%select{a pack indexing type|'decltype'}0 cannot be used in "
+  "a declarative nested name specifier">;
 
 def err_no_typeid_with_fno_rtti : Error<
   "use of typeid requires -frtti">;
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index c790dab72dd721..1ba6b3beb1c758 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -6335,16 +6335,15 @@ bool Sema::diagnoseQualifiedDeclaration(CXXScopeSpec 
, DeclContext *DC,
 if (TST->isDependentType() && TST->isTypeAlias())
   Diag(Loc, diag::ext_alias_template_in_declarative_nns)
   << SpecLoc.getLocalSourceRange();
-  } else if (T->isDecltypeType()) {
+  } else if (T->isDecltypeType() || T->getAsAdjusted()) {
 // C++23 [expr.prim.id.qual]p2:
 //   [...] A declarative nested-name-specifier shall not have a
-//   decltype-specifier.
+//   computed-type-specifier.
 //
-// FIXME: This wording appears to be defective as it does not forbid
-// declarative nested-name-specifiers with pack-index-specifiers.
-// See https://github.com/cplusplus/CWG/issues/499.
-Diag(Loc, diag::err_decltype_in_declarator)
-<< SpecLoc.getTypeLoc().getSourceRange();
+// CWG2858 changed this from 'decltype-specifier' to
+// 'computed-type-specifier'.
+Diag(Loc, diag::err_computed_type_in_declarative_nns)
+<< T->isDecltypeType() << SpecLoc.getTypeLoc().getSourceRange();
   }
 }
   } while ((SpecLoc = SpecLoc.getPrefix()));
diff --git 
a/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp 
b/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp
index c73ffa55a26a31..5da13cc22abef2 100644
--- a/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -std=c++2c -verify %s
 
 template
 struct A {
@@ -27,3 +28,18 @@ namespace N {
 
 template
 void N::E::f() { } // expected-warning {{a declarative nested name 
specifier cannot name an alias template}}
+
+#if __cplusplus > 202302L
+template
+struct A {
+  // FIXME: The nested-name-specifier in the following friend declarations are 
declarative,
+  // but we don't treat them as such (yet).
+  friend void Ts...[0]::f();
+  template
+  friend void Ts...[0]::g();
+
+  friend struct Ts...[0]::B;
+  template
+  friend struct Ts...[0]::C; // expected-warning{{is not supported; ignoring 
this friend declaration}}
+};
+#endif

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


[clang] [Clang][Sema] Implement approved resolution for CWG2858 (PR #88042)

2024-04-08 Thread Krystian Stasiowski via cfe-commits

https://github.com/sdkrystian created 
https://github.com/llvm/llvm-project/pull/88042

The approved resolution for 
[CWG2858](https://cplusplus.github.io/CWG/issues/2858.html) changes 
[[expr.prim.id.qual] p2 sentence 
2](https://eel.is/c++draft/expr.prim.id.qual#2) to read:
> A declarative _nested-name-specifier_ shall not have a 
> _computed-type-specifier_.

This patch implements the approved resolution. Since we don't consider 
_nested-name-specifiers_ in friend declarations to be declarative (yet), it 
currently isn't possible to write a test that would produce this diagnostic 
(`diagnoseQualifiedDeclaration` is never called if the `DeclContext` can't be 
computed). Nevertheless, tests were added which will produce the diagnostic 
once we start calling `diagnoseQualifiedDeclaration` for friend declarations. 

>From 5f06642fa89d517adbb11157fa88352bd86d79bf Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski 
Date: Mon, 8 Apr 2024 09:46:08 -0400
Subject: [PATCH] [Clang][Sema] Implement accepted resolution for CWG2858

---
 clang/include/clang/Basic/DiagnosticSemaKinds.td |  7 +++
 clang/lib/Sema/SemaDecl.cpp  | 13 ++---
 .../expr.prim.id/expr.prim.id.qual/p3.cpp| 16 
 3 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index a1dda2d2461c31..2b9077173aa426 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2402,10 +2402,6 @@ def err_selected_explicit_constructor : Error<
 def note_explicit_ctor_deduction_guide_here : Note<
   "explicit %select{constructor|deduction guide}0 declared here">;
 
-// C++11 decltype
-def err_decltype_in_declarator : Error<
-"'decltype' cannot be used to name a declaration">;
-
 // C++11 auto
 def warn_cxx98_compat_auto_type_specifier : Warning<
   "'auto' type specifier is incompatible with C++98">,
@@ -8302,6 +8298,9 @@ def ext_template_after_declarative_nns : ExtWarn<
 def ext_alias_template_in_declarative_nns : ExtWarn<
   "a declarative nested name specifier cannot name an alias template">,
   InGroup>;
+def err_computed_type_in_declarative_nns  : Error<
+  "%select{a pack indexing type|'decltype'}0 cannot be used in "
+  "a declarative nested name specifier">;
 
 def err_no_typeid_with_fno_rtti : Error<
   "use of typeid requires -frtti">;
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index c790dab72dd721..1ba6b3beb1c758 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -6335,16 +6335,15 @@ bool Sema::diagnoseQualifiedDeclaration(CXXScopeSpec 
, DeclContext *DC,
 if (TST->isDependentType() && TST->isTypeAlias())
   Diag(Loc, diag::ext_alias_template_in_declarative_nns)
   << SpecLoc.getLocalSourceRange();
-  } else if (T->isDecltypeType()) {
+  } else if (T->isDecltypeType() || T->getAsAdjusted()) {
 // C++23 [expr.prim.id.qual]p2:
 //   [...] A declarative nested-name-specifier shall not have a
-//   decltype-specifier.
+//   computed-type-specifier.
 //
-// FIXME: This wording appears to be defective as it does not forbid
-// declarative nested-name-specifiers with pack-index-specifiers.
-// See https://github.com/cplusplus/CWG/issues/499.
-Diag(Loc, diag::err_decltype_in_declarator)
-<< SpecLoc.getTypeLoc().getSourceRange();
+// CWG2858 changed this from 'decltype-specifier' to
+// 'computed-type-specifier'.
+Diag(Loc, diag::err_computed_type_in_declarative_nns)
+<< T->isDecltypeType() << SpecLoc.getTypeLoc().getSourceRange();
   }
 }
   } while ((SpecLoc = SpecLoc.getPrefix()));
diff --git 
a/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp 
b/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp
index c73ffa55a26a31..5da13cc22abef2 100644
--- a/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp
+++ b/clang/test/CXX/expr/expr.prim/expr.prim.id/expr.prim.id.qual/p3.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -verify %s
+// RUN: %clang_cc1 -std=c++2c -verify %s
 
 template
 struct A {
@@ -27,3 +28,18 @@ namespace N {
 
 template
 void N::E::f() { } // expected-warning {{a declarative nested name 
specifier cannot name an alias template}}
+
+#if __cplusplus > 202302L
+template
+struct A {
+  // FIXME: The nested-name-specifier in the following friend declarations are 
declarative,
+  // but we don't treat them as such (yet).
+  friend void Ts...[0]::f();
+  template
+  friend void Ts...[0]::g();
+
+  friend struct Ts...[0]::B;
+  template
+  friend struct Ts...[0]::C; // expected-warning{{is not supported; ignoring 
this friend declaration}}
+};
+#endif

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

[clang] [clang][deps] Cache `VFS::getRealPath()` (PR #68645)

2024-04-08 Thread Jan Svoboda via cfe-commits


@@ -230,6 +251,26 @@ class DependencyScanningFilesystemLocalCache {
 assert(InsertedEntry ==  && "entry already present");
 return *InsertedEntry;
   }
+
+  /// Returns real path associated with the filename or nullptr if none is
+  /// found.
+  const CachedRealPath *findRealPathByFilename(StringRef Filename) const {
+assert(llvm::sys::path::is_absolute_gnu(Filename));
+auto It = RealPathCache.find(Filename);
+return It == RealPathCache.end() ? nullptr : It->getValue();
+  }
+
+  /// Associates the given real path with the filename and returns the given
+  /// entry pointer (for convenience).
+  const CachedRealPath &
+  insertRealPathForFilename(StringRef Filename,
+const CachedRealPath ) {

jansvoboda11 wrote:

I see your point. I used a reference here to be consistent with existing code 
in this file. I think the original motivation for using references was the 
"non-null pointer" aspect of it. I tried converting all uses of `const 
CachedFileSystemEntry &` in the existing code to pointers, but that's 
impossible to understand. Doing that just for arguments to insert-like 
functions is a bit better, but I'm not sure it's clear win in 
readability/understandability.

https://github.com/llvm/llvm-project/pull/68645
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [openmp] [Libomp] Place generated OpenMP headers into build resource directory (PR #88007)

2024-04-08 Thread Joseph Huber via cfe-commits

https://github.com/jhuber6 closed 
https://github.com/llvm/llvm-project/pull/88007
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8671429 - [Libomp] Place generated OpenMP headers into build resource directory (#88007)

2024-04-08 Thread via cfe-commits

Author: Joseph Huber
Date: 2024-04-08T15:26:54-05:00
New Revision: 8671429151d5e67d3f21a737809953ae8bdfbfde

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

LOG: [Libomp] Place generated OpenMP headers into build resource directory 
(#88007)

Summary:
These headers are a part of the compiler's resource directory once
installed. However, they are currently placed in the binary directory
temporarily. This makes it more difficult to use the compiler out of the
build directory and will cause issues when moving to `liboffload`. This
patch changes the logic to write these instead to the copmiler's
resource directory inside of the build tree.

NOTE: This doesn't change the Fortran headers, I don't know enough about
those and it won't use the same directory.

Added: 


Modified: 
clang/test/Headers/Inputs/include/stdint.h
openmp/runtime/src/CMakeLists.txt

Removed: 




diff  --git a/clang/test/Headers/Inputs/include/stdint.h 
b/clang/test/Headers/Inputs/include/stdint.h
index 5bf26a7b67b066..67b27b8dfc7b92 100644
--- a/clang/test/Headers/Inputs/include/stdint.h
+++ b/clang/test/Headers/Inputs/include/stdint.h
@@ -16,4 +16,12 @@ typedef unsigned __INTPTR_TYPE__ uintptr_t;
 #error Every target should have __INTPTR_TYPE__
 #endif
 
+#ifdef __INTPTR_MAX__
+#define  INTPTR_MAX__INTPTR_MAX__
+#endif
+
+#ifdef __UINTPTR_MAX__
+#define UINTPTR_MAX   __UINTPTR_MAX__
+#endif
+
 #endif /* STDINT_H */

diff  --git a/openmp/runtime/src/CMakeLists.txt 
b/openmp/runtime/src/CMakeLists.txt
index f05bcabb441742..000d02c33dc093 100644
--- a/openmp/runtime/src/CMakeLists.txt
+++ b/openmp/runtime/src/CMakeLists.txt
@@ -10,12 +10,19 @@
 
 include(ExtendPath)
 
+# The generated headers will be placed in clang's resource directory if 
present.
+if(${OPENMP_STANDALONE_BUILD})
+  set(LIBOMP_HEADERS_INTDIR ${CMAKE_CURRENT_BINARY_DIR})
+else()
+  set(LIBOMP_HEADERS_INTDIR ${LLVM_BINARY_DIR}/${LIBOMP_HEADERS_INSTALL_PATH})
+endif()
+
 # Configure omp.h, kmp_config.h and omp-tools.h if necessary
-configure_file(${LIBOMP_INC_DIR}/omp.h.var omp.h @ONLY)
-configure_file(${LIBOMP_INC_DIR}/ompx.h.var ompx.h @ONLY)
-configure_file(kmp_config.h.cmake kmp_config.h @ONLY)
+configure_file(${LIBOMP_INC_DIR}/omp.h.var ${LIBOMP_HEADERS_INTDIR}/omp.h 
@ONLY)
+configure_file(${LIBOMP_INC_DIR}/ompx.h.var ${LIBOMP_HEADERS_INTDIR}/ompx.h 
@ONLY)
+configure_file(kmp_config.h.cmake ${LIBOMP_HEADERS_INTDIR}/kmp_config.h @ONLY)
 if(${LIBOMP_OMPT_SUPPORT})
-  configure_file(${LIBOMP_INC_DIR}/omp-tools.h.var omp-tools.h @ONLY)
+  configure_file(${LIBOMP_INC_DIR}/omp-tools.h.var 
${LIBOMP_HEADERS_INTDIR}/omp-tools.h @ONLY)
 endif()
 
 # Generate message catalog files: kmp_i18n_id.inc and kmp_i18n_default.inc
@@ -419,15 +426,15 @@ else()
 endif()
 install(
   FILES
-  ${CMAKE_CURRENT_BINARY_DIR}/omp.h
-  ${CMAKE_CURRENT_BINARY_DIR}/ompx.h
+  ${LIBOMP_HEADERS_INTDIR}/omp.h
+  ${LIBOMP_HEADERS_INTDIR}/ompx.h
   DESTINATION ${LIBOMP_HEADERS_INSTALL_PATH}
 )
 if(${LIBOMP_OMPT_SUPPORT})
-  install(FILES ${CMAKE_CURRENT_BINARY_DIR}/omp-tools.h DESTINATION 
${LIBOMP_HEADERS_INSTALL_PATH})
+  install(FILES ${LIBOMP_HEADERS_INTDIR}/omp-tools.h DESTINATION 
${LIBOMP_HEADERS_INSTALL_PATH})
   # install under legacy name ompt.h
-  install(FILES ${CMAKE_CURRENT_BINARY_DIR}/omp-tools.h DESTINATION 
${LIBOMP_HEADERS_INSTALL_PATH} RENAME ompt.h)
-  set(LIBOMP_OMP_TOOLS_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)
+  install(FILES ${LIBOMP_HEADERS_INTDIR}/omp-tools.h DESTINATION 
${LIBOMP_HEADERS_INSTALL_PATH} RENAME ompt.h)
+  set(LIBOMP_OMP_TOOLS_INCLUDE_DIR ${LIBOMP_HEADERS_INTDIR} PARENT_SCOPE)
 endif()
 if(${BUILD_FORTRAN_MODULES})
   set (destination ${LIBOMP_HEADERS_INSTALL_PATH})



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


[clang] [openmp] [Libomp] Place generated OpenMP headers into build resource directory (PR #88007)

2024-04-08 Thread Shilei Tian via cfe-commits

https://github.com/shiltian approved this pull request.

LGTM

https://github.com/llvm/llvm-project/pull/88007
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [openmp] [Libomp] Place generated OpenMP headers into build resource directory (PR #88007)

2024-04-08 Thread Shilei Tian via cfe-commits


@@ -16,4 +16,12 @@ typedef unsigned __INTPTR_TYPE__ uintptr_t;
 #error Every target should have __INTPTR_TYPE__
 #endif
 
+#ifdef __INTPTR_MAX__
+#define  INTPTR_MAX__INTPTR_MAX__
+#endif
+
+#ifdef __UINTPTR_MAX__
+#define UINTPTR_MAX   __UINTPTR_MAX__
+#endif
+

shiltian wrote:

This header is useful when invoking front end directly such that we don't need 
to pass things like `-internal-isystem` which usually are added by compiler 
driver.

https://github.com/llvm/llvm-project/pull/88007
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Revert "[AArch64] Add support for -ffixed-x30" (PR #88019)

2024-04-08 Thread Francis Visoiu Mistrih via cfe-commits

https://github.com/francisvm approved this pull request.

Makes sense, LGTM.

https://github.com/llvm/llvm-project/pull/88019
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   4   >