[PATCH] D156859: [clang][dataflow] In `ControlFlowContext`, handle `Decl` by reference instead of pointer.

2023-08-02 Thread Martin Böhme via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe6cd409fc639: [clang][dataflow] In `ControlFlowContext`, 
handle `Decl` by reference instead… (authored by mboehme).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156859

Files:
  clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h
  clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
  clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
  clang/lib/Analysis/FlowSensitive/Logger.cpp
  clang/lib/Analysis/FlowSensitive/Transfer.cpp
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp

Index: clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
===
--- clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
+++ clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
@@ -189,7 +189,7 @@
   void print(raw_ostream &OS) const override {
 OS << Message << "\n";
 OS << "Decl:\n";
-CFCtx.getDecl()->dump(OS);
+CFCtx.getDecl().dump(OS);
 OS << "CFG:\n";
 CFCtx.getCFG().print(OS, LangOptions(), false);
   }
Index: clang/lib/Analysis/FlowSensitive/Transfer.cpp
===
--- clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -725,9 +725,7 @@
 // FIXME: Use the same analysis as the caller for the callee. Note,
 // though, that doing so would require support for changing the analysis's
 // ASTContext.
-assert(CFCtx->getDecl() != nullptr &&
-   "ControlFlowContexts in the environment should always carry a decl");
-auto Analysis = NoopAnalysis(CFCtx->getDecl()->getASTContext(),
+auto Analysis = NoopAnalysis(CFCtx->getDecl().getASTContext(),
  DataflowAnalysisOptions{Options});
 
 auto BlockToOutputState =
Index: clang/lib/Analysis/FlowSensitive/Logger.cpp
===
--- clang/lib/Analysis/FlowSensitive/Logger.cpp
+++ clang/lib/Analysis/FlowSensitive/Logger.cpp
@@ -39,11 +39,10 @@
   llvm::WithColor Header(OS, llvm::raw_ostream::Colors::RED, /*Bold=*/true);
   OS << "=== Beginning data flow analysis ===\n";
 }
-if (auto *D = CFG.getDecl()) {
-  D->print(OS);
-  OS << "\n";
-  D->dump(OS);
-}
+auto &D = CFG.getDecl();
+D.print(OS);
+OS << "\n";
+D.dump(OS);
 CurrentCFG = &CFG.getCFG();
 CurrentCFG->print(OS, Analysis.getASTContext().getLangOpts(), ShowColors);
 CurrentAnalysis = &Analysis;
Index: clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
===
--- clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
+++ clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
@@ -166,15 +166,14 @@
 this->CFG = &CFG;
 *OS << llvm::StringRef(HTMLLogger_html).split("").first;
 
-if (const auto *D = CFG.getDecl()) {
-  const auto &SM = A.getASTContext().getSourceManager();
-  *OS << "";
-  if (const auto *ND = dyn_cast(D))
-*OS << ND->getNameAsString() << " at ";
-  *OS << SM.getFilename(D->getLocation()) << ":"
-  << SM.getSpellingLineNumber(D->getLocation());
-  *OS << "\n";
-};
+const auto &D = CFG.getDecl();
+const auto &SM = A.getASTContext().getSourceManager();
+*OS << "";
+if (const auto *ND = dyn_cast(&D))
+  *OS << ND->getNameAsString() << " at ";
+*OS << SM.getFilename(D.getLocation()) << ":"
+<< SM.getSpellingLineNumber(D.getLocation());
+*OS << "\n";
 
 *OS << "" << HTMLLogger_css << "\n";
 *OS << "" << HTMLLogger_js << "\n";
@@ -307,9 +306,7 @@
   // tokens are associated with, and even which BB element (so that clicking
   // can select the right element).
   void writeCode() {
-if (!CFG->getDecl())
-  return;
-const auto &AST = CFG->getDecl()->getASTContext();
+const auto &AST = CFG->getDecl().getASTContext();
 bool Invalid = false;
 
 // Extract the source code from the original file.
@@ -317,7 +314,7 @@
 // indentation to worry about), but we need the boundaries of particular
 // AST nodes and the printer doesn't provide this.
 auto Range = clang::Lexer::makeFileCharRange(
-CharSourceRange::getTokenRange(CFG->getDecl()->getSourceRange()),
+CharSourceRange::getTokenRange(CFG->getDecl().getSourceRange()),
 AST.getSourceManager(), AST.getLangOpts());
 if (Range.isInvalid())
   return;
Index: clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
===
--- clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
+++ clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
@@ -105,7 +105,7 @@
 
   llvm::BitV

[clang] e6cd409 - [clang][dataflow] In `ControlFlowContext`, handle `Decl` by reference instead of pointer.

2023-08-02 Thread Martin Braenne via cfe-commits

Author: Martin Braenne
Date: 2023-08-03T06:59:29Z
New Revision: e6cd409fc6396cb13c59b4a5190abc4b856f22a5

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

LOG: [clang][dataflow] In `ControlFlowContext`, handle `Decl` by reference 
instead of pointer.

`build()` guarantees that we'll always have a `Decl`, so we can simplify the 
code.

Reviewed By: ymandel, xazax.hun

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

Added: 


Modified: 
clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h
clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
clang/lib/Analysis/FlowSensitive/Logger.cpp
clang/lib/Analysis/FlowSensitive/Transfer.cpp
clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp

Removed: 




diff  --git a/clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h 
b/clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h
index bb36ed237c1e34..a45bb0635a2f36 100644
--- a/clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h
+++ b/clang/include/clang/Analysis/FlowSensitive/ControlFlowContext.h
@@ -48,7 +48,7 @@ class ControlFlowContext {
 
   /// Returns the `Decl` containing the statement used to construct the CFG, if
   /// available.
-  const Decl *getDecl() const { return ContainingDecl; }
+  const Decl &getDecl() const { return ContainingDecl; }
 
   /// Returns the CFG that is stored in this context.
   const CFG &getCFG() const { return *Cfg; }
@@ -64,9 +64,7 @@ class ControlFlowContext {
   }
 
 private:
-  // FIXME: Once the deprecated `build` method is removed, mark `D` as "must 
not
-  // be null" and add an assertion.
-  ControlFlowContext(const Decl *D, std::unique_ptr Cfg,
+  ControlFlowContext(const Decl &D, std::unique_ptr Cfg,
  llvm::DenseMap 
StmtToBlock,
  llvm::BitVector BlockReachable)
   : ContainingDecl(D), Cfg(std::move(Cfg)),
@@ -74,7 +72,7 @@ class ControlFlowContext {
 BlockReachable(std::move(BlockReachable)) {}
 
   /// The `Decl` containing the statement used to construct the CFG.
-  const Decl *ContainingDecl;
+  const Decl &ContainingDecl;
   std::unique_ptr Cfg;
   llvm::DenseMap StmtToBlock;
   llvm::BitVector BlockReachable;

diff  --git a/clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp 
b/clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
index c80525dc4f34f2..d5e0b443caf301 100644
--- a/clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
+++ b/clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
@@ -105,7 +105,7 @@ ControlFlowContext::build(const Decl &D, Stmt &S, 
ASTContext &C) {
 
   llvm::BitVector BlockReachable = findReachableBlocks(*Cfg);
 
-  return ControlFlowContext(&D, std::move(Cfg), std::move(StmtToBlock),
+  return ControlFlowContext(D, std::move(Cfg), std::move(StmtToBlock),
 std::move(BlockReachable));
 }
 

diff  --git a/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp 
b/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
index 9ec0160b1e3fe4..b1bfe10db20243 100644
--- a/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
+++ b/clang/lib/Analysis/FlowSensitive/HTMLLogger.cpp
@@ -166,15 +166,14 @@ class HTMLLogger : public Logger {
 this->CFG = &CFG;
 *OS << llvm::StringRef(HTMLLogger_html).split("").first;
 
-if (const auto *D = CFG.getDecl()) {
-  const auto &SM = A.getASTContext().getSourceManager();
-  *OS << "";
-  if (const auto *ND = dyn_cast(D))
-*OS << ND->getNameAsString() << " at ";
-  *OS << SM.getFilename(D->getLocation()) << ":"
-  << SM.getSpellingLineNumber(D->getLocation());
-  *OS << "\n";
-};
+const auto &D = CFG.getDecl();
+const auto &SM = A.getASTContext().getSourceManager();
+*OS << "";
+if (const auto *ND = dyn_cast(&D))
+  *OS << ND->getNameAsString() << " at ";
+*OS << SM.getFilename(D.getLocation()) << ":"
+<< SM.getSpellingLineNumber(D.getLocation());
+*OS << "\n";
 
 *OS << "" << HTMLLogger_css << "\n";
 *OS << "" << HTMLLogger_js << "\n";
@@ -307,9 +306,7 @@ class HTMLLogger : public Logger {
   // tokens are associated with, and even which BB element (so that clicking
   // can select the right element).
   void writeCode() {
-if (!CFG->getDecl())
-  return;
-const auto &AST = CFG->getDecl()->getASTContext();
+const auto &AST = CFG->getDecl().getASTContext();
 bool Invalid = false;
 
 // Extract the source code from the original file.
@@ -317,7 +314,7 @@ class HTMLLogger : public Logger {
 // indentation to worry about), but we need the boundaries of particular
 // AST nodes and the printer doesn't provide this.
 auto Range = clang::Lexer::makeFileChar

cfe-commits@lists.llvm.org

2023-08-02 Thread Bing Yu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6ee497aa0b48: [X86][Regcall] Add an option to respect 
regcall ABI v.4 in win64&win32 (authored by yubing).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155863

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/Mangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/check-regcall4-moduleflag.c
  clang/test/CodeGen/regcall4.c
  clang/test/CodeGenCXX/regcall4.cpp
  clang/test/Driver/cl-cc-flags.c
  llvm/lib/Target/X86/X86CallingConv.td
  llvm/test/CodeGen/X86/sse-regcall4.ll

Index: llvm/test/CodeGen/X86/sse-regcall4.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/sse-regcall4.ll
@@ -0,0 +1,467 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=i386-pc-win32 -mattr=+sse | FileCheck --check-prefix=WIN32 %s
+; RUN: llc < %s -mtriple=x86_64-win32 -mattr=+sse | FileCheck --check-prefix=WIN64 %s
+; RUN: llc < %s -mtriple=x86_64-linux-gnu -mattr=+sse | FileCheck --check-prefix=LINUXOSX %s
+
+; Test regcall when receiving/returning i1
+define x86_regcallcc i1 @test_argReti1(i1 %a)  {
+; WIN32-LABEL: test_argReti1:
+; WIN32:   # %bb.0:
+; WIN32-NEXT:incb %cl
+; WIN32-NEXT:# kill: def $cl killed $cl killed $ecx
+; WIN32-NEXT:retl
+;
+; WIN64-LABEL: test_argReti1:
+; WIN64:   # %bb.0:
+; WIN64-NEXT:incb %al
+; WIN64-NEXT:# kill: def $al killed $al killed $eax
+; WIN64-NEXT:retq
+;
+; LINUXOSX-LABEL: test_argReti1:
+; LINUXOSX:   # %bb.0:
+; LINUXOSX-NEXT:incb %al
+; LINUXOSX-NEXT:# kill: def $al killed $al killed $eax
+; LINUXOSX-NEXT:retq
+  %add = add i1 %a, 1
+  ret i1 %add
+}
+
+; Test regcall when passing/retrieving i1
+define x86_regcallcc i1 @test_CallargReti1(i1 %a)  {
+; WIN32-LABEL: test_CallargReti1:
+; WIN32:   # %bb.0:
+; WIN32-NEXT:incb %cl
+; WIN32-NEXT:movzbl %cl, %ecx
+; WIN32-NEXT:calll _test_argReti1
+; WIN32-NEXT:incb %cl
+; WIN32-NEXT:retl
+;
+; WIN64-LABEL: test_CallargReti1:
+; WIN64:   # %bb.0:
+; WIN64-NEXT:pushq %rax
+; WIN64-NEXT:.seh_stackalloc 8
+; WIN64-NEXT:.seh_endprologue
+; WIN64-NEXT:incb %al
+; WIN64-NEXT:movzbl %al, %eax
+; WIN64-NEXT:callq test_argReti1
+; WIN64-NEXT:incb %al
+; WIN64-NEXT:popq %rcx
+; WIN64-NEXT:retq
+; WIN64-NEXT:.seh_endproc
+;
+; LINUXOSX-LABEL: test_CallargReti1:
+; LINUXOSX:   # %bb.0:
+; LINUXOSX-NEXT:pushq %rax
+; LINUXOSX-NEXT:.cfi_def_cfa_offset 16
+; LINUXOSX-NEXT:incb %al
+; LINUXOSX-NEXT:movzbl %al, %eax
+; LINUXOSX-NEXT:callq *test_argReti1@GOTPCREL(%rip)
+; LINUXOSX-NEXT:incb %al
+; LINUXOSX-NEXT:popq %rcx
+; LINUXOSX-NEXT:.cfi_def_cfa_offset 8
+; LINUXOSX-NEXT:retq
+  %b = add i1 %a, 1
+  %c = call x86_regcallcc i1 @test_argReti1(i1 %b)
+  %d = add i1 %c, 1
+  ret i1 %d
+}
+
+;test calling conventions - input parameters, callee saved xmms
+define x86_regcallcc <16 x float> @testf32_inp(<16 x float> %a, <16 x float> %b, <16 x float> %c) nounwind {
+; WIN32-LABEL: testf32_inp:
+; WIN32:   # %bb.0:
+; WIN32-NEXT:pushl %ebp
+; WIN32-NEXT:movl %esp, %ebp
+; WIN32-NEXT:andl $-16, %esp
+; WIN32-NEXT:subl $32, %esp
+; WIN32-NEXT:movaps %xmm7, (%esp) # 16-byte Spill
+; WIN32-NEXT:movaps %xmm6, %xmm7
+; WIN32-NEXT:movaps %xmm5, %xmm6
+; WIN32-NEXT:movaps %xmm3, %xmm5
+; WIN32-NEXT:movaps %xmm2, %xmm3
+; WIN32-NEXT:movaps %xmm1, %xmm2
+; WIN32-NEXT:movaps %xmm0, %xmm1
+; WIN32-NEXT:addps %xmm4, %xmm0
+; WIN32-NEXT:mulps %xmm4, %xmm1
+; WIN32-NEXT:subps %xmm1, %xmm0
+; WIN32-NEXT:movups 8(%ebp), %xmm1
+; WIN32-NEXT:addps %xmm1, %xmm0
+; WIN32-NEXT:movaps %xmm2, %xmm4
+; WIN32-NEXT:addps %xmm6, %xmm4
+; WIN32-NEXT:mulps %xmm6, %xmm2
+; WIN32-NEXT:subps %xmm2, %xmm4
+; WIN32-NEXT:movups 24(%ebp), %xmm1
+; WIN32-NEXT:addps %xmm1, %xmm4
+; WIN32-NEXT:movaps %xmm3, %xmm2
+; WIN32-NEXT:addps %xmm7, %xmm2
+; WIN32-NEXT:mulps %xmm7, %xmm3
+; WIN32-NEXT:subps %xmm3, %xmm2
+; WIN32-NEXT:movups 40(%ebp), %xmm1
+; WIN32-NEXT:addps %xmm1, %xmm2
+; WIN32-NEXT:movaps %xmm5, %xmm3
+; WIN32-NEXT:movaps (%esp), %xmm1 # 16-byte Reload
+; WIN32-NEXT:addps %xmm1, %xmm3
+; WIN32-NEXT:mulps %xmm1, %xmm5
+; WIN32-NEXT:subps %xmm5, %xmm3
+; WIN32-NEXT:movups 56(%ebp), %xmm1
+; WIN32-NEXT:addps %xmm1, %xmm3
+; WIN32-NEXT:movaps %xmm4, %xmm1
+; WIN32-NEXT:movl %ebp, %esp
+; WIN32-NEXT:popl %ebp
+; WIN32-NEXT:retl
+;
+; WIN64-LABEL: testf32_inp:
+; WIN64:   # %bb.0:
+; WIN64-NEXT:subq $72, %rsp
+;

cfe-commits@lists.llvm.org

2023-08-02 Thread Bing1 Yu via cfe-commits

Author: Bing1 Yu
Date: 2023-08-03T13:58:33+08:00
New Revision: 6ee497aa0b48ad892447f29a90b4e61241949295

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

LOG: [X86][Regcall] Add an option to respect regcall ABI v.4 in win64&win32

Reviewed By: pengfei

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

Added: 
clang/test/CodeGen/check-regcall4-moduleflag.c
clang/test/CodeGen/regcall4.c
clang/test/CodeGenCXX/regcall4.cpp
llvm/test/CodeGen/X86/sse-regcall4.ll

Modified: 
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Driver/Options.td
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/Mangle.cpp
clang/lib/AST/MicrosoftMangle.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/cl-cc-flags.c
llvm/lib/Target/X86/X86CallingConv.td

Removed: 




diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 007b3737f83e62..b6bb5e969e130c 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -429,6 +429,8 @@ LANGOPT(PaddingOnUnsignedFixedPoint, 1, 0,
 
 LANGOPT(RegisterStaticDestructors, 1, 1, "Register C++ static destructors")
 
+LANGOPT(RegCall4, 1, 0, "Set __regcall4 as a default calling convention to 
respect __regcall ABI v.4")
+
 LANGOPT(MatrixTypes, 1, 0, "Enable or disable the builtin matrix type")
 
 ENUM_LANGOPT(StrictFlexArraysLevel, StrictFlexArraysLevelKind, 2,

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 9e25a5e0b58a58..296fa1fcc38a02 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4505,6 +4505,9 @@ def no_offload_add_rpath: Flag<["--"], 
"no-offload-add-rpath">, Flags<[NoArgumen
   Alias;
 def r : Flag<["-"], "r">, Flags<[LinkerInput,NoArgumentUnused]>,
 Group;
+def regcall4 : Flag<["-"], "regcall4">, Group, Flags<[CC1Option]>,
+  HelpText<"Set __regcall4 as a default calling convention to respect 
__regcall ABI v.4">,
+  MarshallingInfoFlag>;
 def save_temps_EQ : Joined<["-", "--"], "save-temps=">, Flags<[CC1Option, 
FlangOption, FC1Option, NoXarchOption]>,
   HelpText<"Save intermediate compilation results.">;
 def save_temps : Flag<["-", "--"], "save-temps">, Flags<[FlangOption, 
FC1Option, NoXarchOption]>,
@@ -7292,6 +7295,8 @@ def _SLASH_Gv : CLFlag<"Gv">,
   HelpText<"Set __vectorcall as a default calling convention">;
 def _SLASH_Gregcall : CLFlag<"Gregcall">,
   HelpText<"Set __regcall as a default calling convention">;
+def _SLASH_Gregcall4 : CLFlag<"Gregcall4">,
+  HelpText<"Set __regcall4 as a default calling convention to respect 
__regcall ABI v.4">;
 
 // GNU Driver aliases
 

diff  --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 16f0d90451f7ad..153f6dc2e9cf12 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -1688,8 +1688,12 @@ void CXXNameMangler::mangleRegCallName(const 
IdentifierInfo *II) {
   //  ::=  __regcall3__ 
   //  ::= [n] 
   //  ::= 
-  Out << II->getLength() + sizeof("__regcall3__") - 1 << "__regcall3__"
-  << II->getName();
+  if (getASTContext().getLangOpts().RegCall4)
+Out << II->getLength() + sizeof("__regcall4__") - 1 << "__regcall4__"
+<< II->getName();
+  else
+Out << II->getLength() + sizeof("__regcall3__") - 1 << "__regcall3__"
+<< II->getName();
 }
 
 void CXXNameMangler::mangleDeviceStubName(const IdentifierInfo *II) {

diff  --git a/clang/lib/AST/Mangle.cpp b/clang/lib/AST/Mangle.cpp
index 31cdad4c8fdd4e..53af9fc4d51897 100644
--- a/clang/lib/AST/Mangle.cpp
+++ b/clang/lib/AST/Mangle.cpp
@@ -198,8 +198,12 @@ void MangleContext::mangleName(GlobalDecl GD, raw_ostream 
&Out) {
 Out << '_';
   else if (CC == CCM_Fast)
 Out << '@';
-  else if (CC == CCM_RegCall)
-Out << "__regcall3__";
+  else if (CC == CCM_RegCall) {
+if (getASTContext().getLangOpts().RegCall4)
+  Out << "__regcall4__";
+else
+  Out << "__regcall3__";
+  }
 
   if (!MCXX)
 Out << D->getIdentifier()->getName();

diff  --git a/clang/lib/AST/MicrosoftMangle.cpp 
b/clang/lib/AST/MicrosoftMangle.cpp
index 3306d90dc85664..91af18d6119796 100644
--- a/clang/lib/AST/MicrosoftMangle.cpp
+++ b/clang/lib/AST/MicrosoftMangle.cpp
@@ -2853,6 +2853,7 @@ void 
MicrosoftCXXNameMangler::mangleCallingConvention(CallingConv CC) {
   //  ::= T # __attribute__((__swiftasynccall__))
   //// Clang-only
   //  ::= w # __regcall
+  //  ::= x # __regcall4
   // The 'export' calling conventions are from a bygone era
   // (*cough*Win16*cough*) when functions were declared fo

[PATCH] D156655: [clang-format] Handle goto labels preceded by C++11 attributes

2023-08-02 Thread Owen Pan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG70d7ea0cebcf: [clang-format] Handle goto labels preceded by 
C++11 attributes (authored by owenpan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156655

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -3023,6 +3023,26 @@
"  some_other_code();\n"
"}\n"
"}");
+  verifyFormat("{\n"
+   "L0:\n"
+   "[[foo]] L1:\n"
+   "[[bar]] [[baz]] L2:\n"
+   "  g();\n"
+   "}");
+  verifyFormat("{\n"
+   "[[foo]] L1: {\n"
+   "[[bar]] [[baz]] L2:\n"
+   "  g();\n"
+   "}\n"
+   "}");
+  verifyFormat("{\n"
+   "[[foo]] L1:\n"
+   "  f();\n"
+   "  {\n"
+   "  [[bar]] [[baz]] L2:\n"
+   "g();\n"
+   "  }\n"
+   "}");
   FormatStyle Style = getLLVMStyle();
   Style.IndentGotoLabels = false;
   verifyFormat("void f() {\n"
@@ -3046,12 +3066,22 @@
"  some_code();\n"
"test_label:;\n"
"  int i = 0;\n"
-   "}");
+   "}",
+   Style);
   verifyFormat("{\n"
"  some_code();\n"
"test_label: { some_other_code(); }\n"
"}",
Style);
+  verifyFormat("{\n"
+   "[[foo]] L1:\n"
+   "  f();\n"
+   "  {\n"
+   "[[bar]] [[baz]] L2:\n"
+   "g();\n"
+   "  }\n"
+   "}",
+   Style);
   // The opening brace may either be on the same unwrapped line as the colon or
   // on a separate one. The formatter should recognize both.
   Style = getLLVMStyle();
@@ -3064,6 +3094,14 @@
"}\n"
"}",
Style);
+  verifyFormat("{\n"
+   "[[foo]] L1:\n"
+   "{\n"
+   "[[bar]] [[baz]] L2:\n"
+   "  g();\n"
+   "}\n"
+   "}",
+   Style);
 }
 
 TEST_F(FormatTest, MultiLineControlStatements) {
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1402,7 +1402,10 @@
 return;
   }
 
-  if (Style.isVerilog()) {
+  if (Style.isCpp()) {
+while (FormatTok->is(tok::l_square) && handleCppAttributes()) {
+}
+  } else if (Style.isVerilog()) {
 if (Keywords.isVerilogStructuredProcedure(*FormatTok)) {
   parseForOrWhileLoop(/*HasParens=*/false);
   return;
@@ -1638,6 +1641,17 @@
   parseNamespace();
   return;
 }
+// In Verilog labels can be any expression, so we don't do them here.
+if (!Style.isVerilog() && Tokens->peekNextToken()->is(tok::colon) &&
+!Line->MustBeDeclaration) {
+  nextToken();
+  Line->Tokens.begin()->Tok->MustBreakBefore = true;
+  FormatTok->setFinalizedType(TT_GotoLabelColon);
+  parseLabel(!Style.IndentGotoLabels);
+  if (HasLabel)
+*HasLabel = true;
+  return;
+}
 // In all other cases, parse the declaration.
 break;
   default:
@@ -1942,16 +1956,6 @@
 return I != E && (++I == E);
   };
   if (OneTokenSoFar()) {
-// In Verilog labels can be any expression, so we don't do them here.
-if (!Style.isVerilog() && FormatTok->is(tok::colon) &&
-!Line->MustBeDeclaration) {
-  Line->Tokens.begin()->Tok->MustBreakBefore = true;
-  FormatTok->setFinalizedType(TT_GotoLabelColon);
-  parseLabel(!Style.IndentGotoLabels);
-  if (HasLabel)
-*HasLabel = true;
-  return;
-}
 // Recognize function-like macro usages without trailing semicolon as
 // well as free-standing macros like Q_OBJECT.
 bool FunctionLike = FormatTok->is(tok::l_paren);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 70d7ea0 - [clang-format] Handle goto labels preceded by C++11 attributes

2023-08-02 Thread Owen Pan via cfe-commits

Author: Owen Pan
Date: 2023-08-02T22:48:48-07:00
New Revision: 70d7ea0cebcf363cd0ddcfb76375fb5fada87dd5

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

LOG: [clang-format] Handle goto labels preceded by C++11 attributes

Fixes #64229.

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

Added: 


Modified: 
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index 22fa651ae96bca..2d34837a4fac04 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -1402,7 +1402,10 @@ void UnwrappedLineParser::parseStructuralElement(
 return;
   }
 
-  if (Style.isVerilog()) {
+  if (Style.isCpp()) {
+while (FormatTok->is(tok::l_square) && handleCppAttributes()) {
+}
+  } else if (Style.isVerilog()) {
 if (Keywords.isVerilogStructuredProcedure(*FormatTok)) {
   parseForOrWhileLoop(/*HasParens=*/false);
   return;
@@ -1638,6 +1641,17 @@ void UnwrappedLineParser::parseStructuralElement(
   parseNamespace();
   return;
 }
+// In Verilog labels can be any expression, so we don't do them here.
+if (!Style.isVerilog() && Tokens->peekNextToken()->is(tok::colon) &&
+!Line->MustBeDeclaration) {
+  nextToken();
+  Line->Tokens.begin()->Tok->MustBreakBefore = true;
+  FormatTok->setFinalizedType(TT_GotoLabelColon);
+  parseLabel(!Style.IndentGotoLabels);
+  if (HasLabel)
+*HasLabel = true;
+  return;
+}
 // In all other cases, parse the declaration.
 break;
   default:
@@ -1942,16 +1956,6 @@ void UnwrappedLineParser::parseStructuralElement(
 return I != E && (++I == E);
   };
   if (OneTokenSoFar()) {
-// In Verilog labels can be any expression, so we don't do them here.
-if (!Style.isVerilog() && FormatTok->is(tok::colon) &&
-!Line->MustBeDeclaration) {
-  Line->Tokens.begin()->Tok->MustBreakBefore = true;
-  FormatTok->setFinalizedType(TT_GotoLabelColon);
-  parseLabel(!Style.IndentGotoLabels);
-  if (HasLabel)
-*HasLabel = true;
-  return;
-}
 // Recognize function-like macro usages without trailing semicolon as
 // well as free-standing macros like Q_OBJECT.
 bool FunctionLike = FormatTok->is(tok::l_paren);

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 3ed97c00c77b18..1a1109f281b442 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -3023,6 +3023,26 @@ TEST_F(FormatTest, FormatsLabels) {
"  some_other_code();\n"
"}\n"
"}");
+  verifyFormat("{\n"
+   "L0:\n"
+   "[[foo]] L1:\n"
+   "[[bar]] [[baz]] L2:\n"
+   "  g();\n"
+   "}");
+  verifyFormat("{\n"
+   "[[foo]] L1: {\n"
+   "[[bar]] [[baz]] L2:\n"
+   "  g();\n"
+   "}\n"
+   "}");
+  verifyFormat("{\n"
+   "[[foo]] L1:\n"
+   "  f();\n"
+   "  {\n"
+   "  [[bar]] [[baz]] L2:\n"
+   "g();\n"
+   "  }\n"
+   "}");
   FormatStyle Style = getLLVMStyle();
   Style.IndentGotoLabels = false;
   verifyFormat("void f() {\n"
@@ -3046,12 +3066,22 @@ TEST_F(FormatTest, FormatsLabels) {
"  some_code();\n"
"test_label:;\n"
"  int i = 0;\n"
-   "}");
+   "}",
+   Style);
   verifyFormat("{\n"
"  some_code();\n"
"test_label: { some_other_code(); }\n"
"}",
Style);
+  verifyFormat("{\n"
+   "[[foo]] L1:\n"
+   "  f();\n"
+   "  {\n"
+   "[[bar]] [[baz]] L2:\n"
+   "g();\n"
+   "  }\n"
+   "}",
+   Style);
   // The opening brace may either be on the same unwrapped line as the colon or
   // on a separate one. The formatter should recognize both.
   Style = getLLVMStyle();
@@ -3064,6 +3094,14 @@ TEST_F(FormatTest, FormatsLabels) {
"}\n"
"}",
Style);
+  verifyFormat("{\n"
+   "[[foo]] L1:\n"
+   "{\n"
+   "[[bar]] [[baz]] L2:\n"
+   "  g();\n"
+   "}\n"
+   "}",
+   Style);
 }
 
 TEST_F(FormatTest, MultiLineControlStatements) {



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

[PATCH] D125788: [flang][driver] Rename `flang-new` as `flang`

2023-08-02 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.
Herald added a subscriber: jplehr.

If you continue this work, consider landing this rename in multiple phases, e.g.

- Use lit substitutions instead of `flang-new` and other preparatory stuff so 
that the next step has very little change
- change flang-new to flang and add flang-new as a symlink for compatibility
- remove the symlink `flang-new`, when it is no longer used.

Many build bots can fail in weird ways and ensuring that we will not revert a 
large change prevents causing churn to the tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125788

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


[PATCH] D156693: [clang][ASTImporter]Skip check friend template declaration in VisitClassTemplateDecl

2023-08-02 Thread Qizhi Hu via Phabricator via cfe-commits
jcsxky updated this revision to Diff 546698.
jcsxky added a comment.

format code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156693

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/test/Analysis/Inputs/ctu-friend-template-other.cpp
  clang/test/Analysis/Inputs/ctu-friend-template.cpp.externalDefMap-dump.txt
  clang/test/Analysis/Inputs/ctu-friend-template.h
  clang/test/Analysis/ctu-friend-template.cpp


Index: clang/test/Analysis/ctu-friend-template.cpp
===
--- /dev/null
+++ clang/test/Analysis/ctu-friend-template.cpp
@@ -0,0 +1,21 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: mkdir -p %t/ctudir
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \
+// RUN:   -emit-pch -o %t/ctudir/ctu-friend-template-other.cpp.ast 
%S/Inputs/ctu-friend-template-other.cpp
+// RUN: cp %S/Inputs/ctu-friend-template.cpp.externalDefMap-dump.txt 
%t/ctudir/externalDefMap.txt
+// RUN: %clang_analyze_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \
+// RUN:   -analyzer-checker=core,debug.ExprInspection \
+// RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \
+// RUN:   -analyzer-config ctu-dir=%t/ctudir \
+// RUN:   -Werror=ctu \
+// RUN:   -verify %s
+
+// CHECK: CTU loaded AST file
+
+#include "Inputs/ctu-friend-template.h"
+
+void bar();
+
+int main(){
+   bar(); // expected-no-diagnostics
+}
Index: clang/test/Analysis/Inputs/ctu-friend-template.h
===
--- /dev/null
+++ clang/test/Analysis/Inputs/ctu-friend-template.h
@@ -0,0 +1,20 @@
+namespace __1{
+
+template
+class A;
+
+template
+class A{
+public:
+   template
+   friend class A;
+
+   A(T x):x(x){}
+   
+   void foo(){}
+   
+private:
+   T x;
+};
+
+}
Index: 
clang/test/Analysis/Inputs/ctu-friend-template.cpp.externalDefMap-dump.txt
===
--- /dev/null
+++ clang/test/Analysis/Inputs/ctu-friend-template.cpp.externalDefMap-dump.txt
@@ -0,0 +1 @@
+9:c:@F@bar# ctu-friend-template-other.cpp.ast
Index: clang/test/Analysis/Inputs/ctu-friend-template-other.cpp
===
--- /dev/null
+++ clang/test/Analysis/Inputs/ctu-friend-template-other.cpp
@@ -0,0 +1,6 @@
+#include "ctu-friend-template.h"
+
+void bar(){
+   __1::A a1(0);
+   a1.foo();
+}
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -34,6 +34,7 @@
 #include "clang/AST/LambdaCapture.h"
 #include "clang/AST/NestedNameSpecifier.h"
 #include "clang/AST/OperationKinds.h"
+#include "clang/AST/ParentMapContext.h"
 #include "clang/AST/Stmt.h"
 #include "clang/AST/StmtCXX.h"
 #include "clang/AST/StmtObjC.h"
@@ -5821,7 +5822,11 @@
   if (FoundTemplate) {
 if (!hasSameVisibilityContextAndLinkage(FoundTemplate, D))
   continue;
-
+auto Parents = FoundDecl->getASTContext().getParents(*FoundDecl);
+if (!Parents.empty() && nullptr != Parents.begin()->get() 
&&
+FoundTemplate->getName() == D->getName() &&
+!IsStructuralMatch(D, FoundTemplate, false))
+  continue;
 if (IsStructuralMatch(D, FoundTemplate)) {
   ClassTemplateDecl *TemplateWithDef =
   getTemplateDefinition(FoundTemplate);


Index: clang/test/Analysis/ctu-friend-template.cpp
===
--- /dev/null
+++ clang/test/Analysis/ctu-friend-template.cpp
@@ -0,0 +1,21 @@
+// RUN: rm -rf %t && mkdir %t
+// RUN: mkdir -p %t/ctudir
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \
+// RUN:   -emit-pch -o %t/ctudir/ctu-friend-template-other.cpp.ast %S/Inputs/ctu-friend-template-other.cpp
+// RUN: cp %S/Inputs/ctu-friend-template.cpp.externalDefMap-dump.txt %t/ctudir/externalDefMap.txt
+// RUN: %clang_analyze_cc1 -std=c++14 -triple x86_64-pc-linux-gnu \
+// RUN:   -analyzer-checker=core,debug.ExprInspection \
+// RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \
+// RUN:   -analyzer-config ctu-dir=%t/ctudir \
+// RUN:   -Werror=ctu \
+// RUN:   -verify %s
+
+// CHECK: CTU loaded AST file
+
+#include "Inputs/ctu-friend-template.h"
+
+void bar();
+
+int main(){
+	bar(); // expected-no-diagnostics
+}
Index: clang/test/Analysis/Inputs/ctu-friend-template.h
===
--- /dev/null
+++ clang/test/Analysis/Inputs/ctu-friend-template.h
@@ -0,0 +1,20 @@
+namespace __1{
+
+template
+class A;
+
+template
+class A{
+public:
+	template
+	friend class A;
+
+	A(T x):x(x){}
+	
+	void foo(){}
+	
+private:
+	T x;
+};
+
+}
Index: clang/test/Analysis/Inputs/ctu-friend-template.cpp.externalDefMap-dump.txt
===

[clang] 1f3c1cb - [Parser][ObjC] Fix crash on nested top-level block with better recovery path

2023-08-02 Thread via cfe-commits

Author: dingfei
Date: 2023-08-03T12:58:48+08:00
New Revision: 1f3c1cba49a1ace7d2813b3be69279df322c2db0

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

LOG: [Parser][ObjC] Fix crash on nested top-level block with better recovery 
path

Delay consuming tokens until we are certain that the next token is not top
level block. Otherwise we bail out as if we saw an @end for better diagnostic
and recovery.

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

Reviewed By: rjmccall

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

Added: 
clang/test/Parser/missing-end-1-gh64065-nocrash.m

Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Parse/ParseObjc.cpp
clang/test/Parser/missing-end-2.m
clang/test/Parser/missing-end-3.m
clang/test/Parser/missing-end-4.m

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3af39b4f409199..627a1541cfddb9 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -146,6 +146,10 @@ Miscellaneous Bug Fixes
 
 Miscellaneous Clang Crashes Fixed
 ^
+- Fixed a crash when parsing top-level ObjC blocks that aren't properly
+  terminated. Clang should now also recover better when an @end is missing
+  between blocks.
+  `Issue 64065 `_
 
 Target Specific Changes
 ---

diff  --git a/clang/lib/Parse/ParseObjc.cpp b/clang/lib/Parse/ParseObjc.cpp
index b30f0380621a17..d0af98b9106c3e 100644
--- a/clang/lib/Parse/ParseObjc.cpp
+++ b/clang/lib/Parse/ParseObjc.cpp
@@ -613,6 +613,19 @@ ObjCTypeParamList *Parser::parseObjCTypeParamList() {
   /*mayBeProtocolList=*/false);
 }
 
+static bool isTopLevelObjCKeyword(tok::ObjCKeywordKind DirectiveKind) {
+  switch (DirectiveKind) {
+  case tok::objc_class:
+  case tok::objc_compatibility_alias:
+  case tok::objc_interface:
+  case tok::objc_implementation:
+  case tok::objc_protocol:
+return true;
+  default:
+return false;
+  }
+}
+
 ///   objc-interface-decl-list:
 /// empty
 /// objc-interface-decl-list objc-property-decl [OBJC2]
@@ -705,27 +718,34 @@ void 
Parser::ParseObjCInterfaceDeclList(tok::ObjCKeywordKind contextKey,
   continue;
 }
 
-// Otherwise, we have an @ directive, eat the @.
-SourceLocation AtLoc = ConsumeToken(); // the "@"
-if (Tok.is(tok::code_completion)) {
+// Otherwise, we have an @ directive, peak at the next token
+SourceLocation AtLoc = Tok.getLocation();
+const auto &NextTok = NextToken();
+if (NextTok.is(tok::code_completion)) {
   cutOffParsing();
   Actions.CodeCompleteObjCAtDirective(getCurScope());
   return;
 }
 
-tok::ObjCKeywordKind DirectiveKind = Tok.getObjCKeywordID();
-
+tok::ObjCKeywordKind DirectiveKind = NextTok.getObjCKeywordID();
 if (DirectiveKind == tok::objc_end) { // @end -> terminate list
+  ConsumeToken(); // the "@"
   AtEnd.setBegin(AtLoc);
   AtEnd.setEnd(Tok.getLocation());
   break;
 } else if (DirectiveKind == tok::objc_not_keyword) {
-  Diag(Tok, diag::err_objc_unknown_at);
+  Diag(NextTok, diag::err_objc_unknown_at);
   SkipUntil(tok::semi);
   continue;
 }
 
-// Eat the identifier.
+// If we see something like '@interface' that's only allowed at the top
+// level, bail out as if we saw an '@end'. We'll diagnose this below.
+if (isTopLevelObjCKeyword(DirectiveKind))
+  break;
+
+// Otherwise parse it as part of the current declaration. Eat 
"@identifier".
+ConsumeToken();
 ConsumeToken();
 
 switch (DirectiveKind) {
@@ -739,15 +759,6 @@ void 
Parser::ParseObjCInterfaceDeclList(tok::ObjCKeywordKind contextKey,
   SkipUntil(tok::r_brace, tok::at, StopAtSemi);
   break;
 
-case tok::objc_implementation:
-case tok::objc_interface:
-  Diag(AtLoc, diag::err_objc_missing_end)
-  << FixItHint::CreateInsertion(AtLoc, "@end\n");
-  Diag(CDecl->getBeginLoc(), diag::note_objc_container_start)
-  << (int)Actions.getObjCContainerKind();
-  ConsumeToken();
-  break;
-
 case tok::objc_required:
 case tok::objc_optional:
   // This is only valid on protocols.
@@ -816,13 +827,10 @@ void 
Parser::ParseObjCInterfaceDeclList(tok::ObjCKeywordKind contextKey,
 }
   }
 
-  // We break out of the big loop in two cases: when we see @end or when we see
-  // EOF.  In the former case, eat the @end.  In the later case, emit an error.
-  if (Tok.is(tok::code_completion)) {
-cutOffParsing();
-Actions.CodeCompleteObjCAtDirective(getCurScope());
-return;
-  } else if (Tok.isObjCAtKeyword(tok::objc_end)) {
+  // We break 

[PATCH] D155145: [X86] Add AVX-VNNI-INT16 instructions.

2023-08-02 Thread Anna Thomas via Phabricator via cfe-commits
anna added a comment.

thank you @craig.topper  and @pengfei .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155145

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


[PATCH] D156933: [HLSL] Add reversebits library function

2023-08-02 Thread Joshua Batista via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe545392b1de3: [HLSL] Add reversebits library function 
(authored by bob80905).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156933

Files:
  clang/lib/Headers/hlsl/hlsl_intrinsics.h
  clang/test/CodeGenHLSL/builtins/bitreverse.hlsl
  clang/test/CodeGenHLSL/builtins/reversebits.hlsl

Index: clang/test/CodeGenHLSL/builtins/reversebits.hlsl
===
--- /dev/null
+++ clang/test/CodeGenHLSL/builtins/reversebits.hlsl
@@ -0,0 +1,155 @@
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -fnative-half-type \
+// RUN:   -D__HLSL_ENABLE_16_BIT -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s
+
+#ifdef __HLSL_ENABLE_16_BIT
+// CHECK: define noundef i16 @
+// CHECK: call i16 @llvm.bitreverse.i16(
+int16_t test_bitreverse_short(int16_t p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <2 x i16> @
+// CHECK: call <2 x i16> @llvm.bitreverse.v2i16(
+int16_t2 test_bitreverse_short2(int16_t2 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <3 x i16> @
+// CHECK: call <3 x i16> @llvm.bitreverse.v3i16
+int16_t3 test_bitreverse_short3(int16_t3 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <4 x i16> @
+// CHECK: call <4 x i16> @llvm.bitreverse.v4i16
+int16_t4 test_bitreverse_short4(int16_t4 p0)
+{
+	return reversebits(p0);
+}
+
+// CHECK: define noundef i16 @
+// CHECK: call i16 @llvm.bitreverse.i16(
+uint16_t test_bitreverse_ushort(uint16_t p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <2 x i16> @
+// CHECK: call <2 x i16> @llvm.bitreverse.v2i16
+uint16_t2 test_bitreverse_ushort2(uint16_t2 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <3 x i16> @
+// CHECK: call <3 x i16> @llvm.bitreverse.v3i16
+uint16_t3 test_bitreverse_ushort3(uint16_t3 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <4 x i16> @
+// CHECK: call <4 x i16> @llvm.bitreverse.v4i16
+uint16_t4 test_bitreverse_ushort4(uint16_t4 p0)
+{
+	return reversebits(p0);
+}
+#endif
+
+// CHECK: define noundef i32 @
+// CHECK: call i32 @llvm.bitreverse.i32(
+int test_bitreverse_int(int p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <2 x i32> @
+// CHECK: call <2 x i32> @llvm.bitreverse.v2i32
+int2 test_bitreverse_int2(int2 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <3 x i32> @
+// CHECK: call <3 x i32> @llvm.bitreverse.v3i32
+int3 test_bitreverse_int3(int3 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <4 x i32> @
+// CHECK: call <4 x i32> @llvm.bitreverse.v4i32
+int4 test_bitreverse_int4(int4 p0)
+{
+	return reversebits(p0);
+}
+
+// CHECK: define noundef i32 @
+// CHECK: call i32 @llvm.bitreverse.i32(
+int test_bitreverse_uint(uint p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <2 x i32> @
+// CHECK: call <2 x i32> @llvm.bitreverse.v2i32
+uint2 test_bitreverse_uint2(uint2 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <3 x i32> @
+// CHECK: call <3 x i32> @llvm.bitreverse.v3i32
+uint3 test_bitreverse_uint3(uint3 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <4 x i32> @
+// CHECK: call <4 x i32> @llvm.bitreverse.v4i32
+uint4 test_bitreverse_uint4(uint4 p0)
+{
+	return reversebits(p0);
+}
+
+// CHECK: define noundef i64 @
+// CHECK: call i64 @llvm.bitreverse.i64(
+int64_t test_bitreverse_long(int64_t p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <2 x i64> @
+// CHECK: call <2 x i64> @llvm.bitreverse.v2i64
+int64_t2 test_bitreverse_long2(int64_t2 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <3 x i64> @
+// CHECK: call <3 x i64> @llvm.bitreverse.v3i64
+int64_t3 test_bitreverse_long3(int64_t3 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <4 x i64> @
+// CHECK: call <4 x i64> @llvm.bitreverse.v4i64
+int64_t4 test_bitreverse_long4(int64_t4 p0)
+{
+	return reversebits(p0);
+}
+
+// CHECK: define noundef i64 @
+// CHECK: call i64 @llvm.bitreverse.i64(
+uint64_t test_bitreverse_long(uint64_t p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <2 x i64> @
+// CHECK: call <2 x i64> @llvm.bitreverse.v2i64
+uint64_t2 test_bitreverse_long2(uint64_t2 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <3 x i64> @
+// CHECK: call <3 x i64> @llvm.bitreverse.v3i64
+uint64_t3 test_bitreverse_long3(uint64_t3 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <4 x i64> @
+// CHECK: call <4 x i64> @llvm.bitreverse.v4i64
+uint64_t4 test_bitreverse_long4(uint64_t4 p0)
+{
+	return reversebits(p0);
+}
Index: clang/test/CodeGenHLSL/builtins/bitreverse.hlsl
===
--- /dev/null
+++ clang/test/CodeGenHLSL/builtins/bitrev

[clang] e545392 - [HLSL] Add reversebits library function

2023-08-02 Thread Joshua Batista via cfe-commits

Author: Joshua Batista
Date: 2023-08-02T20:50:40-07:00
New Revision: e545392b1de304d3bf2776f671cb7327e335b90b

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

LOG: [HLSL] Add reversebits library function

This change exposes the reversebits library function for HLSL, excluding 
floating point types.
The reversebits function is supported for all scalar, vector, and matrix types.

The full documentation of the HLSL reversebits function is available here:
https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/reversebits

Reviewed By: python3kgae

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

Added: 
clang/test/CodeGenHLSL/builtins/bitreverse.hlsl
clang/test/CodeGenHLSL/builtins/reversebits.hlsl

Modified: 
clang/lib/Headers/hlsl/hlsl_intrinsics.h

Removed: 




diff  --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h 
b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
index 1a34e1626e5a60..6f1aa5f26294ef 100644
--- a/clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -476,5 +476,61 @@ double3 min(double3, double3);
 __attribute__((clang_builtin_alias(__builtin_elementwise_min)))
 double4 min(double4, double4);
 
+// reversebits builtins
+#ifdef __HLSL_ENABLE_16_BIT
+__attribute__((clang_builtin_alias(__builtin_elementwise_bitreverse)))
+int16_t reversebits(int16_t);
+__attribute__((clang_builtin_alias(__builtin_elementwise_bitreverse)))
+int16_t2 reversebits(int16_t2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_bitreverse)))
+int16_t3 reversebits(int16_t3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_bitreverse)))
+int16_t4 reversebits(int16_t4);
+
+__attribute__((clang_builtin_alias(__builtin_elementwise_bitreverse)))
+uint16_t reversebits(uint16_t);
+__attribute__((clang_builtin_alias(__builtin_elementwise_bitreverse)))
+uint16_t2 reversebits(uint16_t2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_bitreverse)))
+uint16_t3 reversebits(uint16_t3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_bitreverse)))
+uint16_t4 reversebits(uint16_t4);
+#endif
+
+__attribute__((clang_builtin_alias(__builtin_elementwise_bitreverse))) int
+reversebits(int);
+__attribute__((clang_builtin_alias(__builtin_elementwise_bitreverse)))
+int2 reversebits(int2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_bitreverse)))
+int3 reversebits(int3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_bitreverse)))
+int4 reversebits(int4);
+
+__attribute__((clang_builtin_alias(__builtin_elementwise_bitreverse)))
+uint reversebits(uint);
+__attribute__((clang_builtin_alias(__builtin_elementwise_bitreverse)))
+uint2 reversebits(uint2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_bitreverse)))
+uint3 reversebits(uint3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_bitreverse)))
+uint4 reversebits(uint4);
+
+__attribute__((clang_builtin_alias(__builtin_elementwise_bitreverse)))
+int64_t reversebits(int64_t);
+__attribute__((clang_builtin_alias(__builtin_elementwise_bitreverse)))
+int64_t2 reversebits(int64_t2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_bitreverse)))
+int64_t3 reversebits(int64_t3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_bitreverse)))
+int64_t4 reversebits(int64_t4);
+
+__attribute__((clang_builtin_alias(__builtin_elementwise_bitreverse)))
+uint64_t reversebits(uint64_t);
+__attribute__((clang_builtin_alias(__builtin_elementwise_bitreverse)))
+uint64_t2 reversebits(uint64_t2);
+__attribute__((clang_builtin_alias(__builtin_elementwise_bitreverse)))
+uint64_t3 reversebits(uint64_t3);
+__attribute__((clang_builtin_alias(__builtin_elementwise_bitreverse)))
+uint64_t4 reversebits(uint64_t4);
 } // namespace hlsl
 #endif //_HLSL_HLSL_INTRINSICS_H_

diff  --git a/clang/test/CodeGenHLSL/builtins/bitreverse.hlsl 
b/clang/test/CodeGenHLSL/builtins/bitreverse.hlsl
new file mode 100644
index 00..e7609a2b61e259
--- /dev/null
+++ b/clang/test/CodeGenHLSL/builtins/bitreverse.hlsl
@@ -0,0 +1,155 @@
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -D__HLSL_ENABLE_16_BIT \
+// RUN:   -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s
+
+#ifdef __HLSL_ENABLE_16_BIT
+// CHECK: define noundef i16 @
+// CHECK: call i16 @llvm.bitreverse.i16(
+int16_t test_bitreverse_short(int16_t p0)
+{
+   return reversebits(p0);
+}
+// CHECK: define noundef <2 x i16> @
+// CHECK: call <2 x i16> @llvm.bitreverse.v2i16(
+int16_t2 test_bitreverse_short2(int16_t2 p0)
+{
+   return reversebits(p0);
+}
+// CHECK: define noundef <3 x i16> @
+// CHECK: call <3 x i16> @llvm.bitreverse.v3i16
+int16_t3 test_bitreverse_short3(int16_t3 p0)
+{
+   return reversebi

[PATCH] D152770: [clang][ExtractAPI] Add support for Objective-C categories

2023-08-02 Thread R4444 via Phabricator via cfe-commits
Ruturaj4 updated this revision to Diff 546683.
Ruturaj4 added a comment.



1. Updating D152770 : [clang][ExtractAPI] Add 
support for Objective-C categories #
2. Enter a brief description of the changes included in this update.
3. The first line is used as subject, next lines as comment. #
4. If you intended to create a new revision, use:
5. $ arc diff --create

Upload the correct patch and update.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152770

Files:
  clang/include/clang/ExtractAPI/API.h
  clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
  clang/include/clang/ExtractAPI/Serialization/SerializerBase.h
  clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
  clang/lib/ExtractAPI/API.cpp
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
  clang/test/ExtractAPI/objc_module_category.m
  clang/test/ExtractAPI/objc_various_categories.m

Index: clang/test/ExtractAPI/objc_various_categories.m
===
--- /dev/null
+++ clang/test/ExtractAPI/objc_various_categories.m
@@ -0,0 +1,671 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}@g" \
+// RUN: %t/reference.output.json.in >> %t/reference.output.json
+// RUN: %clang -extract-api -x objective-c-header \
+// RUN: -target arm64-apple-macosx \
+// RUN: %t/myclass_1.h \
+// RUN: %t/input.h -o %t/output.json | FileCheck -allow-empty %s
+
+// Generator version is not consistent across test runs, normalize it.
+// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
+// RUN: %t/output.json >> %t/output-normalized.json
+// RUN: diff %t/reference.output.json %t/output-normalized.json
+
+// CHECK-NOT: error:
+// CHECK-NOT: warning:
+
+//--- input.h
+#import 
+#import "myclass_1.h"
+#import "myclass_2.h"
+
+@interface MyClass1 (MyCategory1)
+- (int) SomeMethod;
+@end
+
+@interface MyClass2 (MyCategory2)
+- (int) SomeMethod2;
+@end
+
+@interface NSString (Category1)
+-(void) StringMethod;
+@end
+
+@interface NSString (Category2)
+-(void) StringMethod2;
+@end
+
+//--- myclass_1.h
+@interface MyClass1
+@end
+
+//--- myclass_2.h
+@interface MyClass2
+@end
+
+//--- reference.output.json.in
+{
+  "metadata": {
+"formatVersion": {
+  "major": 0,
+  "minor": 5,
+  "patch": 3
+},
+"generator": "?"
+  },
+  "module": {
+"name": "",
+"platform": {
+  "architecture": "arm64",
+  "operatingSystem": {
+"minimumVersion": {
+  "major": 11,
+  "minor": 0,
+  "patch": 0
+},
+"name": "macosx"
+  },
+  "vendor": "apple"
+}
+  },
+  "relationships": [
+{
+  "kind": "memberOf",
+  "source": "c:objc(cs)MyClass1(im)SomeMethod",
+  "target": "c:objc(cs)MyClass1",
+  "targetFallback": "MyClass1"
+},
+{
+  "kind": "extensionTo",
+  "source": "c:objc(cy)MyClass2@MyCategory2",
+  "target": "c:objc(cs)MyClass2",
+  "targetFallback": "MyClass2"
+},
+{
+  "kind": "memberOf",
+  "source": "c:objc(cs)MyClass2(im)SomeMethod2",
+  "target": "c:objc(cy)MyClass2@MyCategory2",
+  "targetFallback": "MyCategory2"
+},
+{
+  "kind": "extensionTo",
+  "source": "c:objc(cy)NSString@Category1",
+  "target": "c:objc(cs)NSString",
+  "targetFallback": "NSString"
+},
+{
+  "kind": "memberOf",
+  "source": "c:objc(cs)NSString(im)StringMethod",
+  "target": "c:objc(cy)NSString@Category1",
+  "targetFallback": "Category1"
+},
+{
+  "kind": "extensionTo",
+  "source": "c:objc(cy)NSString@Category2",
+  "target": "c:objc(cs)NSString",
+  "targetFallback": "NSString"
+},
+{
+  "kind": "memberOf",
+  "source": "c:objc(cs)NSString(im)StringMethod2",
+  "target": "c:objc(cy)NSString@Category2",
+  "targetFallback": "Category2"
+}
+  ],
+  "symbols": [
+{
+  "accessLevel": "public",
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "@interface"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "MyClass1"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "objective-c",
+"precise": "c:objc(cs)MyClass1"
+  },
+  "kind": {
+"displayName": "Class",
+"identifier": "objective-c.class"
+  },
+  "location": {
+"position": {
+  "character": 12,
+  "line": 1
+},
+"uri": "file://INPUT_DIR/myclass_1.h"
+  },
+  "names": {
+"navigator": [
+  {
+"kind": "identifier",
+"spelling": "MyClass1"
+  }
+],
+"subHeading": [
+  {
+"kind": "identifier",
+"spe

[PATCH] D152770: [clang][ExtractAPI] Add support for Objective-C categories

2023-08-02 Thread R4444 via Phabricator via cfe-commits
Ruturaj4 added inline comments.



Comment at: clang/include/clang/ExtractAPI/ExtractAPIVisitor.h:488
+  bool IsFromExternalModule = true;
+  for (const auto &Interface : API.getObjCInterfaces()) {
+if (InterfaceDecl->getName() == Interface.second.get()->Name) {

dang wrote:
> I think this is fine for now but there must be a better way of doing this 
> that doesn't involve traversing the whole APISet
I looked at different api methods, but still not able to figure it out. I will 
do it once this gets approved. In a following patch.



Comment at: clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp:219
   Object Identifier;
-  Identifier["precise"] = Record.USR;
+  if (auto *CategoryRecord =
+  dyn_cast_or_null(&Record))

dang wrote:
> I don't think this is right. My expectation is that category records that 
> need to get emitted would still have their own unique USR.
Thanks. I removed the check.



Comment at: clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp:759
+  // Check if the current Category Record has been visited before, if not add.
+  if (!(visitedCategories.contains(Record.Interface.Name) > 0)) {
+visitedCategories.insert(Record.Interface.Name);

dang wrote:
> What happens when there are multiple categories to the same type though?
Yes! I added this check keeping that in mind. If the parent symbol of the 
category is not added before then it pushes it to serialize (but skips if 
already present). Otherwise, just adds the category.

For e.g. in example test - objc_various_categories.m, there are two categories 
extending the same type:

```
@interface NSString (Category1)
-(void) StringMethod;
@end

@interface NSString (Category2)
-(void) StringMethod2;
@end
```

In this case, it adds the symbol for NSString (parent of categories `Category1` 
and `Category2`). I fixed the comments to make that clear.



Comment at: clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp:775
+  Relationship["targetFallback"] = Record.Interface.Name;
+  Relationship["kind"] = getRelationshipString(RelationshipKind::MemberOf);
+  Relationships.emplace_back(std::move(Relationship));

dang wrote:
> I would expect this to be a new relationship kind that reads as "extensionTo"
Thanks, that makes sense. I fixed it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152770

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


[PATCH] D152770: [clang][ExtractAPI] Add support for Objective-C categories

2023-08-02 Thread R4444 via Phabricator via cfe-commits
Ruturaj4 updated this revision to Diff 546682.
Ruturaj4 marked 4 inline comments as done.
Ruturaj4 added a comment.



1. Updating D152770 : [clang][ExtractAPI] Add 
support for Objective-C categories #
2. Enter a brief description of the changes included in this update.
3. The first line is used as subject, next lines as comment. #
4. If you intended to create a new revision, use:
5. $ arc diff --create

Made all the changes according to comments.

1. Removed check on line #219 to include unique USR for categories.
2. Explained how multiple categories to the same type are supported.
3. Added new relationship "extensionTo".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152770

Files:
  clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
  clang/test/ExtractAPI/objc_module_category.m
  clang/test/ExtractAPI/objc_various_categories.m

Index: clang/test/ExtractAPI/objc_various_categories.m
===
--- clang/test/ExtractAPI/objc_various_categories.m
+++ clang/test/ExtractAPI/objc_various_categories.m
@@ -77,7 +77,7 @@
   "targetFallback": "MyClass1"
 },
 {
-  "kind": "memberOf",
+  "kind": "extensionTo",
   "source": "c:objc(cy)MyClass2@MyCategory2",
   "target": "c:objc(cs)MyClass2",
   "targetFallback": "MyClass2"
@@ -89,7 +89,7 @@
   "targetFallback": "MyCategory2"
 },
 {
-  "kind": "memberOf",
+  "kind": "extensionTo",
   "source": "c:objc(cy)NSString@Category1",
   "target": "c:objc(cs)NSString",
   "targetFallback": "NSString"
@@ -101,7 +101,7 @@
   "targetFallback": "Category1"
 },
 {
-  "kind": "memberOf",
+  "kind": "extensionTo",
   "source": "c:objc(cy)NSString@Category2",
   "target": "c:objc(cs)NSString",
   "targetFallback": "NSString"
@@ -241,7 +241,7 @@
   "accessLevel": "public",
   "identifier": {
 "interfaceLanguage": "objective-c",
-"precise": "c:objc(cs)MyClass2"
+"precise": "c:objc(cy)MyClass2@MyCategory2"
   },
   "kind": {
 "displayName": "Module Extension",
@@ -279,7 +279,7 @@
   ],
   "identifier": {
 "interfaceLanguage": "objective-c",
-"precise": "c:objc(cs)MyClass2"
+"precise": "c:objc(cy)MyClass2@MyCategory2"
   },
   "kind": {
 "displayName": "Class Extension",
@@ -388,7 +388,7 @@
   "accessLevel": "public",
   "identifier": {
 "interfaceLanguage": "objective-c",
-"precise": "c:objc(cs)NSString"
+"precise": "c:objc(cy)NSString@Category1"
   },
   "kind": {
 "displayName": "Module Extension",
@@ -426,7 +426,7 @@
   ],
   "identifier": {
 "interfaceLanguage": "objective-c",
-"precise": "c:objc(cs)NSString"
+"precise": "c:objc(cy)NSString@Category1"
   },
   "kind": {
 "displayName": "Class Extension",
@@ -562,7 +562,7 @@
   ],
   "identifier": {
 "interfaceLanguage": "objective-c",
-"precise": "c:objc(cs)NSString"
+"precise": "c:objc(cy)NSString@Category2"
   },
   "kind": {
 "displayName": "Class Extension",
Index: clang/test/ExtractAPI/objc_module_category.m
===
--- clang/test/ExtractAPI/objc_module_category.m
+++ clang/test/ExtractAPI/objc_module_category.m
@@ -53,7 +53,7 @@
   },
   "relationships": [
 {
-  "kind": "memberOf",
+  "kind": "extensionTo",
   "source": "c:objc(cy)NSString@Category1",
   "target": "c:objc(cs)NSString",
   "targetFallback": "NSString"
@@ -65,7 +65,7 @@
   "targetFallback": "Category1"
 },
 {
-  "kind": "memberOf",
+  "kind": "extensionTo",
   "source": "c:objc(cy)NSString@Category2",
   "target": "c:objc(cs)NSString",
   "targetFallback": "NSString"
@@ -82,7 +82,7 @@
   "accessLevel": "public",
   "identifier": {
 "interfaceLanguage": "objective-c",
-"precise": "c:objc(cs)NSString"
+"precise": "c:objc(cy)NSString@Category1"
   },
   "kind": {
 "displayName": "Module Extension",
@@ -137,7 +137,7 @@
   },
   "identifier": {
 "interfaceLanguage": "objective-c",
-"precise": "c:objc(cs)NSString"
+"precise": "c:objc(cy)NSString@Category1"
   },
   "kind": {
 "displayName": "Class Extension",
@@ -290,7 +290,7 @@
   },
   "identifier": {
 "interfaceLanguage": "objective-c",
-"precise": "c:objc(cs)NSString"
+"precise": "c:objc(cy)NSString@Category2"
   },
   "kind": {
 "displayName": "Class Extension",
Index: clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
=

[PATCH] D155145: [X86] Add AVX-VNNI-INT16 instructions.

2023-08-02 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a comment.

In D155145#4556178 , @craig.topper 
wrote:

> In D155145#4556157 , @anna wrote:
>
>> In D155145#4554786 , @anna wrote:
>>
 Can you capture the values of EAX, EBX, ECX, and EDX after the two calls 
 to getX86CpuIDAndInfoEx that have 0x7 as the first argument? Maybe there's 
 a bug in CPUID on Sandy Bridge.
>>>
>>> Sure, on the original code before the patch you suggested right?
>>> The two calls are:
>>>
>>>bool HasLeaf7 =
>>>   MaxLevel >= 7 && !getX86CpuIDAndInfoEx(0x7, 0x0, &EAX, &EBX, 
>>> &ECX, &EDX);
>>>   +   llvm::errs() << "Before setting fsgsbase the value for EAX: " << EAX
>>>   + << " EBX: " << EBX << " ECX: " << ECX << "  EDX: " 
>>> << EDX
>>>   + << "\n";
>>> 
>>>   Features["fsgsbase"]   = HasLeaf7 && ((EBX >>  0) & 1);
>>>   
>>>   bool HasLeaf7Subleaf1 =
>>>   MaxLevel >= 7 && !getX86CpuIDAndInfoEx(0x7, 0x1, &EAX, &EBX, 
>>> &ECX, &EDX);
>>>   +   llvm::errs() << "Before setting sha512 the value for EAX: " << EAX
>>>   + << " EBX: " << EBX << " ECX: " << ECX << "  EDX: " 
>>> << EDX
>>>   + << "\n";
>>>   Features["sha512"] = HasLeaf7Subleaf1 && ((EAX >> 0) & 1);
>>>   ...
>>>   we set avxvnniint16 after this
>>>
>>> Takes a while to get a build on this machine, should have the output soon.
>>
>> @craig.topper here is the output:
>>
>>   Before setting fsgsbase the value for EAX: 0 EBX: 0 ECX: 0  EDX: 
>> 2617246720 // this is after the HasLeaf7 calculation
>>   Before setting sha512 the value for EAX: 0 EBX: 0 ECX: 0  EDX: 2617246720 
>> // this is after the HasLeaf7Subleaf1 calculation
>>
>> So, with your patch `HasLeaf7Subleaf1` is 0 as EAX is 0. Pls let me know if 
>> you need  any additional diagnostics output (we actually lose access to the 
>> machine on friday, since it is being retired!).
>>
>>> The documentation says that invalid subleaves of leaf 7 should return all 
>>> 0s. So we thought it was safe to check the bits of sub leaf 1 even if eax 
>>> from subleaf 0 doesn't say subleaf 1 is supported.
>>
>> This means the CPUID doesn't satisfy the documentation since EDX != 0 for 
>> SubLeaf1?
>
> Interestingly all of the bits set in EDX are features that were things that 
> were added in microcode patches in the wake of vulnerabilities like Spectre 
> and Meltdown. Maybe the microcode patch forgot to check the subleaf since 
> there was no subleaf implemented when sandy bridge was originally made.
>
> I think my patch is the correct fix given that information. I'll post a patch 
> for review shortly.

Thanks Craig! That makes sense to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155145

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


[PATCH] D156962: [Driver] Mark m_x86_Features_Group options as TargetSpecific

2023-08-02 Thread Kan Shengchen via Phabricator via cfe-commits
skan accepted this revision.
skan added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156962

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


[PATCH] D138810: [RISCV] Support vector crypto extension C intrinsics

2023-08-02 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat updated this revision to Diff 546677.
4vtomat added a comment.

Update missing comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138810

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/include/clang/Basic/riscv_vector_common.td
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdf.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdm.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesef.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesem.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaeskf1.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaeskf2.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesz.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vandn.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vbrev.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vbrev8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vclmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vclmulh.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vclz.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vcpopv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vctz.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vghsh.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vgmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vrev8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vrol.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vror.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsha2ch.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsha2cl.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsha2ms.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsm3c.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsm3me.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsm4k.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsm4r.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vwsll.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesdf.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesdm.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesef.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesem.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaeskf1.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaeskf2.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesz.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vandn.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vbrev.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vbrev8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vclmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vclmulh.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vclz.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vcpopv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vctz.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vghsh.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vgmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vrev8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vrol.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vror.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsha2ch.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsha2cl.c
  
clang/test/CodeGen/RISCV/rvv-intr

[PATCH] D155145: [X86] Add AVX-VNNI-INT16 instructions.

2023-08-02 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D155145#4556157 , @anna wrote:

> In D155145#4554786 , @anna wrote:
>
>>> Can you capture the values of EAX, EBX, ECX, and EDX after the two calls to 
>>> getX86CpuIDAndInfoEx that have 0x7 as the first argument? Maybe there's a 
>>> bug in CPUID on Sandy Bridge.
>>
>> Sure, on the original code before the patch you suggested right?
>> The two calls are:
>>
>>bool HasLeaf7 =
>>   MaxLevel >= 7 && !getX86CpuIDAndInfoEx(0x7, 0x0, &EAX, &EBX, &ECX, 
>> &EDX);
>>   +   llvm::errs() << "Before setting fsgsbase the value for EAX: " << EAX
>>   + << " EBX: " << EBX << " ECX: " << ECX << "  EDX: " 
>> << EDX
>>   + << "\n";
>> 
>>   Features["fsgsbase"]   = HasLeaf7 && ((EBX >>  0) & 1);
>>   
>>   bool HasLeaf7Subleaf1 =
>>   MaxLevel >= 7 && !getX86CpuIDAndInfoEx(0x7, 0x1, &EAX, &EBX, &ECX, 
>> &EDX);
>>   +   llvm::errs() << "Before setting sha512 the value for EAX: " << EAX
>>   + << " EBX: " << EBX << " ECX: " << ECX << "  EDX: " 
>> << EDX
>>   + << "\n";
>>   Features["sha512"] = HasLeaf7Subleaf1 && ((EAX >> 0) & 1);
>>   ...
>>   we set avxvnniint16 after this
>>
>> Takes a while to get a build on this machine, should have the output soon.
>
> @craig.topper here is the output:
>
>   Before setting fsgsbase the value for EAX: 0 EBX: 0 ECX: 0  EDX: 2617246720 
> // this is after the HasLeaf7 calculation
>   Before setting sha512 the value for EAX: 0 EBX: 0 ECX: 0  EDX: 2617246720 
> // this is after the HasLeaf7Subleaf1 calculation
>
> So, with your patch `HasLeaf7Subleaf1` is 0 as EAX is 0. Pls let me know if 
> you need  any additional diagnostics output (we actually lose access to the 
> machine on friday, since it is being retired!).
>
>> The documentation says that invalid subleaves of leaf 7 should return all 
>> 0s. So we thought it was safe to check the bits of sub leaf 1 even if eax 
>> from subleaf 0 doesn't say subleaf 1 is supported.
>
> This means the CPUID doesn't satisfy the documentation since EDX != 0 for 
> SubLeaf1?

Interestingly all of the bits set in EDX are features that were things that 
were added in microcode patches in the wake of vulnerabilities like Spectre and 
Meltdown. Maybe the microcode patch forgot to check the subleaf since there was 
no subleaf implemented when sandy bridge was originally made.

I think my patch is the correct fix given that information. I'll post a patch 
for review shortly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155145

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


[PATCH] D155145: [X86] Add AVX-VNNI-INT16 instructions.

2023-08-02 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a comment.

In D155145#4556157 , @anna wrote:

> In D155145#4554786 , @anna wrote:
>
>>> Can you capture the values of EAX, EBX, ECX, and EDX after the two calls to 
>>> getX86CpuIDAndInfoEx that have 0x7 as the first argument? Maybe there's a 
>>> bug in CPUID on Sandy Bridge.
>>
>> Sure, on the original code before the patch you suggested right?
>> The two calls are:
>>
>>bool HasLeaf7 =
>>   MaxLevel >= 7 && !getX86CpuIDAndInfoEx(0x7, 0x0, &EAX, &EBX, &ECX, 
>> &EDX);
>>   +   llvm::errs() << "Before setting fsgsbase the value for EAX: " << EAX
>>   + << " EBX: " << EBX << " ECX: " << ECX << "  EDX: " 
>> << EDX
>>   + << "\n";
>> 
>>   Features["fsgsbase"]   = HasLeaf7 && ((EBX >>  0) & 1);
>>   
>>   bool HasLeaf7Subleaf1 =
>>   MaxLevel >= 7 && !getX86CpuIDAndInfoEx(0x7, 0x1, &EAX, &EBX, &ECX, 
>> &EDX);
>>   +   llvm::errs() << "Before setting sha512 the value for EAX: " << EAX
>>   + << " EBX: " << EBX << " ECX: " << ECX << "  EDX: " 
>> << EDX
>>   + << "\n";
>>   Features["sha512"] = HasLeaf7Subleaf1 && ((EAX >> 0) & 1);
>>   ...
>>   we set avxvnniint16 after this
>>
>> Takes a while to get a build on this machine, should have the output soon.
>
> @craig.topper here is the output:
>
>   Before setting fsgsbase the value for EAX: 0 EBX: 0 ECX: 0  EDX: 2617246720 
> // this is after the HasLeaf7 calculation
>   Before setting sha512 the value for EAX: 0 EBX: 0 ECX: 0  EDX: 2617246720 
> // this is after the HasLeaf7Subleaf1 calculation
>
> So, with your patch `HasLeaf7Subleaf1` is 0 as EAX is 0. Pls let me know if 
> you need  any additional diagnostics output (we actually lose access to the 
> machine on friday, since it is being retired!).
>
>> The documentation says that invalid subleaves of leaf 7 should return all 
>> 0s. So we thought it was safe to check the bits of sub leaf 1 even if eax 
>> from subleaf 0 doesn't say subleaf 1 is supported.
>
> This means the CPUID doesn't satisfy the documentation since EDX != 0 for 
> SubLeaf1?

The identical EDX value looks dubious to me. Could you compile and run above 
code and paste the result here? Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155145

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


[PATCH] D156962: [Driver] Mark m_x86_Features_Group options as TargetSpecific

2023-08-02 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: pengfei, skan, RKSimon.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

so that they lead to an error when compiled for non-x86 targets.
Follow-up to D151590 .

  % aarch64-linux-gnu-gcc -c -mavx a.c
  aarch64-linux-gnu-gcc: error: unrecognized command-line option ‘-mavx’
  % clang --target=aarch64-unknown-linux-gnu -c -mavx a.c  # without this patch
  clang: warning: argument unused during compilation: '-mavx' 
[-Wunused-command-line-argument]
  ...
  
  % clang --target=aarch64-unknown-linux-gnu -c -mavx a.c  # with this patch
  clang: error: unsupported option '-mavx' for target 
'aarch64-unknown-linux-gnu'

As a workaround for https://github.com/llvm/llvm-project/issues/63270, we don't
report an error for -msse4.2.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156962

Files:
  clang/include/clang/Driver/Options.td
  clang/test/Driver/x86-target-features.c


Index: clang/test/Driver/x86-target-features.c
===
--- clang/test/Driver/x86-target-features.c
+++ clang/test/Driver/x86-target-features.c
@@ -374,6 +374,13 @@
 // CRC32: "-target-feature" "+crc32"
 // NO-CRC32: "-target-feature" "-crc32"
 
+// RUN: %clang -### --target=aarch64 -mcrc32 -msse4.1 -msse4.2 -mno-sgx %s 
2>&1 | FileCheck --check-prefix=NONX86 %s
+// NONX86:  error: unsupported option '-mcrc32' for target 'aarch64'
+// NONX86-NEXT: error: unsupported option '-msse4.1' for target 'aarch64'
+/// TODO: This warning is a workaround for 
https://github.com/llvm/llvm-project/issues/63270
+// NONX86-NEXT: warning: argument unused during compilation: '-msse4.2' 
[-Wunused-command-line-argument]
+// NONX86-NEXT: error: unsupported option '-mno-sgx' for target 'aarch64'
+
 // RUN: %clang --target=i386 -march=i386 -mharden-sls=return %s -### -o %t.o 
2>&1 | FileCheck -check-prefixes=SLS-RET,NO-SLS %s
 // RUN: %clang --target=i386 -march=i386 -mharden-sls=indirect-jmp %s -### -o 
%t.o 2>&1 | FileCheck -check-prefixes=SLS-IJMP,NO-SLS %s
 // RUN: %clang --target=i386 -march=i386 -mharden-sls=none -mharden-sls=all %s 
-### -o %t.o 2>&1 | FileCheck -check-prefixes=SLS-IJMP,SLS-RET %s
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4887,6 +4887,7 @@
 } // let Flags = [TargetSpecific]
 
 // X86 feature flags
+let Flags = [TargetSpecific] in {
 def mx87 : Flag<["-"], "mx87">, Group;
 def mno_x87 : Flag<["-"], "mno-x87">, Group;
 def m80387 : Flag<["-"], "m80387">, Alias;
@@ -4920,7 +4921,11 @@
 def mno_ssse3 : Flag<["-"], "mno-ssse3">, Group;
 def msse4_1 : Flag<["-"], "msse4.1">, Group;
 def mno_sse4_1 : Flag<["-"], "mno-sse4.1">, Group;
+} // let Flags = [TargetSpecific]
+// TODO: Make -msse4.2 TargetSpecific after
+// https://github.com/llvm/llvm-project/issues/63270 is fixed.
 def msse4_2 : Flag<["-"], "msse4.2">, Group;
+let Flags = [TargetSpecific] in {
 def mno_sse4_2 : Flag<["-"], "mno-sse4.2">, Group;
 def msse4 : Flag<["-"], "msse4">, Alias;
 // -mno-sse4 turns off sse4.1 which has the effect of turning off everything
@@ -5101,6 +5106,7 @@
 def mno_retpoline_external_thunk : Flag<["-"], 
"mno-retpoline-external-thunk">, Group;
 def mvzeroupper : Flag<["-"], "mvzeroupper">, Group;
 def mno_vzeroupper : Flag<["-"], "mno-vzeroupper">, 
Group;
+} // let Flags = [TargetSpecific]
 
 // These are legacy user-facing driver-level option spellings. They are always
 // aliases for options that are spelled using the more common Unix / GNU flag


Index: clang/test/Driver/x86-target-features.c
===
--- clang/test/Driver/x86-target-features.c
+++ clang/test/Driver/x86-target-features.c
@@ -374,6 +374,13 @@
 // CRC32: "-target-feature" "+crc32"
 // NO-CRC32: "-target-feature" "-crc32"
 
+// RUN: %clang -### --target=aarch64 -mcrc32 -msse4.1 -msse4.2 -mno-sgx %s 2>&1 | FileCheck --check-prefix=NONX86 %s
+// NONX86:  error: unsupported option '-mcrc32' for target 'aarch64'
+// NONX86-NEXT: error: unsupported option '-msse4.1' for target 'aarch64'
+/// TODO: This warning is a workaround for https://github.com/llvm/llvm-project/issues/63270
+// NONX86-NEXT: warning: argument unused during compilation: '-msse4.2' [-Wunused-command-line-argument]
+// NONX86-NEXT: error: unsupported option '-mno-sgx' for target 'aarch64'
+
 // RUN: %clang --target=i386 -march=i386 -mharden-sls=return %s -### -o %t.o 2>&1 | FileCheck -check-prefixes=SLS-RET,NO-SLS %s
 // RUN: %clang --target=i386 -march=i386 -mharden-sls=indirect-jmp %s -### -o %t.o 2>&1 | FileCheck -check-prefixes=SLS-IJMP,NO-SLS %s
 // RUN: %clang --target=i386 -march=i386 -mharden-sls=none -

[PATCH] D155145: [X86] Add AVX-VNNI-INT16 instructions.

2023-08-02 Thread Anna Thomas via Phabricator via cfe-commits
anna added a comment.

In D155145#4554786 , @anna wrote:

>> Can you capture the values of EAX, EBX, ECX, and EDX after the two calls to 
>> getX86CpuIDAndInfoEx that have 0x7 as the first argument? Maybe there's a 
>> bug in CPUID on Sandy Bridge.
>
> Sure, on the original code before the patch you suggested right?
> The two calls are:
>
>bool HasLeaf7 =
>   MaxLevel >= 7 && !getX86CpuIDAndInfoEx(0x7, 0x0, &EAX, &EBX, &ECX, 
> &EDX);
>   +   llvm::errs() << "Before setting fsgsbase the value for EAX: " << EAX
>   + << " EBX: " << EBX << " ECX: " << ECX << "  EDX: " << 
> EDX
>   + << "\n";
> 
>   Features["fsgsbase"]   = HasLeaf7 && ((EBX >>  0) & 1);
>   
>   bool HasLeaf7Subleaf1 =
>   MaxLevel >= 7 && !getX86CpuIDAndInfoEx(0x7, 0x1, &EAX, &EBX, &ECX, 
> &EDX);
>   +   llvm::errs() << "Before setting sha512 the value for EAX: " << EAX
>   + << " EBX: " << EBX << " ECX: " << ECX << "  EDX: " << 
> EDX
>   + << "\n";
>   Features["sha512"] = HasLeaf7Subleaf1 && ((EAX >> 0) & 1);
>   ...
>   we set avxvnniint16 after this
>
> Takes a while to get a build on this machine, should have the output soon.

@ctopper here is the output:

  Before setting fsgsbase the value for EAX: 0 EBX: 0 ECX: 0  EDX: 2617246720 
// this is after the HasLeaf7 calculation
  Before setting sha512 the value for EAX: 0 EBX: 0 ECX: 0  EDX: 2617246720 // 
this is after the HasLeaf7Subleaf1 calculation

So, with your patch `HasLeaf7Subleaf1` is 0 as EAX is 0. Pls let me know if you 
need  any additional diagnostics output (we actually lose access to the machine 
on friday, since it is being retired!).

> The documentation says that invalid subleaves of leaf 7 should return all 0s. 
> So we thought it was safe to check the bits of sub leaf 1 even if eax from 
> subleaf 0 doesn't say subleaf 1 is supported.

This means the CPUID doesn't satisfy the documentation since EDX != 0 for 
SubLeaf1?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155145

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


[PATCH] D155145: [X86] Add AVX-VNNI-INT16 instructions.

2023-08-02 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a comment.

Thanks @anna and @craig.topper 
I think we can dump the value with the simple code

  $ cat cpuid.c
  #include 
  #include 
  
  int main() {
unsigned int info[4];
for (int i = 0; i < 2; ++i) {
  __get_cpuid_count(7, 1, info, info + 1, info + 2, info + 3);
  printf("%08x\n", info[0]);
  printf("%08x\n", info[1]);
  printf("%08x\n", info[2]);
  printf("%08x\n", info[3]);
}
  }
  
  $ clang cpuid.c && ./a.out


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155145

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


[PATCH] D138810: [RISCV] Support vector crypto extension C intrinsics

2023-08-02 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat added inline comments.



Comment at: clang/include/clang/Basic/riscv_vector.td:2405
+  defvar suffix = !if(IsVV, "vv", "vi");
+  defvar prototype = !if(IsVV, "UvUvUvUv", "UvUvUvKz");
+  defm "" : RVVBuiltinSet;

craig.topper wrote:
> Can we split this into two classes and get rid of IsVV?
Sure, good idea~



Comment at: clang/lib/Sema/SemaChecking.cpp:4693
+  }
+  case RISCVVector::BI__builtin_rvv_vaesdf_vv:
+  case RISCVVector::BI__builtin_rvv_vaesdf_vs:

craig.topper wrote:
> Are there `tu` versions of these builtins?
Yes, there are, thanks for reminding!



Comment at: 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vwsll.c:12
+//
+vint16mf4_t test_vwsll_vv_i16mf4(vint8mf8_t op1, vint8mf8_t op2, size_t vl) {
+  return __riscv_vwsll_vv_i16mf4(op1, op2, vl);

craig.topper wrote:
> craig.topper wrote:
> > It doesn't make sense for op2 to be signed. It's a shift amount, its always 
> > a positive number
> The spec doesn't define signed versions of these instrinsics from what I can 
> see.
You are right, maybe it should only be signed version!



Comment at: clang/test/Sema/zvk-invalid.c:19
+  __riscv_vaesdf_vv_u32mf2(vd, vs2, vl); // expected-error {{RISC-V type 
'vuint32mf2_t' (aka '__rvv_uint32mf2_t') requires the 'zvl256b' extension}}
+}

craig.topper wrote:
> Test a _vs intrinsic since the vs operand has a different type than the 
> result?
Sure~


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138810

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


[PATCH] D138810: [RISCV] Support vector crypto extension C intrinsics

2023-08-02 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat updated this revision to Diff 546671.
4vtomat marked 3 inline comments as done.
4vtomat added a comment.

This update does a few things:

1. Update Craig's comments.
2. Make `LMUL=8` 
valid(https://github.com/riscv-non-isa/rvv-intrinsic-doc/pull/234#discussion_r1282568330).
3. Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138810

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/include/clang/Basic/riscv_vector_common.td
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdf.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesdm.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesef.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesem.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaeskf1.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaeskf2.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaesz.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vandn.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vbrev.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vbrev8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vclmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vclmulh.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vclz.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vcpopv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vctz.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vghsh.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vgmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vrev8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vrol.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vror.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsha2ch.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsha2cl.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsha2ms.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsm3c.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsm3me.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsm4k.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsm4r.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vwsll.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesdf.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesdm.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesef.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesem.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaeskf1.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaeskf2.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaesz.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vandn.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vbrev.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vbrev8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vclmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vclmulh.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vclz.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vcpopv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vctz.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vghsh.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vgmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vrev8.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vrol.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vror.c
  
clang/test/Co

[PATCH] D156441: [clangd]Fix addUsing tweak doesn't traverse same-level anon namespaces

2023-08-02 Thread zhou via Phabricator via cfe-commits
chouzz added a comment.

@kadircet Could you please take a look this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156441

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


[PATCH] D155850: [Clang][CodeGen][RFC] Add codegen support for C++ Parallel Algorithm Offload

2023-08-02 Thread Alex Voicu via Phabricator via cfe-commits
AlexVlx added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:5315
+  !GV->isThreadLocal() &&
+  !(getLangOpts().HIPStdPar && getLangOpts().CUDAIsDevice)) {
 if (D->getTLSKind() == VarDecl::TLS_Dynamic)

efriedma wrote:
> You can't just pretend a thread-local variable isn't thread-local.  If the 
> intent here is that thread-local variables are illegal in device code, you 
> need to figure out some way to produce a diagnostic.  (Maybe by generating a 
> call to __stdpar_unsupported_threadlocal or something like that if code tries 
> to refer to such a variable.)
Oh, this is actually an error that slipped through, I botched the diff it 
appears, I'll correct it, apologies.


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

https://reviews.llvm.org/D155850

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


[PATCH] D156466: [clang][CGExprConstant] handle implicit widening/narrowing Int-to-Int casts

2023-08-02 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 546646.
nickdesaulniers edited the summary of this revision.
nickdesaulniers added a comment.

- update description


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156466

Files:
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/test/CodeGen/global-init.c


Index: clang/test/CodeGen/global-init.c
===
--- clang/test/CodeGen/global-init.c
+++ clang/test/CodeGen/global-init.c
@@ -49,6 +49,11 @@
 // CHECK: @yuv_types ={{.*}} global [4 x [6 x i8]] {{\[}}[6 x i8] c"4:0:0\00", 
[6 x i8] c"4:2:0\00", [6 x i8] c"4:2:2\00", [6 x i8] c"4:4:4\00"]
 char yuv_types[4][6]= {"4:0:0","4:2:0","4:2:2","4:4:4"};
 
+unsigned long long x = -1000;
+// CHECK: @x ={{.*}} global i64 -1000
+unsigned long long uint_max = 4294967295u;
+// CHECK: @uint_max ={{.*}} global i64 4294967295
+
 
 // NOTE: tentative definitions are processed at the end of the translation 
unit.
 
Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1139,6 +1139,24 @@
 case CK_IntToOCLSampler:
   llvm_unreachable("global sampler variables are not generated");
 
+case CK_IntegralCast: {
+  QualType FromType = subExpr->getType();
+  // See also HandleIntToIntCast in ExprConstant.cpp
+  if (FromType->isIntegerType())
+if (llvm::Constant *C = Visit(subExpr, FromType))
+  if (auto *CI = dyn_cast(C)) {
+unsigned SrcWidth = CGM.getContext().getIntWidth(FromType);
+unsigned DstWidth = CGM.getContext().getIntWidth(destType);
+if (DstWidth == SrcWidth)
+  return CI;
+llvm::APInt A = FromType->isSignedIntegerType()
+? CI->getValue().sextOrTrunc(DstWidth)
+: CI->getValue().zextOrTrunc(DstWidth);
+return llvm::ConstantInt::get(CGM.getLLVMContext(), A);
+  }
+  return nullptr;
+}
+
 case CK_Dependent: llvm_unreachable("saw dependent cast!");
 
 case CK_BuiltinFnToFnPtr:
@@ -1191,7 +1209,6 @@
 case CK_IntegralComplexToFloatingComplex:
 case CK_PointerToIntegral:
 case CK_PointerToBoolean:
-case CK_IntegralCast:
 case CK_BooleanToSignedIntegral:
 case CK_IntegralToPointer:
 case CK_IntegralToBoolean:


Index: clang/test/CodeGen/global-init.c
===
--- clang/test/CodeGen/global-init.c
+++ clang/test/CodeGen/global-init.c
@@ -49,6 +49,11 @@
 // CHECK: @yuv_types ={{.*}} global [4 x [6 x i8]] {{\[}}[6 x i8] c"4:0:0\00", [6 x i8] c"4:2:0\00", [6 x i8] c"4:2:2\00", [6 x i8] c"4:4:4\00"]
 char yuv_types[4][6]= {"4:0:0","4:2:0","4:2:2","4:4:4"};
 
+unsigned long long x = -1000;
+// CHECK: @x ={{.*}} global i64 -1000
+unsigned long long uint_max = 4294967295u;
+// CHECK: @uint_max ={{.*}} global i64 4294967295
+
 
 // NOTE: tentative definitions are processed at the end of the translation unit.
 
Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1139,6 +1139,24 @@
 case CK_IntToOCLSampler:
   llvm_unreachable("global sampler variables are not generated");
 
+case CK_IntegralCast: {
+  QualType FromType = subExpr->getType();
+  // See also HandleIntToIntCast in ExprConstant.cpp
+  if (FromType->isIntegerType())
+if (llvm::Constant *C = Visit(subExpr, FromType))
+  if (auto *CI = dyn_cast(C)) {
+unsigned SrcWidth = CGM.getContext().getIntWidth(FromType);
+unsigned DstWidth = CGM.getContext().getIntWidth(destType);
+if (DstWidth == SrcWidth)
+  return CI;
+llvm::APInt A = FromType->isSignedIntegerType()
+? CI->getValue().sextOrTrunc(DstWidth)
+: CI->getValue().zextOrTrunc(DstWidth);
+return llvm::ConstantInt::get(CGM.getLLVMContext(), A);
+  }
+  return nullptr;
+}
+
 case CK_Dependent: llvm_unreachable("saw dependent cast!");
 
 case CK_BuiltinFnToFnPtr:
@@ -1191,7 +1209,6 @@
 case CK_IntegralComplexToFloatingComplex:
 case CK_PointerToIntegral:
 case CK_PointerToBoolean:
-case CK_IntegralCast:
 case CK_BooleanToSignedIntegral:
 case CK_IntegralToPointer:
 case CK_IntegralToBoolean:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156466: [clang][CGExprConstant] handle implicit widening/narrowing Int-to-Int casts

2023-08-02 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 546645.
nickdesaulniers marked an inline comment as done.
nickdesaulniers added a comment.

- add test case that would have caught SExt bug
- fix SExt bug


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156466

Files:
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/test/CodeGen/global-init.c


Index: clang/test/CodeGen/global-init.c
===
--- clang/test/CodeGen/global-init.c
+++ clang/test/CodeGen/global-init.c
@@ -49,6 +49,11 @@
 // CHECK: @yuv_types ={{.*}} global [4 x [6 x i8]] {{\[}}[6 x i8] c"4:0:0\00", 
[6 x i8] c"4:2:0\00", [6 x i8] c"4:2:2\00", [6 x i8] c"4:4:4\00"]
 char yuv_types[4][6]= {"4:0:0","4:2:0","4:2:2","4:4:4"};
 
+unsigned long long x = -1000;
+// CHECK: @x ={{.*}} global i64 -1000
+unsigned long long uint_max = 4294967295u;
+// CHECK: @uint_max ={{.*}} global i64 4294967295
+
 
 // NOTE: tentative definitions are processed at the end of the translation 
unit.
 
Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1139,6 +1139,24 @@
 case CK_IntToOCLSampler:
   llvm_unreachable("global sampler variables are not generated");
 
+case CK_IntegralCast: {
+  QualType FromType = subExpr->getType();
+  // See also HandleIntToIntCast in ExprConstant.cpp
+  if (FromType->isIntegerType())
+if (llvm::Constant *C = Visit(subExpr, FromType))
+  if (auto *CI = dyn_cast(C)) {
+unsigned SrcWidth = CGM.getContext().getIntWidth(FromType);
+unsigned DstWidth = CGM.getContext().getIntWidth(destType);
+if (DstWidth == SrcWidth)
+  return CI;
+llvm::APInt A = FromType->isSignedIntegerType()
+? CI->getValue().sextOrTrunc(DstWidth)
+: CI->getValue().zextOrTrunc(DstWidth);
+return llvm::ConstantInt::get(CGM.getLLVMContext(), A);
+  }
+  return nullptr;
+}
+
 case CK_Dependent: llvm_unreachable("saw dependent cast!");
 
 case CK_BuiltinFnToFnPtr:
@@ -1191,7 +1209,6 @@
 case CK_IntegralComplexToFloatingComplex:
 case CK_PointerToIntegral:
 case CK_PointerToBoolean:
-case CK_IntegralCast:
 case CK_BooleanToSignedIntegral:
 case CK_IntegralToPointer:
 case CK_IntegralToBoolean:


Index: clang/test/CodeGen/global-init.c
===
--- clang/test/CodeGen/global-init.c
+++ clang/test/CodeGen/global-init.c
@@ -49,6 +49,11 @@
 // CHECK: @yuv_types ={{.*}} global [4 x [6 x i8]] {{\[}}[6 x i8] c"4:0:0\00", [6 x i8] c"4:2:0\00", [6 x i8] c"4:2:2\00", [6 x i8] c"4:4:4\00"]
 char yuv_types[4][6]= {"4:0:0","4:2:0","4:2:2","4:4:4"};
 
+unsigned long long x = -1000;
+// CHECK: @x ={{.*}} global i64 -1000
+unsigned long long uint_max = 4294967295u;
+// CHECK: @uint_max ={{.*}} global i64 4294967295
+
 
 // NOTE: tentative definitions are processed at the end of the translation unit.
 
Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1139,6 +1139,24 @@
 case CK_IntToOCLSampler:
   llvm_unreachable("global sampler variables are not generated");
 
+case CK_IntegralCast: {
+  QualType FromType = subExpr->getType();
+  // See also HandleIntToIntCast in ExprConstant.cpp
+  if (FromType->isIntegerType())
+if (llvm::Constant *C = Visit(subExpr, FromType))
+  if (auto *CI = dyn_cast(C)) {
+unsigned SrcWidth = CGM.getContext().getIntWidth(FromType);
+unsigned DstWidth = CGM.getContext().getIntWidth(destType);
+if (DstWidth == SrcWidth)
+  return CI;
+llvm::APInt A = FromType->isSignedIntegerType()
+? CI->getValue().sextOrTrunc(DstWidth)
+: CI->getValue().zextOrTrunc(DstWidth);
+return llvm::ConstantInt::get(CGM.getLLVMContext(), A);
+  }
+  return nullptr;
+}
+
 case CK_Dependent: llvm_unreachable("saw dependent cast!");
 
 case CK_BuiltinFnToFnPtr:
@@ -1191,7 +1209,6 @@
 case CK_IntegralComplexToFloatingComplex:
 case CK_PointerToIntegral:
 case CK_PointerToBoolean:
-case CK_IntegralCast:
 case CK_BooleanToSignedIntegral:
 case CK_IntegralToPointer:
 case CK_IntegralToBoolean:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D153924: Allowing exception handling in OpenMP target regions when offloading to AMDGCN or NVPTX targets

2023-08-02 Thread Anton Rydahl via Phabricator via cfe-commits
AntonRydahl added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticCommonKinds.td:432
+  "Target '%0' does not support exception handling."
+  " To allow code generation for '%0', 'catch' statement will be replaced by a 
no operation instruction.">;
 }

jdoerfert wrote:
> Check the style of other messages, they have a single sentence and start with 
> a lower case letter.
> Also, the explanation doesn't make sense for users. They don't know about 
> traps, basic blocks, etc.
> Maybe:
> `target '%0' does not support exception handling; 'throw' is assumed to be 
> never reached`
> `target '%0' does not support exception handling; 'catch' block is ignored`
> and nothing for try.
> Finally, these need a group so users can also disable them.
Is the group name ok? Now the warnings can be enabled with 
`-Wopenmp-target-exception` and disabled with `-Wno-openmp-target-exception`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153924

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


[PATCH] D153924: Allowing exception handling in OpenMP target regions when offloading to AMDGCN or NVPTX targets

2023-08-02 Thread Anton Rydahl via Phabricator via cfe-commits
AntonRydahl marked 2 inline comments as done.
AntonRydahl added inline comments.



Comment at: clang/lib/CodeGen/CGException.cpp:624
+  const bool is_omp_gpu_target =
+  (CGM.getLangOpts().OpenMPIsDevice && (T.isNVPTX() || T.isAMDGCN()));
+  if (is_omp_gpu_target) {

jdoerfert wrote:
> Check the LLVM style guide, or the surrounding code, for variable naming.
Is it better now? Variables have to use camel case and start with an uppercase 
character, right?



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:3837
+Opts.Exceptions = exceptions_user_enabled;
+Opts.CXXExceptions = exceptions_user_enabled;
   }

jdoerfert wrote:
> I don't get this. Is this needed?
The way it is right now before this patch, we are overwriting the users command 
line arguments. So `-fexceptions` and `fcxx-exceptions` will have no effect on 
the device. But we could introduce a new command line option instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153924

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


[PATCH] D155850: [Clang][CodeGen][RFC] Add codegen support for C++ Parallel Algorithm Offload

2023-08-02 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:5559
+return EmitStdParUnsupportedBuiltin(this, FD);
+  else
+ErrorUnsupported(E, "builtin function");

Else-after-return.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:5315
+  !GV->isThreadLocal() &&
+  !(getLangOpts().HIPStdPar && getLangOpts().CUDAIsDevice)) {
 if (D->getTLSKind() == VarDecl::TLS_Dynamic)

You can't just pretend a thread-local variable isn't thread-local.  If the 
intent here is that thread-local variables are illegal in device code, you need 
to figure out some way to produce a diagnostic.  (Maybe by generating a call to 
__stdpar_unsupported_threadlocal or something like that if code tries to refer 
to such a variable.)


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

https://reviews.llvm.org/D155850

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


[PATCH] D156948: [clang][modules] Add -Wsystem-headers-in-module=

2023-08-02 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir created this revision.
benlangmuir added reviewers: jansvoboda11, iana.
Herald added a project: All.
benlangmuir requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Add a way to enable -Wsystem-headers only for a specific module. This is useful 
for validating a module that would otherwise not see system header diagnostics 
without being flooded by diagnostics for unrelated headers/modules. It's 
relatively common for a module to be marked [system] but still wish to validate 
itself explicitly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156948

Files:
  clang/include/clang/Basic/DiagnosticOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  clang/test/ClangScanDeps/Wsystem-headers-in-module.c
  clang/test/Modules/Wsystem-headers-in-module.c

Index: clang/test/Modules/Wsystem-headers-in-module.c
===
--- /dev/null
+++ clang/test/Modules/Wsystem-headers-in-module.c
@@ -0,0 +1,32 @@
+// Check that Wsystem-headers-in-module shows diagnostics in the named system
+// module, but not in other system headers or modules.
+
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/mcp \
+// RUN:   -isystem %t/sys %t/tu.c -fsyntax-only -Wextra-semi -Wsystem-headers-in-module=sys_mod \
+// RUN:   2>&1 | FileCheck %s
+
+// CHECK-NOT: warning:
+// CHECK: sys_mod.h:2:7: warning: extra ';'
+// CHECK-NOT: warning:
+
+//--- sys/other_sys_header.h
+int x;;
+//--- sys_mod.h
+#include "dependent_sys_mod.h"
+int y;;
+//--- other_sys_mod.h
+int z;;
+//--- dependent_sys_mod.h
+int w;;
+//--- module.modulemap
+module sys_mod [system] { header "sys_mod.h" }
+module other_sys_mod [system] { header "other_sys_mod.h" }
+module dependent_sys_mod [system] { header "dependent_sys_mod.h" }
+
+//--- tu.c
+#include "sys_mod.h"
+#include "other_sys_mod.h"
+#include "other_sys_header.h"
Index: clang/test/ClangScanDeps/Wsystem-headers-in-module.c
===
--- /dev/null
+++ clang/test/ClangScanDeps/Wsystem-headers-in-module.c
@@ -0,0 +1,56 @@
+// Check that Wsystem-headers-in-module shows diagnostics in the named system
+// module, but not in other system headers or modules when built with explicit
+// modules.
+
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
+
+// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full > %t/deps.json
+
+// RUN: %deps-to-rsp %t/deps.json --module-name=dependent_sys_mod > %t/dependent_sys_mod.rsp
+// RUN: %deps-to-rsp %t/deps.json --module-name=sys_mod > %t/sys_mod.rsp
+// RUN: %deps-to-rsp %t/deps.json --module-name=other_sys_mod > %t/other_sys_mod.rsp
+// RUN: %deps-to-rsp %t/deps.json --tu-index 0 > %t/tu.rsp
+
+// RUN: %clang @%t/dependent_sys_mod.rsp -verify
+// RUN: %clang @%t/sys_mod.rsp -verify
+// RUN: %clang @%t/other_sys_mod.rsp -verify
+// RUN: %clang @%t/tu.rsp -verify
+
+// CHECK-NOT: warning:
+// CHECK: sys_mod.h:2:7: warning: extra ';'
+// CHECK-NOT: warning:
+
+//--- cdb.json.template
+[{
+  "directory": "DIR",
+  "command": "clang -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=DIR/mcp DIR/tu.c -isystem DIR/sys -Wextra-semi -Wsystem-headers-in-module=sys_mod",
+  "file": "DIR/tu.c"
+}]
+
+//--- sys/other_sys_header.h
+int x;;
+
+//--- sys_mod.h
+#include "dependent_sys_mod.h"
+int y;; // expected-warning {{extra ';' outside of a function}}
+
+//--- other_sys_mod.h
+int z;;
+// expected-no-diagnostics
+
+//--- dependent_sys_mod.h
+int w;;
+// expected-no-diagnostics
+
+//--- module.modulemap
+module sys_mod [system] { header "sys_mod.h" }
+module other_sys_mod [system] { header "other_sys_mod.h" }
+module dependent_sys_mod [system] { header "dependent_sys_mod.h" }
+
+//--- tu.c
+#include "sys_mod.h"
+#include "other_sys_mod.h"
+#include "other_sys_header.h"
+// expected-no-diagnostics
Index: clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
===
--- clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -172,6 +172,13 @@
 CI.getHeaderSearchOpts().ModulesIgnoreMacros.clear();
   }
 
+  // Apply -Wsystem-headers-in-module for the current module.
+  for (StringRef Name : CI.getDiagnosticOpts().SystemHeaderWarningsModules)
+if (Name == Deps.ID.ModuleName)
+  CI.getDiagnosticOpts().Warnings.push_back("system-headers");
+  // Remove the now unused option(s).
+  CI.getDiagnosticOpts().SystemHeaderWarningsModules.clear();
+
   Optimize(CI);
 
   return CI;
Index: clang/lib/Serializatio

[PATCH] D153924: Allowing exception handling in OpenMP target regions when offloading to AMDGCN or NVPTX targets

2023-08-02 Thread Anton Rydahl via Phabricator via cfe-commits
AntonRydahl updated this revision to Diff 546636.
AntonRydahl added a comment.
Herald added subscribers: wangpc, kerbowa, jvesely.

Updated the tests to use `%clang_cc1 -verify`. There are still things that need 
to be improved.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153924

Files:
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/lib/CodeGen/CGException.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/OpenMP/amdgpu_exceptions.cpp
  clang/test/OpenMP/amdgpu_throw.cpp
  clang/test/OpenMP/amdgpu_try_catch.cpp
  clang/test/OpenMP/nvptx_exceptions.cpp
  clang/test/OpenMP/nvptx_throw.cpp
  clang/test/OpenMP/nvptx_try_catch.cpp
  clang/test/OpenMP/x86_target_exceptions.cpp
  clang/test/OpenMP/x86_target_throw.cpp
  clang/test/OpenMP/x86_target_try_catch.cpp

Index: clang/test/OpenMP/x86_target_try_catch.cpp
===
--- /dev/null
+++ clang/test/OpenMP/x86_target_try_catch.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fopenmp -triple x86_64-pc-linux-gnu -fopenmp-is-target-device -fcxx-exceptions -fexceptions %s -emit-llvm -S -verify -Wopenmp-target-exception
+#pragma omp declare target
+int foo(void) {
+	int error = -1;
+	try {
+		error = 1;
+	}
+	catch (int e){ 
+		error = e;
+	}
+	return error;
+}
+#pragma omp end declare target
+// expected-no-diagnostics
Index: clang/test/OpenMP/x86_target_throw.cpp
===
--- /dev/null
+++ clang/test/OpenMP/x86_target_throw.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fopenmp -triple x86_64-pc-linux-gnu -fopenmp-is-target-device -fcxx-exceptions -fexceptions %s -emit-llvm -S -verify -Wopenmp-target-exception
+#pragma omp declare target
+void foo(void) {
+	throw 404;
+}
+#pragma omp end declare target
+// expected-no-diagnostics
Index: clang/test/OpenMP/x86_target_exceptions.cpp
===
--- /dev/null
+++ clang/test/OpenMP/x86_target_exceptions.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fopenmp -triple x86_64-pc-linux-gnu -fopenmp-is-target-device -fcxx-exceptions -fexceptions %s -emit-llvm -S -verify -Wopenmp-target-exception
+#pragma omp declare target
+int foo(void) {
+	int error = -1;
+	try {
+		throw 404;
+	}
+	catch (int e){ 
+		error = e;
+	}
+	return error;
+}
+#pragma omp end declare target
+// expected-no-diagnostics
Index: clang/test/OpenMP/nvptx_try_catch.cpp
===
--- /dev/null
+++ clang/test/OpenMP/nvptx_try_catch.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device -fcxx-exceptions -fexceptions %s -emit-llvm -S -verify=with -Wopenmp-target-exception
+// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device -fcxx-exceptions -fexceptions %s -emit-llvm -S -verify=without -Wno-openmp-target-exception
+// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device %s -emit-llvm -S -verify=noexceptions
+
+// noexceptions-error@10 {{cannot use 'try' with exceptions disabled}}
+
+#pragma omp declare target
+int foo(void) {
+	int error = -1;
+	try { // with-warning {{target 'nvptx64' does not support exception handling; 'catch' block is ignored}}
+		error = 1;
+	}
+	catch (int e){ 
+		error = e;
+	}
+	return error;
+}
+#pragma omp end declare target
+// without-no-diagnostics
Index: clang/test/OpenMP/nvptx_throw.cpp
===
--- /dev/null
+++ clang/test/OpenMP/nvptx_throw.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device -fcxx-exceptions -fexceptions %s -emit-llvm -S -verify=with -Wopenmp-target-exception
+// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device -fcxx-exceptions -fexceptions %s -emit-llvm -S -verify=without -Wno-openmp-target-exception
+// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device %s -emit-llvm -S -verify=noexceptions
+
+// noexceptions-error@9 {{cannot use 'throw' with exceptions disabled}}
+
+#pragma omp declare target
+void foo(void) {
+	throw 404; // with-warning {{target 'nvptx64' does not support exception handling; 'throw' is assumed to be never reached}}
+}
+#pragma omp end declare target
+// without-no-diagnostics
Index: clang/test/OpenMP/nvptx_exceptions.cpp
===
--- /dev/null
+++ clang/test/OpenMP/nvptx_exceptions.cpp
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device -fcxx-exceptions -fexceptions %s -emit-llvm -S -verify=with -Wopenmp-target-exception
+// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device -fcxx-exceptions -fexceptions %s -emit-llvm -S -verify=without -Wno-openmp-target-exception
+// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fo

[PATCH] D153557: [clang][ExtractAPI] Add support for C++ classes

2023-08-02 Thread Erick Velez via Phabricator via cfe-commits
evelez7 updated this revision to Diff 546635.
evelez7 added a comment.

Reintroduce fix from f4de606ef271 
 and use 
clang frontend for C++ tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153557

Files:
  clang/include/clang/ExtractAPI/API.h
  clang/include/clang/ExtractAPI/DeclarationFragments.h
  clang/include/clang/ExtractAPI/ExtractAPIVisitor.h
  clang/include/clang/ExtractAPI/Serialization/SerializerBase.h
  clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
  clang/lib/ExtractAPI/API.cpp
  clang/lib/ExtractAPI/DeclarationFragments.cpp
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
  clang/test/ExtractAPI/class.cpp
  clang/test/ExtractAPI/constructor_destructor.cpp
  clang/test/ExtractAPI/conversions.cpp
  clang/test/ExtractAPI/function_noexcepts.cpp
  clang/test/ExtractAPI/methods.cpp
  clang/test/ExtractAPI/multiple_inheritance.cpp
  clang/test/ExtractAPI/operator_overload.cpp
  clang/test/ExtractAPI/simple_inheritance.cpp

Index: clang/test/ExtractAPI/simple_inheritance.cpp
===
--- /dev/null
+++ clang/test/ExtractAPI/simple_inheritance.cpp
@@ -0,0 +1,162 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s@INPUT_DIR@%{/t:regex_replacement}@g" \
+// RUN: %t/reference.output.json.in >> %t/reference.output.json
+// RUN: %clang_cc1 -extract-api -triple arm64-apple-macosx \
+// RUN:   -x c++-header %t/input.h -o %t/output.json -verify
+
+// Generator version is not consistent across test runs, normalize it.
+// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
+// RUN: %t/output.json >> %t/output-normalized.json
+// RUN: diff %t/reference.output.json %t/output-normalized.json
+
+//--- input.h
+class Foo {};
+
+class Bar : public Foo {};
+/// expected-no-diagnostics
+
+//--- reference.output.json.in
+{
+  "metadata": {
+"formatVersion": {
+  "major": 0,
+  "minor": 5,
+  "patch": 3
+},
+"generator": "?"
+  },
+  "module": {
+"name": "",
+"platform": {
+  "architecture": "arm64",
+  "operatingSystem": {
+"minimumVersion": {
+  "major": 11,
+  "minor": 0,
+  "patch": 0
+},
+"name": "macosx"
+  },
+  "vendor": "apple"
+}
+  },
+  "relationships": [
+{
+  "kind": "inheritsFrom",
+  "source": "c:@S@Bar",
+  "target": "c:@S@Foo",
+  "targetFallback": "Foo"
+}
+  ],
+  "symbols": [
+{
+  "accessLevel": "public",
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "class"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "Foo"
+},
+{
+  "kind": "text",
+  "spelling": ";"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "c++",
+"precise": "c:@S@Foo"
+  },
+  "kind": {
+"displayName": "Class",
+"identifier": "c++.class"
+  },
+  "location": {
+"position": {
+  "character": 7,
+  "line": 1
+},
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"navigator": [
+  {
+"kind": "identifier",
+"spelling": "Foo"
+  }
+],
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "Foo"
+  }
+],
+"title": "Foo"
+  },
+  "pathComponents": [
+"Foo"
+  ]
+},
+{
+  "accessLevel": "public",
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "class"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "Bar"
+},
+{
+  "kind": "text",
+  "spelling": ";"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "c++",
+"precise": "c:@S@Bar"
+  },
+  "kind": {
+"displayName": "Class",
+"identifier": "c++.class"
+  },
+  "location": {
+"position": {
+  "character": 7,
+  "line": 3
+},
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"navigator": [
+  {
+"kind": "identifier",
+"spelling": "Bar"
+  }
+],
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "Bar"
+  }
+],
+"title": "Bar"
+  },
+  "pathComponents": [
+"Bar"
+  ]
+}
+  ]
+}
Index: clang/test/ExtractAPI/operator_overload.cpp

[PATCH] D156378: [clang][CGExprConstant] handle unary negation on integrals

2023-08-02 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 546634.
nickdesaulniers marked an inline comment as done.
nickdesaulniers added a comment.

- prefer VisitUnaryMinus as per @efriedma


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156378

Files:
  clang/lib/CodeGen/CGExprConstant.cpp


Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1363,6 +1363,13 @@
 return Visit(E->getSubExpr(), T);
   }
 
+  llvm::Constant *VisitUnaryMinus(UnaryOperator *U, QualType T) {
+if (llvm::Constant *C = Visit(U->getSubExpr(), T))
+  if (auto *CI = dyn_cast(C))
+return llvm::ConstantInt::get(CGM.getLLVMContext(), -CI->getValue());
+return nullptr;
+  }
+
   // Utility methods
   llvm::Type *ConvertType(QualType T) {
 return CGM.getTypes().ConvertType(T);


Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1363,6 +1363,13 @@
 return Visit(E->getSubExpr(), T);
   }
 
+  llvm::Constant *VisitUnaryMinus(UnaryOperator *U, QualType T) {
+if (llvm::Constant *C = Visit(U->getSubExpr(), T))
+  if (auto *CI = dyn_cast(C))
+return llvm::ConstantInt::get(CGM.getLLVMContext(), -CI->getValue());
+return nullptr;
+  }
+
   // Utility methods
   llvm::Type *ConvertType(QualType T) {
 return CGM.getTypes().ConvertType(T);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156172: [clang][CodeGen] Emit annotations for function declarations.

2023-08-02 Thread Brendan Dahl via Phabricator via cfe-commits
brendandahl updated this revision to Diff 546632.
brendandahl added a comment.

Switch to emitting annotations and the end.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156172

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/test/CodeGen/annotations-decl-use-define.c
  clang/test/CodeGen/annotations-declaration.c
  clang/test/CodeGen/annotations-global.c
  clang/test/CodeGenCXX/attr-annotate-destructor.cpp

Index: clang/test/CodeGenCXX/attr-annotate-destructor.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/attr-annotate-destructor.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -S -emit-llvm -triple x86_64-unknown-linux-gnu -o - | FileCheck %s
+
+// Test annotation attributes on destructors doesn't crash.
+
+struct k {
+  ~k() __attribute__((annotate(""))) {}
+};
+void m() { k(); }
+
+// CHECK: @llvm.global.annotations = appending global [2 x { ptr, ptr, ptr, i32, ptr }] [{
Index: clang/test/CodeGen/annotations-global.c
===
--- clang/test/CodeGen/annotations-global.c
+++ clang/test/CodeGen/annotations-global.c
@@ -33,15 +33,15 @@
 // CHECK: @llvm.global.annotations = appending global [11 x { ptr, ptr, ptr, i32, ptr }] [{
 // CHECK-SAME: { ptr @a.bar,
 // CHECK-SAME: { ptr @a.bar,
-// CHECK-SAME: { ptr @a,
-// CHECK-SAME: { ptr @a,
-// CHECK-SAME: { ptr @a,
-// CHECK-SAME: { ptr @a,
 // CHECK-SAME: { ptr @sfoo,
 // CHECK-SAME: { ptr @sfoo,
 // CHECK-SAME: { ptr @foo,
 // CHECK-SAME: { ptr @foo,
 // CHECK-SAME: { ptr addrspacecast (ptr addrspace(1) @addrspace1_var to ptr),
+// CHECK-SAME: { ptr @a,
+// CHECK-SAME: { ptr @a,
+// CHECK-SAME: { ptr @a,
+// CHECK-SAME: { ptr @a,
 // CHECK-SAME: }], section "llvm.metadata"
 
 // AS1-GLOBALS: target datalayout = "{{.+}}-A5-G1"
Index: clang/test/CodeGen/annotations-declaration.c
===
--- /dev/null
+++ clang/test/CodeGen/annotations-declaration.c
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+// Test annotation attributes are emitted for declarations.
+
+__attribute__((annotate("bar"))) int foo();
+
+int main() {
+  return foo();
+}
+
+// CHECK: target triple
+// CHECK-DAG: private unnamed_addr constant [4 x i8] c"bar\00", section "llvm.metadata"
+
+// CHECK: @llvm.global.annotations = appending global [1 x { ptr, ptr, ptr, i32, ptr }] [{
+// CHECK-SAME: { ptr @foo,
+// CHECK-SAME: }], section "llvm.metadata"
+
Index: clang/test/CodeGen/annotations-decl-use-define.c
===
--- /dev/null
+++ clang/test/CodeGen/annotations-decl-use-define.c
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
+
+// Test annotation attributes are still emitted when the function is used before
+// it is defined with annotations.
+
+void foo(void);
+void *xxx = (void*)foo;
+void __attribute__((annotate("bar"))) foo() {}
+
+// CHECK: target triple
+// CHECK-DAG: private unnamed_addr constant [4 x i8] c"bar\00", section "llvm.metadata"
+
+// CHECK: @llvm.global.annotations = appending global [1 x { ptr, ptr, ptr, i32, ptr }] [{
+// CHECK-SAME: { ptr @foo,
+// CHECK-SAME: }], section "llvm.metadata"
+
Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -423,6 +423,10 @@
   /// Global annotations.
   std::vector Annotations;
 
+  // Store deferred function annotations so they can be emitted at the end with
+  // most up to date ValueDecl that will have all the inherited annotations.
+  llvm::DenseMap DeferredAnnotations;
+
   /// Map used to get unique annotation strings.
   llvm::StringMap AnnotationStrings;
 
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -689,6 +689,7 @@
 void CodeGenModule::clear() {
   DeferredDeclsToEmit.clear();
   EmittedDeferredDecls.clear();
+  DeferredAnnotations.clear();
   if (OpenMPRuntime)
 OpenMPRuntime->clear();
 }
@@ -3078,6 +3079,10 @@
 }
 
 void CodeGenModule::EmitGlobalAnnotations() {
+  for (const auto& [F, VD] : DeferredAnnotations)
+AddGlobalAnnotations(VD, F);
+  DeferredAnnotations.clear();
+
   if (Annotations.empty())
 return;
 
@@ -4316,6 +4321,11 @@
   }
 }
 
+// Store the declaration associated with this function so it is emitted at
+// the end.
+if (D && D->hasAttr() && isa(Entry))
+  DeferredAnnotations[cast(Entry)] = cast(D);
+
 if ((isa(Entry) || isa(Entry)) &&
 (Entry->getValueType() == Ty)) {
   return Entry;
@@ -4346,6 +4356,11 @@
   llvm::Function::Create(FTy, llvm::Function::ExternalLink

[PATCH] D156482: [clang][CGExprConstant] handle FunctionToPointerDecay

2023-08-02 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/CodeGen/CGExprConstant.cpp:1128
+case CK_NoOp:
+case CK_NonAtomicToAtomic:
   return Visit(subExpr, destType);

I think I'd prefer to continue treating an undecayed function as an "lvalue", 
to keep things straightforward.  To that end, I'd prefer a separate 
"ConstLValueExprEmitter", or something like that, so ConstExprEmitter only 
visits rvalues.

The new emitter should reuse code from ConstLValueExprEmitter where possible.



Comment at: clang/lib/CodeGen/CGExprConstant.cpp:1247
+if (isa(VD))
+  return CGM.getModule().getNamedValue(VD->getName());
+return nullptr;

You 100% can't use `VD->getName()` like this; I'm shocked this isn't causing 
any test failures.  GetAddrOfFunction() resolves names correctly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156482

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


[PATCH] D156466: [clang][CGExprConstant] handle implicit widening/narrowing Int-to-Int casts

2023-08-02 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/CodeGen/CGExprConstant.cpp:1152
+  return CI;
+llvm::APInt A = CI->getValue().sextOrTrunc(DstWidth);
+return llvm::ConstantInt::get(CGM.getLLVMContext(), A);

sextOrTrunc() is, in general, wrong; if FromType is unsigned, you need 
zextOrTrunc.  (This works transparently in HandleIntToIntCast because it's 
using APSInt, which tracks the sign bit of the operand.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156466

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


[PATCH] D156378: [clang][CGExprConstant] handle unary negation on integrals

2023-08-02 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/CodeGen/CGExprConstant.cpp:1366
 
+  llvm::Constant *VisitUnaryOperator(UnaryOperator *U, QualType T) {
+switch (U->getOpcode()) {

StmtVisitor supports defining a function "VisitUnaryMinus", so you don't have 
to switch() over the opcode.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156378

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


[PATCH] D153557: [clang][ExtractAPI] Add support for C++ classes

2023-08-02 Thread Haowei Wu via Phabricator via cfe-commits
haowei added a comment.

FYI, this patch fails the Windows bots in a different way. (you can see the 
error triggered in the pre-merge build in 
https://buildkite.com/llvm-project/premerge-checks/builds/161603#018909c4-fe90-4de6-91a3-d251dc5ada8f)

The error message from our builders are:

  Script:
  --
  : 'RUN: at line 1';   rm -rf 
C:\b\s\w\ir\x\w\llvm_build\tools\clang\test\ExtractAPI\Output\class.cpp.tmp
  : 'RUN: at line 2';   split-file 
C:\b\s\w\ir\x\w\llvm-llvm-project\clang\test\ExtractAPI\class.cpp 
C:\b\s\w\ir\x\w\llvm_build\tools\clang\test\ExtractAPI\Output\class.cpp.tmp
  : 'RUN: at line 3';   sed -e 
"s@INPUT_DIR@C:/b/s/w/ir/x/w/llvm_build/tools/clang/test/ExtractAPI/Output/class.cpp.tmp@g"
  
C:\b\s\w\ir\x\w\llvm_build\tools\clang\test\ExtractAPI\Output\class.cpp.tmp/reference.output.json.in
 >> 
C:\b\s\w\ir\x\w\llvm_build\tools\clang\test\ExtractAPI\Output\class.cpp.tmp/reference.output.json
  : 'RUN: at line 5';   c:\b\s\w\ir\x\w\llvm_build\bin\clang.exe++ -extract-api 
-target arm64-apple-macosx -x c++-header  
C:\b\s\w\ir\x\w\llvm_build\tools\clang\test\ExtractAPI\Output\class.cpp.tmp/input.h
 -o 
C:\b\s\w\ir\x\w\llvm_build\tools\clang\test\ExtractAPI\Output\class.cpp.tmp/output.json
 -Xclang -verify
  : 'RUN: at line 9';   sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" 
 
C:\b\s\w\ir\x\w\llvm_build\tools\clang\test\ExtractAPI\Output\class.cpp.tmp/output.json
 >> 
C:\b\s\w\ir\x\w\llvm_build\tools\clang\test\ExtractAPI\Output\class.cpp.tmp/output-normalized.json
  : 'RUN: at line 11';   diff 
C:\b\s\w\ir\x\w\llvm_build\tools\clang\test\ExtractAPI\Output\class.cpp.tmp/reference.output.json
 
C:\b\s\w\ir\x\w\llvm_build\tools\clang\test\ExtractAPI\Output\class.cpp.tmp/output-normalized.json
  --
  Exit Code: 127
  
  Command Output (stdout):
  --
  $ ":" "RUN: at line 1"
  $ "rm" "-rf" 
"C:\b\s\w\ir\x\w\llvm_build\tools\clang\test\ExtractAPI\Output\class.cpp.tmp"
  $ ":" "RUN: at line 2"
  $ "split-file" 
"C:\b\s\w\ir\x\w\llvm-llvm-project\clang\test\ExtractAPI\class.cpp" 
"C:\b\s\w\ir\x\w\llvm_build\tools\clang\test\ExtractAPI\Output\class.cpp.tmp"
  $ ":" "RUN: at line 3"
  $ "sed" "-e" 
"s@INPUT_DIR@C:/b/s/w/ir/x/w/llvm_build/tools/clang/test/ExtractAPI/Output/class.cpp.tmp@g"
 
"C:\b\s\w\ir\x\w\llvm_build\tools\clang\test\ExtractAPI\Output\class.cpp.tmp/reference.output.json.in"
  $ ":" "RUN: at line 5"
  $ "c:\b\s\w\ir\x\w\llvm_build\bin\clang.exe++" "-extract-api" "-target" 
"arm64-apple-macosx" "-x" "c++-header" 
"C:\b\s\w\ir\x\w\llvm_build\tools\clang\test\ExtractAPI\Output\class.cpp.tmp/input.h"
 "-o" 
"C:\b\s\w\ir\x\w\llvm_build\tools\clang\test\ExtractAPI\Output\class.cpp.tmp/output.json"
 "-Xclang" "-verify"
  # command stderr:
  'c:\\b\\s\\w\\ir\\x\\w\\llvm_build\\bin\\clang.exe++': command not found
  error: command failed with exit status: 127
  
  --

Link to the failed task: 
https://ci.chromium.org/ui/p/fuchsia/builders/toolchain.ci/clang-windows-x64/b8773853314698659521/overview

`%clang++` is probably not the correct way to invoke clang++ as it was replaced 
as `clang.exe++` on Windows


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153557

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


[PATCH] D153557: [clang][ExtractAPI] Add support for C++ classes

2023-08-02 Thread Erick Velez via Phabricator via cfe-commits
evelez7 added a comment.

@haowei Thank you for letting me know! That patch does seem to fix it, 
unfortunately it didn't fail on my end. Thanks again.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153557

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


[PATCH] D76096: [clang] allow const structs/unions/arrays to be constant expressions for C

2023-08-02 Thread Nick Desaulniers via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG610ec954e1f8: [clang] allow const structs/unions/arrays to 
be constant expressions for C (authored by nickdesaulniers).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76096

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/AST/ExprConstant.cpp
  clang/test/CodeGen/builtin-constant-p.c
  clang/test/CodeGen/const-init.c
  clang/test/Sema/builtins.c
  clang/test/Sema/init.c

Index: clang/test/Sema/init.c
===
--- clang/test/Sema/init.c
+++ clang/test/Sema/init.c
@@ -164,3 +164,46 @@
 
 typedef struct { uintptr_t x : 2; } StructWithBitfield;
 StructWithBitfield bitfieldvar = { (uintptr_t)&bitfieldvar }; // expected-error {{initializer element is not a compile-time constant}}
+
+// PR45157
+struct PR4517_foo {
+  int x;
+};
+struct PR4517_bar {
+  struct PR4517_foo foo;
+};
+const struct PR4517_foo my_foo = {.x = 42};
+struct PR4517_bar my_bar = {
+.foo = my_foo, // no-warning
+};
+struct PR4517_bar my_bar2 = (struct PR4517_bar){
+.foo = my_foo, // no-warning
+};
+struct PR4517_bar my_bar3 = {
+my_foo, // no-warning
+};
+struct PR4517_bar my_bar4 = (struct PR4517_bar){
+my_foo // no-warning
+};
+extern const struct PR4517_foo my_foo2;
+struct PR4517_bar my_bar5 = {
+  .foo = my_foo2, // expected-error {{initializer element is not a compile-time constant}}
+};
+const struct PR4517_foo my_foo3 = {.x = my_foo.x};
+int PR4517_a[2] = {0, 1};
+const int PR4517_ca[2] = {0, 1};
+int PR4517_idx = 0;
+const int PR4517_idxc = 1;
+int PR4517_x1 = PR4517_a[PR4517_idx]; // expected-error {{initializer element is not a compile-time constant}}
+int PR4517_x2 = PR4517_a[PR4517_idxc]; // expected-error {{initializer element is not a compile-time constant}}
+int PR4517_x3 = PR4517_a[0]; // expected-error {{initializer element is not a compile-time constant}}
+int PR4517_y1 = PR4517_ca[PR4517_idx]; // expected-error {{initializer element is not a compile-time constant}}
+int PR4517_y2 = PR4517_ca[PR4517_idxc]; // no-warning
+int PR4517_y3 = PR4517_ca[0]; // no-warning
+union PR4517_u {
+int x;
+float y;
+};
+const union PR4517_u u1 = {4.0f};
+const union PR4517_u u2 = u1; // no-warning
+const union PR4517_u u3 = {u1.y}; // expected-error {{initializer element is not a compile-time constant}}
Index: clang/test/Sema/builtins.c
===
--- clang/test/Sema/builtins.c
+++ clang/test/Sema/builtins.c
@@ -131,7 +131,7 @@
 
 const int test17_n = 0;
 const char test17_c[] = {1, 2, 3, 0};
-const char test17_d[] = {1, 2, 3, 4};
+const char test17_d[] = {1, 2, 3, 4}; // Like test17_c but not NUL-terminated.
 typedef int __attribute__((vector_size(16))) IntVector;
 struct Aggregate { int n; char c; };
 enum Enum { EnumValue1, EnumValue2 };
@@ -178,9 +178,10 @@
   ASSERT(!OPT("abcd"));
   // In these cases, the strlen is non-constant, but the __builtin_constant_p
   // is 0: the array size is not an ICE but is foldable.
-  ASSERT(!OPT(test17_c));// expected-warning {{folding}}
-  ASSERT(!OPT(&test17_c[0]));// expected-warning {{folding}}
-  ASSERT(!OPT((char*)test17_c)); // expected-warning {{folding}}
+  ASSERT(!OPT(test17_c));
+  ASSERT(!OPT(&test17_c[0]));
+  ASSERT(!OPT((char*)test17_c));
+  // NOTE: test17_d is not NUL-termintated, so calling strlen on it is UB.
   ASSERT(!OPT(test17_d));// expected-warning {{folding}}
   ASSERT(!OPT(&test17_d[0]));// expected-warning {{folding}}
   ASSERT(!OPT((char*)test17_d)); // expected-warning {{folding}}
Index: clang/test/CodeGen/const-init.c
===
--- clang/test/CodeGen/const-init.c
+++ clang/test/CodeGen/const-init.c
@@ -190,3 +190,28 @@
 struct { const float *floats; } compoundliteral = {
   (float[1]) { 0.1, },
 };
+
+struct PR4517_foo {
+  int x;
+};
+struct PR4517_bar {
+  struct PR4517_foo foo;
+};
+const struct PR4517_foo my_foo = {.x = 42};
+struct PR4517_bar my_bar = {.foo = my_foo};
+struct PR4517_bar my_bar2 = (struct PR4517_bar){.foo = my_foo};
+struct PR4517_bar my_bar3 = {my_foo};
+struct PR4517_bar my_bar4 = (struct PR4517_bar){my_foo};
+// CHECK: @my_foo = constant %struct.PR4517_foo { i32 42 }, align 4
+// CHECK: @my_bar = global %struct.PR4517_bar { %struct.PR4517_foo { i32 42 } }, align 4
+// CHECK: @my_bar2 = global %struct.PR4517_bar { %struct.PR4517_foo { i32 42 } }, align 4
+// CHECK: @my_bar3 = global %struct.PR4517_bar { %struct.PR4517_foo { i32 42 } }, align 4
+// CHECK: @my_bar4 = global %struct.PR4517_bar { %struct.PR4517_foo { i32 42 } }, align 4
+const int PR4517_arrc[2] = {41, 42};
+int PR4517_x = PR4517_arrc[1];
+const int PR4517_idx = 1;
+int PR4517_x2 = PR4517_arrc[PR4517_idx];
+// CHECK: @PR4517_arrc = con

[clang] 610ec95 - [clang] allow const structs/unions/arrays to be constant expressions for C

2023-08-02 Thread Nick Desaulniers via cfe-commits

Author: Nick Desaulniers
Date: 2023-08-02T15:32:37-07:00
New Revision: 610ec954e1f81c0e8fcadedcd25afe643f5a094e

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

LOG: [clang] allow const structs/unions/arrays to be constant expressions for C

For code like:
struct foo { ... };
struct bar { struct foo foo; };
const struct foo my_foo = { ... };
struct bar my_bar = { .foo = my_foo };

Eli Friedman points out the relevant part of the C standard seems to
have some flexibility in what is considered a constant expression:

6.6 paragraph 10:
An implementation may accept other forms of constant expressions.

GCC 8 added support for these, so clang not supporting them has been a
constant thorn in the side of source code portability within the Linux
kernel.

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

Reviewed By: efriedma

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/AST/ExprConstant.cpp
clang/test/CodeGen/builtin-constant-p.c
clang/test/CodeGen/const-init.c
clang/test/Sema/builtins.c
clang/test/Sema/init.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 381346f9605b4a..3af39b4f409199 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -71,6 +71,9 @@ Resolutions to C++ Defect Reports
 
 C Language Changes
 --
+- ``structs``, ``unions``, and ``arrays`` that are const may now be used as
+  constant expressions.  This change is more consistent with the behavior of
+  GCC.
 
 C2x Feature Support
 ^^^

diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index c688467a2fef74..361e8efe4cdf33 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -15261,14 +15261,6 @@ static bool FastEvaluateAsRValue(const Expr *Exp, 
Expr::EvalResult &Result,
 return true;
   }
 
-  // FIXME: Evaluating values of large array and record types can cause
-  // performance problems. Only do so in C++11 for now.
-  if (Exp->isPRValue() &&
-  (Exp->getType()->isArrayType() || Exp->getType()->isRecordType()) &&
-  !Ctx.getLangOpts().CPlusPlus11) {
-IsConst = false;
-return true;
-  }
   return false;
 }
 
@@ -15510,12 +15502,6 @@ bool Expr::EvaluateAsInitializer(APValue &Value, const 
ASTContext &Ctx,
 return Name;
   });
 
-  // FIXME: Evaluating initializers for large array and record types can cause
-  // performance problems. Only do so in C++11 for now.
-  if (isPRValue() && (getType()->isArrayType() || getType()->isRecordType()) &&
-  !Ctx.getLangOpts().CPlusPlus11)
-return false;
-
   Expr::EvalStatus EStatus;
   EStatus.Diag = &Notes;
 

diff  --git a/clang/test/CodeGen/builtin-constant-p.c 
b/clang/test/CodeGen/builtin-constant-p.c
index 2c15a9b07fb379..8e35cb2b2ef836 100644
--- a/clang/test/CodeGen/builtin-constant-p.c
+++ b/clang/test/CodeGen/builtin-constant-p.c
@@ -76,7 +76,7 @@ int test6(void) {
 
 int test7(void) {
   // CHECK-LABEL: test7
-  // CHECK: call i1 @llvm.is.constant.i32
+  // CHECK: ret i32 1
   return __builtin_constant_p(c_arr[2]);
 }
 

diff  --git a/clang/test/CodeGen/const-init.c b/clang/test/CodeGen/const-init.c
index 7f6035a2178a80..7062393c450226 100644
--- a/clang/test/CodeGen/const-init.c
+++ b/clang/test/CodeGen/const-init.c
@@ -190,3 +190,28 @@ void g31(void) {
 struct { const float *floats; } compoundliteral = {
   (float[1]) { 0.1, },
 };
+
+struct PR4517_foo {
+  int x;
+};
+struct PR4517_bar {
+  struct PR4517_foo foo;
+};
+const struct PR4517_foo my_foo = {.x = 42};
+struct PR4517_bar my_bar = {.foo = my_foo};
+struct PR4517_bar my_bar2 = (struct PR4517_bar){.foo = my_foo};
+struct PR4517_bar my_bar3 = {my_foo};
+struct PR4517_bar my_bar4 = (struct PR4517_bar){my_foo};
+// CHECK: @my_foo = constant %struct.PR4517_foo { i32 42 }, align 4
+// CHECK: @my_bar = global %struct.PR4517_bar { %struct.PR4517_foo { i32 42 } 
}, align 4
+// CHECK: @my_bar2 = global %struct.PR4517_bar { %struct.PR4517_foo { i32 42 } 
}, align 4
+// CHECK: @my_bar3 = global %struct.PR4517_bar { %struct.PR4517_foo { i32 42 } 
}, align 4
+// CHECK: @my_bar4 = global %struct.PR4517_bar { %struct.PR4517_foo { i32 42 } 
}, align 4
+const int PR4517_arrc[2] = {41, 42};
+int PR4517_x = PR4517_arrc[1];
+const int PR4517_idx = 1;
+int PR4517_x2 = PR4517_arrc[PR4517_idx];
+// CHECK: @PR4517_arrc = constant [2 x i32] [i32 41, i32 42], align 4
+// CHECK: @PR4517_x = global i32 42, align 4
+// CHECK: @PR4517_idx = constant i32 1, align 4
+// CHECK: @PR4517_x2 = global i32 42, align 4

diff  --git a/clang/test/Sema/builtins.c b/clang/test/Sema/builtins.c
index 13b6df18f62800..0e112977bf58f9 100644
--- a/clang/test/Sema/builtins.c

[PATCH] D156936: [Clang] Increase default architecture from sm_35 to sm_52

2023-08-02 Thread Joseph Huber via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGab202aa7004a: [Clang] Increase default architecture from  
sm_35 to sm_52 (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156936

Files:
  clang/include/clang/Basic/Cuda.h
  clang/test/Driver/cuda-cross-compiling.c


Index: clang/test/Driver/cuda-cross-compiling.c
===
--- clang/test/Driver/cuda-cross-compiling.c
+++ clang/test/Driver/cuda-cross-compiling.c
@@ -65,9 +65,9 @@
 // RUN: %clang --target=nvptx64-nvidia-cuda -### 
--cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=DEFAULT %s
 
-//  DEFAULT: -cc1" "-triple" "nvptx64-nvidia-cuda" "-S" {{.*}} 
"-target-cpu" "sm_35" "-target-feature" "+ptx{{[0-9]+}}" {{.*}} "-o" 
"[[PTX:.+]].s"
-// DEFAULT-NEXT: ptxas{{.*}}"-m64" "-O0" "--gpu-name" "sm_35" "--output-file" 
"[[CUBIN:.+]].cubin" "[[PTX]].s" "-c"
-// DEFAULT-NEXT: nvlink{{.*}}"-o" "a.out" "-arch" "sm_35" {{.*}} 
"[[CUBIN]].cubin"
+//  DEFAULT: -cc1" "-triple" "nvptx64-nvidia-cuda" "-S" {{.*}} 
"-target-cpu" "sm_52" "-target-feature" "+ptx{{[0-9]+}}" {{.*}} "-o" 
"[[PTX:.+]].s"
+// DEFAULT-NEXT: ptxas{{.*}}"-m64" "-O0" "--gpu-name" "sm_52" "--output-file" 
"[[CUBIN:.+]].cubin" "[[PTX]].s" "-c"
+// DEFAULT-NEXT: nvlink{{.*}}"-o" "a.out" "-arch" "sm_52" {{.*}} 
"[[CUBIN]].cubin"
 
 //
 // Test to ensure that we enable handling global constructors in a freestanding
Index: clang/include/clang/Basic/Cuda.h
===
--- clang/include/clang/Basic/Cuda.h
+++ clang/include/clang/Basic/Cuda.h
@@ -117,7 +117,7 @@
// public one.
   LAST,
 
-  CudaDefault = CudaArch::SM_35,
+  CudaDefault = CudaArch::SM_52,
   HIPDefault = CudaArch::GFX803,
 };
 


Index: clang/test/Driver/cuda-cross-compiling.c
===
--- clang/test/Driver/cuda-cross-compiling.c
+++ clang/test/Driver/cuda-cross-compiling.c
@@ -65,9 +65,9 @@
 // RUN: %clang --target=nvptx64-nvidia-cuda -### --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=DEFAULT %s
 
-//  DEFAULT: -cc1" "-triple" "nvptx64-nvidia-cuda" "-S" {{.*}} "-target-cpu" "sm_35" "-target-feature" "+ptx{{[0-9]+}}" {{.*}} "-o" "[[PTX:.+]].s"
-// DEFAULT-NEXT: ptxas{{.*}}"-m64" "-O0" "--gpu-name" "sm_35" "--output-file" "[[CUBIN:.+]].cubin" "[[PTX]].s" "-c"
-// DEFAULT-NEXT: nvlink{{.*}}"-o" "a.out" "-arch" "sm_35" {{.*}} "[[CUBIN]].cubin"
+//  DEFAULT: -cc1" "-triple" "nvptx64-nvidia-cuda" "-S" {{.*}} "-target-cpu" "sm_52" "-target-feature" "+ptx{{[0-9]+}}" {{.*}} "-o" "[[PTX:.+]].s"
+// DEFAULT-NEXT: ptxas{{.*}}"-m64" "-O0" "--gpu-name" "sm_52" "--output-file" "[[CUBIN:.+]].cubin" "[[PTX]].s" "-c"
+// DEFAULT-NEXT: nvlink{{.*}}"-o" "a.out" "-arch" "sm_52" {{.*}} "[[CUBIN]].cubin"
 
 //
 // Test to ensure that we enable handling global constructors in a freestanding
Index: clang/include/clang/Basic/Cuda.h
===
--- clang/include/clang/Basic/Cuda.h
+++ clang/include/clang/Basic/Cuda.h
@@ -117,7 +117,7 @@
// public one.
   LAST,
 
-  CudaDefault = CudaArch::SM_35,
+  CudaDefault = CudaArch::SM_52,
   HIPDefault = CudaArch::GFX803,
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] ab202aa - [Clang] Increase default architecture from sm_35 to sm_52

2023-08-02 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2023-08-02T17:30:23-05:00
New Revision: ab202aa7004a451ee9f496505256cfcb94d71747

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

LOG: [Clang] Increase default architecture from  sm_35 to sm_52

We previously defaulted to `sm_35` for the purpose of unspecified
architecture. This was removed in new CUDA versions so we should bump
this up.

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/include/clang/Basic/Cuda.h
clang/test/Driver/cuda-cross-compiling.c

Removed: 




diff  --git a/clang/include/clang/Basic/Cuda.h 
b/clang/include/clang/Basic/Cuda.h
index 7f65d711bb3210..878f8d70f90c0a 100644
--- a/clang/include/clang/Basic/Cuda.h
+++ b/clang/include/clang/Basic/Cuda.h
@@ -117,7 +117,7 @@ enum class CudaArch {
// public one.
   LAST,
 
-  CudaDefault = CudaArch::SM_35,
+  CudaDefault = CudaArch::SM_52,
   HIPDefault = CudaArch::GFX803,
 };
 

diff  --git a/clang/test/Driver/cuda-cross-compiling.c 
b/clang/test/Driver/cuda-cross-compiling.c
index a94e5801382d8f..12d0af3b45f32f 100644
--- a/clang/test/Driver/cuda-cross-compiling.c
+++ b/clang/test/Driver/cuda-cross-compiling.c
@@ -65,9 +65,9 @@
 // RUN: %clang --target=nvptx64-nvidia-cuda -### 
--cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=DEFAULT %s
 
-//  DEFAULT: -cc1" "-triple" "nvptx64-nvidia-cuda" "-S" {{.*}} 
"-target-cpu" "sm_35" "-target-feature" "+ptx{{[0-9]+}}" {{.*}} "-o" 
"[[PTX:.+]].s"
-// DEFAULT-NEXT: ptxas{{.*}}"-m64" "-O0" "--gpu-name" "sm_35" "--output-file" 
"[[CUBIN:.+]].cubin" "[[PTX]].s" "-c"
-// DEFAULT-NEXT: nvlink{{.*}}"-o" "a.out" "-arch" "sm_35" {{.*}} 
"[[CUBIN]].cubin"
+//  DEFAULT: -cc1" "-triple" "nvptx64-nvidia-cuda" "-S" {{.*}} 
"-target-cpu" "sm_52" "-target-feature" "+ptx{{[0-9]+}}" {{.*}} "-o" 
"[[PTX:.+]].s"
+// DEFAULT-NEXT: ptxas{{.*}}"-m64" "-O0" "--gpu-name" "sm_52" "--output-file" 
"[[CUBIN:.+]].cubin" "[[PTX]].s" "-c"
+// DEFAULT-NEXT: nvlink{{.*}}"-o" "a.out" "-arch" "sm_52" {{.*}} 
"[[CUBIN]].cubin"
 
 //
 // Test to ensure that we enable handling global constructors in a freestanding



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


[PATCH] D147283: [Sema] Search template parameter scopes before searching namespace/file scopes when performing unqualified name lookup

2023-08-02 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147283

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


[PATCH] D156901: [OpenMP] Change OpenMP default version in documentation and help text for -fopenmp-version

2023-08-02 Thread Valentin Clement via Phabricator via cfe-commits
clementval added inline comments.



Comment at: flang/test/Driver/driver-help.f90:55
 ! HELP-NEXT: -fopenmp-version=
-! HELP-NEXT:Set OpenMP version (e.g. 45 for OpenMP 
4.5, 50 for OpenMP 5.0). Default value is 50 for Clang and 11 for Flang
+! HELP-NEXT:Set OpenMP version (e.g. 45 for OpenMP 
4.5, 51 for OpenMP 5.1). Default value is 51 for Clang and 11 for Flang
 ! HELP-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel 
code.

jdoerfert wrote:
> tianshilei1992 wrote:
> > clementval wrote:
> > > AntonRydahl wrote:
> > > > tianshilei1992 wrote:
> > > > > Does Flang also switch to 5.1 by default?
> > > > As far as I know, `flang` is still OpenMP 1.1 by default but still 
> > > > depends on the same command line options as `clang`. 
> > > `flang` does not differentiate between versions. 
> > I see.
> I would remove the flang part of the wording for now.
+1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156901

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


[PATCH] D156901: [OpenMP] Change OpenMP default version in documentation and help text for -fopenmp-version

2023-08-02 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: flang/test/Driver/driver-help.f90:55
 ! HELP-NEXT: -fopenmp-version=
-! HELP-NEXT:Set OpenMP version (e.g. 45 for OpenMP 
4.5, 50 for OpenMP 5.0). Default value is 50 for Clang and 11 for Flang
+! HELP-NEXT:Set OpenMP version (e.g. 45 for OpenMP 
4.5, 51 for OpenMP 5.1). Default value is 51 for Clang and 11 for Flang
 ! HELP-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel 
code.

tianshilei1992 wrote:
> clementval wrote:
> > AntonRydahl wrote:
> > > tianshilei1992 wrote:
> > > > Does Flang also switch to 5.1 by default?
> > > As far as I know, `flang` is still OpenMP 1.1 by default but still 
> > > depends on the same command line options as `clang`. 
> > `flang` does not differentiate between versions. 
> I see.
I would remove the flang part of the wording for now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156901

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


[PATCH] D156933: [HLSL] Add reversebits library function

2023-08-02 Thread Joshua Batista via Phabricator via cfe-commits
bob80905 updated this revision to Diff 546618.
bob80905 added a comment.

- remove fnative half type from run line


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156933

Files:
  clang/lib/Headers/hlsl/hlsl_intrinsics.h
  clang/test/CodeGenHLSL/builtins/bitreverse.hlsl
  clang/test/CodeGenHLSL/builtins/reversebits.hlsl

Index: clang/test/CodeGenHLSL/builtins/reversebits.hlsl
===
--- /dev/null
+++ clang/test/CodeGenHLSL/builtins/reversebits.hlsl
@@ -0,0 +1,155 @@
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -fnative-half-type \
+// RUN:   -D__HLSL_ENABLE_16_BIT -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s
+
+#ifdef __HLSL_ENABLE_16_BIT
+// CHECK: define noundef i16 @
+// CHECK: call i16 @llvm.bitreverse.i16(
+int16_t test_bitreverse_short(int16_t p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <2 x i16> @
+// CHECK: call <2 x i16> @llvm.bitreverse.v2i16(
+int16_t2 test_bitreverse_short2(int16_t2 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <3 x i16> @
+// CHECK: call <3 x i16> @llvm.bitreverse.v3i16
+int16_t3 test_bitreverse_short3(int16_t3 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <4 x i16> @
+// CHECK: call <4 x i16> @llvm.bitreverse.v4i16
+int16_t4 test_bitreverse_short4(int16_t4 p0)
+{
+	return reversebits(p0);
+}
+
+// CHECK: define noundef i16 @
+// CHECK: call i16 @llvm.bitreverse.i16(
+uint16_t test_bitreverse_ushort(uint16_t p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <2 x i16> @
+// CHECK: call <2 x i16> @llvm.bitreverse.v2i16
+uint16_t2 test_bitreverse_ushort2(uint16_t2 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <3 x i16> @
+// CHECK: call <3 x i16> @llvm.bitreverse.v3i16
+uint16_t3 test_bitreverse_ushort3(uint16_t3 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <4 x i16> @
+// CHECK: call <4 x i16> @llvm.bitreverse.v4i16
+uint16_t4 test_bitreverse_ushort4(uint16_t4 p0)
+{
+	return reversebits(p0);
+}
+#endif
+
+// CHECK: define noundef i32 @
+// CHECK: call i32 @llvm.bitreverse.i32(
+int test_bitreverse_int(int p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <2 x i32> @
+// CHECK: call <2 x i32> @llvm.bitreverse.v2i32
+int2 test_bitreverse_int2(int2 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <3 x i32> @
+// CHECK: call <3 x i32> @llvm.bitreverse.v3i32
+int3 test_bitreverse_int3(int3 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <4 x i32> @
+// CHECK: call <4 x i32> @llvm.bitreverse.v4i32
+int4 test_bitreverse_int4(int4 p0)
+{
+	return reversebits(p0);
+}
+
+// CHECK: define noundef i32 @
+// CHECK: call i32 @llvm.bitreverse.i32(
+int test_bitreverse_uint(uint p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <2 x i32> @
+// CHECK: call <2 x i32> @llvm.bitreverse.v2i32
+uint2 test_bitreverse_uint2(uint2 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <3 x i32> @
+// CHECK: call <3 x i32> @llvm.bitreverse.v3i32
+uint3 test_bitreverse_uint3(uint3 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <4 x i32> @
+// CHECK: call <4 x i32> @llvm.bitreverse.v4i32
+uint4 test_bitreverse_uint4(uint4 p0)
+{
+	return reversebits(p0);
+}
+
+// CHECK: define noundef i64 @
+// CHECK: call i64 @llvm.bitreverse.i64(
+int64_t test_bitreverse_long(int64_t p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <2 x i64> @
+// CHECK: call <2 x i64> @llvm.bitreverse.v2i64
+int64_t2 test_bitreverse_long2(int64_t2 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <3 x i64> @
+// CHECK: call <3 x i64> @llvm.bitreverse.v3i64
+int64_t3 test_bitreverse_long3(int64_t3 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <4 x i64> @
+// CHECK: call <4 x i64> @llvm.bitreverse.v4i64
+int64_t4 test_bitreverse_long4(int64_t4 p0)
+{
+	return reversebits(p0);
+}
+
+// CHECK: define noundef i64 @
+// CHECK: call i64 @llvm.bitreverse.i64(
+uint64_t test_bitreverse_long(uint64_t p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <2 x i64> @
+// CHECK: call <2 x i64> @llvm.bitreverse.v2i64
+uint64_t2 test_bitreverse_long2(uint64_t2 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <3 x i64> @
+// CHECK: call <3 x i64> @llvm.bitreverse.v3i64
+uint64_t3 test_bitreverse_long3(uint64_t3 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <4 x i64> @
+// CHECK: call <4 x i64> @llvm.bitreverse.v4i64
+uint64_t4 test_bitreverse_long4(uint64_t4 p0)
+{
+	return reversebits(p0);
+}
Index: clang/test/CodeGenHLSL/builtins/bitreverse.hlsl
===
--- /dev/null
+++ clang/test/CodeGenHLSL/builtins/bitreverse.hlsl
@@ -0,0 +1,155 @@
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN

[PATCH] D156925: [Driver] Don't try to spell check unsupported options

2023-08-02 Thread Justin Bogner via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7ef1718c4d4e: [Driver] Don't try to spell check 
unsupported options (authored by bogner).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156925

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/unsupported-option.c
  flang/test/Driver/driver-version.f90


Index: flang/test/Driver/driver-version.f90
===
--- flang/test/Driver/driver-version.f90
+++ flang/test/Driver/driver-version.f90
@@ -9,7 +9,7 @@
 ! VERSION-NEXT: Thread model:
 ! VERSION-NEXT: InstalledDir:
 
-! ERROR: flang-new: error: unsupported option '--versions'; did you mean 
'--version'?
+! ERROR: flang-new: error: unknown argument '--versions'; did you mean 
'--version'?
 
 ! VERSION-FC1: LLVM version
 
Index: clang/test/Driver/unsupported-option.c
===
--- clang/test/Driver/unsupported-option.c
+++ clang/test/Driver/unsupported-option.c
@@ -1,10 +1,10 @@
 // RUN: not %clang %s --hedonism -### 2>&1 | \
 // RUN: FileCheck %s
-// CHECK: error: unsupported option '--hedonism'
+// CHECK: error: unknown argument: '--hedonism'
 
 // RUN: not %clang %s --hell -### 2>&1 | \
 // RUN: FileCheck %s --check-prefix=DID-YOU-MEAN
-// DID-YOU-MEAN: error: unsupported option '--hell'; did you mean '--help'?
+// DID-YOU-MEAN: error: unknown argument '--hell'; did you mean '--help'?
 
 // RUN: not %clang --target=powerpc-ibm-aix %s -mlong-double-128 2>&1 | \
 // RUN: FileCheck %s --check-prefix=AIX-LONGDOUBLE128-ERR
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -286,19 +286,9 @@
   // Check for unsupported options.
   for (const Arg *A : Args) {
 if (A->getOption().hasFlag(options::Unsupported)) {
-  unsigned DiagID;
-  auto ArgString = A->getAsString(Args);
-  std::string Nearest;
-  if (getOpts().findNearest(
-ArgString, Nearest, IncludedFlagsBitmask,
-ExcludedFlagsBitmask | options::Unsupported) > 1) {
-DiagID = diag::err_drv_unsupported_opt;
-Diag(DiagID) << ArgString;
-  } else {
-DiagID = diag::err_drv_unsupported_opt_with_suggestion;
-Diag(DiagID) << ArgString << Nearest;
-  }
-  ContainsError |= Diags.getDiagnosticLevel(DiagID, SourceLocation()) >
+  Diag(diag::err_drv_unsupported_opt) << A->getAsString(Args);
+  ContainsError |= Diags.getDiagnosticLevel(diag::err_drv_unsupported_opt,
+SourceLocation()) >
DiagnosticsEngine::Warning;
   continue;
 }
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4773,7 +4773,6 @@
 def _warn_ : Joined<["--"], "warn-">, Alias;
 def _write_dependencies : Flag<["--"], "write-dependencies">, Alias;
 def _write_user_dependencies : Flag<["--"], "write-user-dependencies">, 
Alias;
-def _ : Joined<["--"], "">, Flags<[Unsupported]>;
 
 // Hexagon feature flags.
 let Flags = [TargetSpecific] in {


Index: flang/test/Driver/driver-version.f90
===
--- flang/test/Driver/driver-version.f90
+++ flang/test/Driver/driver-version.f90
@@ -9,7 +9,7 @@
 ! VERSION-NEXT: Thread model:
 ! VERSION-NEXT: InstalledDir:
 
-! ERROR: flang-new: error: unsupported option '--versions'; did you mean '--version'?
+! ERROR: flang-new: error: unknown argument '--versions'; did you mean '--version'?
 
 ! VERSION-FC1: LLVM version
 
Index: clang/test/Driver/unsupported-option.c
===
--- clang/test/Driver/unsupported-option.c
+++ clang/test/Driver/unsupported-option.c
@@ -1,10 +1,10 @@
 // RUN: not %clang %s --hedonism -### 2>&1 | \
 // RUN: FileCheck %s
-// CHECK: error: unsupported option '--hedonism'
+// CHECK: error: unknown argument: '--hedonism'
 
 // RUN: not %clang %s --hell -### 2>&1 | \
 // RUN: FileCheck %s --check-prefix=DID-YOU-MEAN
-// DID-YOU-MEAN: error: unsupported option '--hell'; did you mean '--help'?
+// DID-YOU-MEAN: error: unknown argument '--hell'; did you mean '--help'?
 
 // RUN: not %clang --target=powerpc-ibm-aix %s -mlong-double-128 2>&1 | \
 // RUN: FileCheck %s --check-prefix=AIX-LONGDOUBLE128-ERR
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -286,19 +286,9 @@
   // Check for unsupported options.
   for (const Arg *A : Args) {
 if (A-

[clang] 7ef1718 - [Driver] Don't try to spell check unsupported options

2023-08-02 Thread Justin Bogner via cfe-commits

Author: Justin Bogner
Date: 2023-08-02T14:23:14-07:00
New Revision: 7ef1718c4d4ecd99f3ba48236f7fd4fd9ffb540c

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

LOG: [Driver] Don't try to spell check unsupported options

We currently spell check options that are listed as unsupported, but
this doesn't make much sense. If an option is explicitly unsupported
why would one that's spelled similarly be useful?

It looks like the reason this was added was that we explicitly mark
all `--something` flags as Unsupported rather than just leaving them
undefined and treating them as unknown. Drop that handling so that we
don't regress on things like misspelling `--help`.

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/Driver.cpp
clang/test/Driver/unsupported-option.c
flang/test/Driver/driver-version.f90

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 7d719234192a93..9e25a5e0b58a58 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4773,7 +4773,6 @@ def _warn__EQ : Joined<["--"], "warn-=">, Alias;
 def _warn_ : Joined<["--"], "warn-">, Alias;
 def _write_dependencies : Flag<["--"], "write-dependencies">, Alias;
 def _write_user_dependencies : Flag<["--"], "write-user-dependencies">, 
Alias;
-def _ : Joined<["--"], "">, Flags<[Unsupported]>;
 
 // Hexagon feature flags.
 let Flags = [TargetSpecific] in {

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index a43d3f07bc1d31..b34003041373f5 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -286,19 +286,9 @@ InputArgList Driver::ParseArgStrings(ArrayRef ArgStrings,
   // Check for unsupported options.
   for (const Arg *A : Args) {
 if (A->getOption().hasFlag(options::Unsupported)) {
-  unsigned DiagID;
-  auto ArgString = A->getAsString(Args);
-  std::string Nearest;
-  if (getOpts().findNearest(
-ArgString, Nearest, IncludedFlagsBitmask,
-ExcludedFlagsBitmask | options::Unsupported) > 1) {
-DiagID = diag::err_drv_unsupported_opt;
-Diag(DiagID) << ArgString;
-  } else {
-DiagID = diag::err_drv_unsupported_opt_with_suggestion;
-Diag(DiagID) << ArgString << Nearest;
-  }
-  ContainsError |= Diags.getDiagnosticLevel(DiagID, SourceLocation()) >
+  Diag(diag::err_drv_unsupported_opt) << A->getAsString(Args);
+  ContainsError |= Diags.getDiagnosticLevel(diag::err_drv_unsupported_opt,
+SourceLocation()) >
DiagnosticsEngine::Warning;
   continue;
 }

diff  --git a/clang/test/Driver/unsupported-option.c 
b/clang/test/Driver/unsupported-option.c
index 3f4227b52b3ba3..6be531d9df7de9 100644
--- a/clang/test/Driver/unsupported-option.c
+++ b/clang/test/Driver/unsupported-option.c
@@ -1,10 +1,10 @@
 // RUN: not %clang %s --hedonism -### 2>&1 | \
 // RUN: FileCheck %s
-// CHECK: error: unsupported option '--hedonism'
+// CHECK: error: unknown argument: '--hedonism'
 
 // RUN: not %clang %s --hell -### 2>&1 | \
 // RUN: FileCheck %s --check-prefix=DID-YOU-MEAN
-// DID-YOU-MEAN: error: unsupported option '--hell'; did you mean '--help'?
+// DID-YOU-MEAN: error: unknown argument '--hell'; did you mean '--help'?
 
 // RUN: not %clang --target=powerpc-ibm-aix %s -mlong-double-128 2>&1 | \
 // RUN: FileCheck %s --check-prefix=AIX-LONGDOUBLE128-ERR

diff  --git a/flang/test/Driver/driver-version.f90 
b/flang/test/Driver/driver-version.f90
index 44c5b8a9318216..d1e1e1d90fe1f8 100644
--- a/flang/test/Driver/driver-version.f90
+++ b/flang/test/Driver/driver-version.f90
@@ -9,7 +9,7 @@
 ! VERSION-NEXT: Thread model:
 ! VERSION-NEXT: InstalledDir:
 
-! ERROR: flang-new: error: unsupported option '--versions'; did you mean 
'--version'?
+! ERROR: flang-new: error: unknown argument '--versions'; did you mean 
'--version'?
 
 ! VERSION-FC1: LLVM version
 



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


[PATCH] D156506: [clang][Interp] Check floating results for NaNs

2023-08-02 Thread Joshua Cranmer via Phabricator via cfe-commits
jcranmer-intel added a comment.

You definitely don't want these rules to apply to all qNaNs. It's when an input 
operand is an sNaN for many operations. Note that the result of an operation 
with an sNaN as input (and FP result type) is a qNaN output, and the only times 
that you get an sNaN output are the times when you never signal (I think), so 
checking the result type is incorrect.




Comment at: clang/lib/AST/Interp/Interp.cpp:534-539
   if ((Status & APFloat::opStatus::opInvalidOp) &&
   FPO.getExceptionMode() != LangOptions::FPE_Ignore) {
 // There is no usefully definable result.
 S.FFDiag(E);
 return false;
   }

A further note is that sNaNs signal `FE_INVALID` when used, so sNaN should 
generally fall into this if statement in particular.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156506

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


[PATCH] D141918: WIP: [Clang] Emit 'unwindabort' when applicable.

2023-08-02 Thread James Y Knight via Phabricator via cfe-commits
jyknight updated this revision to Diff 546613.
jyknight edited the summary of this revision.
jyknight added a comment.

Rebase patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141918

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGCleanup.cpp
  clang/lib/CodeGen/CGCleanup.h
  clang/lib/CodeGen/CGException.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/EHScopeStack.h
  clang/test/CXX/except/except.spec/p9-dynamic.cpp
  clang/test/CXX/except/except.spec/p9-noexcept.cpp
  clang/test/CodeGenCXX/arm-generated-fn-attr.cpp
  clang/test/CodeGenCXX/block-byref-cxx-objc.cpp
  clang/test/CodeGenCXX/clang-call-terminate.uwtable.cpp
  clang/test/CodeGenCXX/cxx0x-delegating-ctors.cpp
  clang/test/CodeGenCXX/debug-info-class.cpp
  clang/test/CodeGenCXX/debug-info-line.cpp
  clang/test/CodeGenCXX/destructors.cpp
  clang/test/CodeGenCXX/dllimport-runtime-fns.cpp
  clang/test/CodeGenCXX/eh.cpp
  clang/test/CodeGenCXX/exceptions.cpp
  clang/test/CodeGenCXX/lambda-expressions.cpp
  clang/test/CodeGenCXX/noexcept.cpp
  clang/test/CodeGenCXX/nrvo.cpp
  clang/test/CodeGenCXX/partial-destruction.cpp
  clang/test/CodeGenCXX/pod-member-memcpys.cpp
  clang/test/CodeGenCXX/pr58798.cpp
  clang/test/CodeGenCXX/rtti-qualfn.cpp
  clang/test/CodeGenCXX/runtime-dllstorage.cpp
  clang/test/CodeGenObjCXX/arc-blocks.mm
  clang/test/CodeGenObjCXX/literals.mm
  clang/test/OpenMP/atomic_codegen.cpp
  clang/test/OpenMP/critical_codegen.cpp
  clang/test/OpenMP/critical_codegen_attr.cpp
  clang/test/OpenMP/declare_reduction_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
  clang/test/OpenMP/for_codegen.cpp
  clang/test/OpenMP/for_simd_codegen.cpp
  clang/test/OpenMP/masked_codegen.cpp
  clang/test/OpenMP/master_codegen.cpp
  clang/test/OpenMP/ordered_doacross_codegen.cpp
  clang/test/OpenMP/parallel_codegen.cpp
  clang/test/OpenMP/parallel_for_codegen.cpp
  clang/test/OpenMP/parallel_for_simd_codegen.cpp
  clang/test/OpenMP/parallel_master_codegen.cpp
  clang/test/OpenMP/parallel_sections_codegen.cpp
  clang/test/OpenMP/sections_codegen.cpp
  clang/test/OpenMP/simd_codegen.cpp
  clang/test/OpenMP/single_codegen.cpp
  clang/test/OpenMP/taskgroup_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_num_threads_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_num_threads_codegen.cpp

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


[PATCH] D156933: [HLSL] Add reversebits library function

2023-08-02 Thread Xiang Li via Phabricator via cfe-commits
python3kgae accepted this revision.
python3kgae added a comment.
This revision is now accepted and ready to land.

Don't need -fnative-half-type in the RUN line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156933

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


[PATCH] D156925: [Driver] Don't try to spell check unsupported options

2023-08-02 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

Looks great! We've had `def _ : Joined<"--">` since commit 
46fffee081b583a617fa94397b0c758bdf3a4a80 (2009) when TableGen based options 
were introduced.

Due to it, the error messages are slightly different, but I agree that it is 
not a meaningful difference:

  % fclang -qqq -c a.c
  clang: error: unknown argument: '-qqq'
  % fclang --qqq -c a.c
  clang: error: unsupported option '--qqq'


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156925

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


[PATCH] D156474: [-Wunsafe-buffer-usage][NFC] Slightly refactor and optimize the code

2023-08-02 Thread Rashmi Mudduluru via Phabricator via cfe-commits
t-rasmud accepted this revision.
t-rasmud added a comment.
This revision is now accepted and ready to land.

LGTM!




Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:2179
+  if (FixItsForVariable.count(GrpMate))
+FinalFixItsForVariable[Var].insert(FinalFixItsForVariable[Var].end(),
+   FixItsForVariable[GrpMate].begin(),

ziqingluo-90 wrote:
> t-rasmud wrote:
> > ziqingluo-90 wrote:
> > > Instead of calling `fixVariable` to generate fix-its for group mates, 
> > > directly copying those fix-its from the `FixItsForVariable` container.
> > > 
> > > At this point,  `FixItsForVariable` is complete. That is, it maps every 
> > > variable to its own fix-its (excluding fix-its of group mates).
> > Do you mean "including fix-its of group mates"? If not, I might have 
> > misunderstood the changes and will take a look again.
> No. 
> `FixItsForVariable` is a map from variables to their own fix-its, excluding 
> fix-its of group mates.
> `FinalFixItsForVariable` is a map from variables to the set of fix-its that 
> fix the whole group.
> 
> The construction of  `FinalFixItsForVariable` reads `FixItsForVariable`.
> 
> Maybe I should have better names for these two variables.
> 
> 
> 
Ah! That makes sense, I misread the `FixItsForVariable` as 
`FinalFixItsForVariable` in you comment. Thank you for explaining.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156474

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


[PATCH] D156234: [clang][deps] add support for dependency scanning with cc1 command line

2023-08-02 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 accepted this revision.
jansvoboda11 added a comment.
This revision is now accepted and ready to land.

LGTM after Windows CI gets fixed.


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

https://reviews.llvm.org/D156234

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


[PATCH] D156474: [-Wunsafe-buffer-usage][NFC] Slightly refactor and optimize the code

2023-08-02 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added inline comments.



Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:2179
+  if (FixItsForVariable.count(GrpMate))
+FinalFixItsForVariable[Var].insert(FinalFixItsForVariable[Var].end(),
+   FixItsForVariable[GrpMate].begin(),

t-rasmud wrote:
> ziqingluo-90 wrote:
> > Instead of calling `fixVariable` to generate fix-its for group mates, 
> > directly copying those fix-its from the `FixItsForVariable` container.
> > 
> > At this point,  `FixItsForVariable` is complete. That is, it maps every 
> > variable to its own fix-its (excluding fix-its of group mates).
> Do you mean "including fix-its of group mates"? If not, I might have 
> misunderstood the changes and will take a look again.
No. 
`FixItsForVariable` is a map from variables to their own fix-its, excluding 
fix-its of group mates.
`FinalFixItsForVariable` is a map from variables to the set of fix-its that fix 
the whole group.

The construction of  `FinalFixItsForVariable` reads `FixItsForVariable`.

Maybe I should have better names for these two variables.





Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156474

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


[PATCH] D153557: [clang][ExtractAPI] Add support for C++ classes

2023-08-02 Thread Haowei Wu via Phabricator via cfe-commits
haowei added a comment.

Thanks for reverting. I wasn't doing any changes to this when you were asking 
though, but looking at build log, it looks like the assertion error disappeared 
after f4de606ef271fe362f03d30c53a850f9877ec238 
 was 
landed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153557

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


[PATCH] D156936: [Clang] Increase default architecture from sm_35 to sm_52

2023-08-02 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: tra, jdoerfert, yaxunl, jlebar.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

We previously defaulted to `sm_35` for the purpose of unspecified
architecture. This was removed in new CUDA versions so we should bump
this up.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156936

Files:
  clang/include/clang/Basic/Cuda.h
  clang/test/Driver/cuda-cross-compiling.c


Index: clang/test/Driver/cuda-cross-compiling.c
===
--- clang/test/Driver/cuda-cross-compiling.c
+++ clang/test/Driver/cuda-cross-compiling.c
@@ -65,9 +65,9 @@
 // RUN: %clang --target=nvptx64-nvidia-cuda -### 
--cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=DEFAULT %s
 
-//  DEFAULT: -cc1" "-triple" "nvptx64-nvidia-cuda" "-S" {{.*}} 
"-target-cpu" "sm_35" "-target-feature" "+ptx{{[0-9]+}}" {{.*}} "-o" 
"[[PTX:.+]].s"
-// DEFAULT-NEXT: ptxas{{.*}}"-m64" "-O0" "--gpu-name" "sm_35" "--output-file" 
"[[CUBIN:.+]].cubin" "[[PTX]].s" "-c"
-// DEFAULT-NEXT: nvlink{{.*}}"-o" "a.out" "-arch" "sm_35" {{.*}} 
"[[CUBIN]].cubin"
+//  DEFAULT: -cc1" "-triple" "nvptx64-nvidia-cuda" "-S" {{.*}} 
"-target-cpu" "sm_52" "-target-feature" "+ptx{{[0-9]+}}" {{.*}} "-o" 
"[[PTX:.+]].s"
+// DEFAULT-NEXT: ptxas{{.*}}"-m64" "-O0" "--gpu-name" "sm_52" "--output-file" 
"[[CUBIN:.+]].cubin" "[[PTX]].s" "-c"
+// DEFAULT-NEXT: nvlink{{.*}}"-o" "a.out" "-arch" "sm_52" {{.*}} 
"[[CUBIN]].cubin"
 
 //
 // Test to ensure that we enable handling global constructors in a freestanding
Index: clang/include/clang/Basic/Cuda.h
===
--- clang/include/clang/Basic/Cuda.h
+++ clang/include/clang/Basic/Cuda.h
@@ -117,7 +117,7 @@
// public one.
   LAST,
 
-  CudaDefault = CudaArch::SM_35,
+  CudaDefault = CudaArch::SM_52,
   HIPDefault = CudaArch::GFX803,
 };
 


Index: clang/test/Driver/cuda-cross-compiling.c
===
--- clang/test/Driver/cuda-cross-compiling.c
+++ clang/test/Driver/cuda-cross-compiling.c
@@ -65,9 +65,9 @@
 // RUN: %clang --target=nvptx64-nvidia-cuda -### --cuda-path=%S/Inputs/CUDA/usr/local/cuda %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=DEFAULT %s
 
-//  DEFAULT: -cc1" "-triple" "nvptx64-nvidia-cuda" "-S" {{.*}} "-target-cpu" "sm_35" "-target-feature" "+ptx{{[0-9]+}}" {{.*}} "-o" "[[PTX:.+]].s"
-// DEFAULT-NEXT: ptxas{{.*}}"-m64" "-O0" "--gpu-name" "sm_35" "--output-file" "[[CUBIN:.+]].cubin" "[[PTX]].s" "-c"
-// DEFAULT-NEXT: nvlink{{.*}}"-o" "a.out" "-arch" "sm_35" {{.*}} "[[CUBIN]].cubin"
+//  DEFAULT: -cc1" "-triple" "nvptx64-nvidia-cuda" "-S" {{.*}} "-target-cpu" "sm_52" "-target-feature" "+ptx{{[0-9]+}}" {{.*}} "-o" "[[PTX:.+]].s"
+// DEFAULT-NEXT: ptxas{{.*}}"-m64" "-O0" "--gpu-name" "sm_52" "--output-file" "[[CUBIN:.+]].cubin" "[[PTX]].s" "-c"
+// DEFAULT-NEXT: nvlink{{.*}}"-o" "a.out" "-arch" "sm_52" {{.*}} "[[CUBIN]].cubin"
 
 //
 // Test to ensure that we enable handling global constructors in a freestanding
Index: clang/include/clang/Basic/Cuda.h
===
--- clang/include/clang/Basic/Cuda.h
+++ clang/include/clang/Basic/Cuda.h
@@ -117,7 +117,7 @@
// public one.
   LAST,
 
-  CudaDefault = CudaArch::SM_35,
+  CudaDefault = CudaArch::SM_52,
   HIPDefault = CudaArch::GFX803,
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156933: [HLSL] Add reversebits library function

2023-08-02 Thread Joshua Batista via Phabricator via cfe-commits
bob80905 updated this revision to Diff 546585.
bob80905 added a comment.

- rename file, make merge 2 Runs into 1 with enable16bit defined


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156933

Files:
  clang/lib/Headers/hlsl/hlsl_intrinsics.h
  clang/test/CodeGenHLSL/builtins/reversebits.hlsl

Index: clang/test/CodeGenHLSL/builtins/reversebits.hlsl
===
--- /dev/null
+++ clang/test/CodeGenHLSL/builtins/reversebits.hlsl
@@ -0,0 +1,155 @@
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -fnative-half-type \
+// RUN:   -D__HLSL_ENABLE_16_BIT -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s
+
+#ifdef __HLSL_ENABLE_16_BIT
+// CHECK: define noundef i16 @
+// CHECK: call i16 @llvm.bitreverse.i16(
+int16_t test_bitreverse_short(int16_t p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <2 x i16> @
+// CHECK: call <2 x i16> @llvm.bitreverse.v2i16(
+int16_t2 test_bitreverse_short2(int16_t2 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <3 x i16> @
+// CHECK: call <3 x i16> @llvm.bitreverse.v3i16
+int16_t3 test_bitreverse_short3(int16_t3 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <4 x i16> @
+// CHECK: call <4 x i16> @llvm.bitreverse.v4i16
+int16_t4 test_bitreverse_short4(int16_t4 p0)
+{
+	return reversebits(p0);
+}
+
+// CHECK: define noundef i16 @
+// CHECK: call i16 @llvm.bitreverse.i16(
+uint16_t test_bitreverse_ushort(uint16_t p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <2 x i16> @
+// CHECK: call <2 x i16> @llvm.bitreverse.v2i16
+uint16_t2 test_bitreverse_ushort2(uint16_t2 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <3 x i16> @
+// CHECK: call <3 x i16> @llvm.bitreverse.v3i16
+uint16_t3 test_bitreverse_ushort3(uint16_t3 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <4 x i16> @
+// CHECK: call <4 x i16> @llvm.bitreverse.v4i16
+uint16_t4 test_bitreverse_ushort4(uint16_t4 p0)
+{
+	return reversebits(p0);
+}
+#endif
+
+// CHECK: define noundef i32 @
+// CHECK: call i32 @llvm.bitreverse.i32(
+int test_bitreverse_int(int p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <2 x i32> @
+// CHECK: call <2 x i32> @llvm.bitreverse.v2i32
+int2 test_bitreverse_int2(int2 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <3 x i32> @
+// CHECK: call <3 x i32> @llvm.bitreverse.v3i32
+int3 test_bitreverse_int3(int3 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <4 x i32> @
+// CHECK: call <4 x i32> @llvm.bitreverse.v4i32
+int4 test_bitreverse_int4(int4 p0)
+{
+	return reversebits(p0);
+}
+
+// CHECK: define noundef i32 @
+// CHECK: call i32 @llvm.bitreverse.i32(
+int test_bitreverse_uint(uint p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <2 x i32> @
+// CHECK: call <2 x i32> @llvm.bitreverse.v2i32
+uint2 test_bitreverse_uint2(uint2 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <3 x i32> @
+// CHECK: call <3 x i32> @llvm.bitreverse.v3i32
+uint3 test_bitreverse_uint3(uint3 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <4 x i32> @
+// CHECK: call <4 x i32> @llvm.bitreverse.v4i32
+uint4 test_bitreverse_uint4(uint4 p0)
+{
+	return reversebits(p0);
+}
+
+// CHECK: define noundef i64 @
+// CHECK: call i64 @llvm.bitreverse.i64(
+int64_t test_bitreverse_long(int64_t p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <2 x i64> @
+// CHECK: call <2 x i64> @llvm.bitreverse.v2i64
+int64_t2 test_bitreverse_long2(int64_t2 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <3 x i64> @
+// CHECK: call <3 x i64> @llvm.bitreverse.v3i64
+int64_t3 test_bitreverse_long3(int64_t3 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <4 x i64> @
+// CHECK: call <4 x i64> @llvm.bitreverse.v4i64
+int64_t4 test_bitreverse_long4(int64_t4 p0)
+{
+	return reversebits(p0);
+}
+
+// CHECK: define noundef i64 @
+// CHECK: call i64 @llvm.bitreverse.i64(
+uint64_t test_bitreverse_long(uint64_t p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <2 x i64> @
+// CHECK: call <2 x i64> @llvm.bitreverse.v2i64
+uint64_t2 test_bitreverse_long2(uint64_t2 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <3 x i64> @
+// CHECK: call <3 x i64> @llvm.bitreverse.v3i64
+uint64_t3 test_bitreverse_long3(uint64_t3 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <4 x i64> @
+// CHECK: call <4 x i64> @llvm.bitreverse.v4i64
+uint64_t4 test_bitreverse_long4(uint64_t4 p0)
+{
+	return reversebits(p0);
+}
Index: clang/lib/Headers/hlsl/hlsl_intrinsics.h
===
--- clang/lib/Headers/hlsl/hlsl_intrinsics.h
+++ clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -476,5 +476,61 @@
 __attribute__((clang_builtin_alias(__builtin_elementwise_min)))
 double4 min(double4, dou

[PATCH] D156861: [Driver] Remove references to Solaris 12

2023-08-02 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

While you are modifying the lines `static const char ...[]` should look better 
than `static const char *const SolarisX86Triples[]`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156861

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


[PATCH] D156935: [HIP] Fix test rocm-detect.hip

2023-08-02 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG590d7e266426: [HIP] Fix test rocm-detect.hip (authored by 
yaxunl).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156935

Files:
  clang/test/Driver/rocm-detect.hip


Index: clang/test/Driver/rocm-detect.hip
===
--- clang/test/Driver/rocm-detect.hip
+++ clang/test/Driver/rocm-detect.hip
@@ -21,8 +21,8 @@
 // RUN:   | FileCheck -check-prefixes=COMMON,NODEFAULTLIBS %s
 
 // Test environment variable ROCM_PATH.
-// RUN: env ROCM_PATH=%S/Inputs/rocm not %clang -### --target=x86_64-linux-gnu 
\
-// RUN:   --print-rocm-search-dirs %s 2>&1 \
+// RUN: env ROCM_PATH=%S/Inputs/rocm %clang -### --target=x86_64-linux-gnu \
+// RUN:   --print-rocm-search-dirs --offload-arch=gfx1010 %s 2>&1 \
 // RUN:   | FileCheck -check-prefixes=ROCM-ENV %s
 
 // Test interaction between environment variables HIP_PATH and ROCM_PATH.
@@ -82,7 +82,7 @@
 // RUN: mkdir -p %T/opt
 // RUN: cp -r %S/Inputs/rocm %T/opt/rocm-3.9.0-1234
 // RUN: cp -r %S/Inputs/rocm %T/opt/rocm-3.10.0
-// RUN: not %clang -### --target=x86_64-linux-gnu --sysroot=%T \
+// RUN: %clang -### --target=x86_64-linux-gnu --offload-arch=gfx1010 
--sysroot=%T \
 // RUN:   --print-rocm-search-dirs %s 2>&1 \
 // RUN:   | FileCheck -check-prefixes=ROCM-REL %s
 
@@ -98,26 +98,18 @@
 // RUN:   | FileCheck -check-prefixes=SPACK %s
 
 // Test SPACK installation with multiple hip and rocm-device-libs packages of 
the same
-// ROCm release. Clang cannot determine which one to use and emit diagnostics. 
--hip-path
-// and --rocm-device-lib-path can be used to specify them.
+// ROCm release. --hip-path and --rocm-device-lib-path can be used to specify 
them.
 
 // RUN: cp -r %T/rocm-spack/hip-* %T/rocm-spack/hip-4.0.0-abcd
-// RUN: not 
%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang -### 
-v \
-// RUN:   -target x86_64-linux-gnu --cuda-gpu-arch=gfx900 %s 2>&1 \
-// RUN:   | FileCheck -check-prefixes=SPACK-MULT %s
 // RUN: 
%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang -### 
-v \
 // RUN:   -target x86_64-linux-gnu --cuda-gpu-arch=gfx900 \
 // RUN:   --hip-path=%T/rocm-spack/hip-4.0.0-abcd \
 // RUN:%s 2>&1 | FileCheck -check-prefixes=SPACK-SET %s
 
 // Test invalid SPACK ROCm installation missing hip and rocm-device-libs 
packages.
-// The message about SPACK is emitted only if -v is specified.
 
 // RUN: rm -rf %T/rocm-spack/hip-*
 // RUN: rm -rf 
%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/amdgcn
-// RUN: not 
%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang -### 
-v \
-// RUN:   -target x86_64-linux-gnu --cuda-gpu-arch=gfx900 %s 2>&1 \
-// RUN:   | FileCheck -check-prefixes=SPACK-MISS %s
 // RUN: 
%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang 
--version 2>&1 \
 // RUN:   | FileCheck -check-prefixes=SPACK-MISS-SILENT %s
 
@@ -152,21 +144,11 @@
 // SPACK-SAME: "-mlink-builtin-bitcode" 
"[[DIR]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/amdgcn/bitcode/hip.bc"
 // SPACK-SAME: "-idirafter" 
"[[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5/include"
 
-// SPACK-MULT: InstalledDir: 
[[DIR:.*]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin
-// SPACK-MULT-DAG: Cannot use SPACK package hip-4.0.0 at [[DIR]] due to 
multiple installations for the same version
-// SPACK-MULT-NOT: Found HIP installation: 
[[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5, version 4.0.20214-a2917cd
-// SPACK-MULT-NOT: "-internal-isystem" 
"[[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5/include"
-
 // SPACK-SET: InstalledDir: 
[[DIR:.*]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin
 // SPACK-SET: Found HIP installation: [[DIR]]/hip-4.0.0-abcd, version 
4.0.20214-a2917cd
 // SPACK-SET: "-triple" "amdgcn-amd-amdhsa"
 // SPACK-SET-SAME: "-mlink-builtin-bitcode" 
"[[DIR]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/amdgcn/bitcode/hip.bc"
 // SPACK-SET-SAME: "-idirafter" "[[DIR]]/hip-4.0.0-abcd/include"
 
-// SPACK-MISS: InstalledDir: 
[[DIR:.*]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin
-// SPACK-MISS-DAG: SPACK package hip-4.0.0 not found at [[DIR]]
-// SPACK-MISS-NOT: Found HIP installation: 
[[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5, version 4.0.20214-a2917cd
-// SPACK-MISS-NOT: "-idirafter" 
"[[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5/include"
-
 // SPACK-MISS-SILENT-NOT: SPACK package hip-{{.*}} not found at
 // SPACK-MISS-SILENT-NOT: Found HIP installation


Index: clang/test/Driver/rocm-detect.hip
===
--- clang/test/Driver/rocm-detect.hip
+++ clang/test/Driver/rocm-detect.hip
@@ -21,8 +21,8 @@
 // RUN:   | FileCheck 

[clang] 590d7e2 - [HIP] Fix test rocm-detect.hip

2023-08-02 Thread Yaxun Liu via cfe-commits

Author: Yaxun (Sam) Liu
Date: 2023-08-02T16:12:54-04:00
New Revision: 590d7e2664260d5ceef77be03cdc3564e0f57f72

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

LOG: [HIP] Fix test rocm-detect.hip

Two run lines fail due to missing device libs for gfx902, which are fixed by
using gfx1010 which has device lib.

The other two spack tests have to be removed since there is no reliable
way to make them pass/fail not depending on whether there is ROCm
installed on the system.

Reviewed by: Fangrui Song, Joseph Huber

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

Added: 


Modified: 
clang/test/Driver/rocm-detect.hip

Removed: 




diff  --git a/clang/test/Driver/rocm-detect.hip 
b/clang/test/Driver/rocm-detect.hip
index 683053610b74dc..6c6c352dcd1235 100644
--- a/clang/test/Driver/rocm-detect.hip
+++ b/clang/test/Driver/rocm-detect.hip
@@ -21,8 +21,8 @@
 // RUN:   | FileCheck -check-prefixes=COMMON,NODEFAULTLIBS %s
 
 // Test environment variable ROCM_PATH.
-// RUN: env ROCM_PATH=%S/Inputs/rocm not %clang -### --target=x86_64-linux-gnu 
\
-// RUN:   --print-rocm-search-dirs %s 2>&1 \
+// RUN: env ROCM_PATH=%S/Inputs/rocm %clang -### --target=x86_64-linux-gnu \
+// RUN:   --print-rocm-search-dirs --offload-arch=gfx1010 %s 2>&1 \
 // RUN:   | FileCheck -check-prefixes=ROCM-ENV %s
 
 // Test interaction between environment variables HIP_PATH and ROCM_PATH.
@@ -82,7 +82,7 @@
 // RUN: mkdir -p %T/opt
 // RUN: cp -r %S/Inputs/rocm %T/opt/rocm-3.9.0-1234
 // RUN: cp -r %S/Inputs/rocm %T/opt/rocm-3.10.0
-// RUN: not %clang -### --target=x86_64-linux-gnu --sysroot=%T \
+// RUN: %clang -### --target=x86_64-linux-gnu --offload-arch=gfx1010 
--sysroot=%T \
 // RUN:   --print-rocm-search-dirs %s 2>&1 \
 // RUN:   | FileCheck -check-prefixes=ROCM-REL %s
 
@@ -98,26 +98,18 @@
 // RUN:   | FileCheck -check-prefixes=SPACK %s
 
 // Test SPACK installation with multiple hip and rocm-device-libs packages of 
the same
-// ROCm release. Clang cannot determine which one to use and emit diagnostics. 
--hip-path
-// and --rocm-device-lib-path can be used to specify them.
+// ROCm release. --hip-path and --rocm-device-lib-path can be used to specify 
them.
 
 // RUN: cp -r %T/rocm-spack/hip-* %T/rocm-spack/hip-4.0.0-abcd
-// RUN: not 
%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang -### 
-v \
-// RUN:   -target x86_64-linux-gnu --cuda-gpu-arch=gfx900 %s 2>&1 \
-// RUN:   | FileCheck -check-prefixes=SPACK-MULT %s
 // RUN: 
%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang -### 
-v \
 // RUN:   -target x86_64-linux-gnu --cuda-gpu-arch=gfx900 \
 // RUN:   --hip-path=%T/rocm-spack/hip-4.0.0-abcd \
 // RUN:%s 2>&1 | FileCheck -check-prefixes=SPACK-SET %s
 
 // Test invalid SPACK ROCm installation missing hip and rocm-device-libs 
packages.
-// The message about SPACK is emitted only if -v is specified.
 
 // RUN: rm -rf %T/rocm-spack/hip-*
 // RUN: rm -rf 
%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/amdgcn
-// RUN: not 
%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang -### 
-v \
-// RUN:   -target x86_64-linux-gnu --cuda-gpu-arch=gfx900 %s 2>&1 \
-// RUN:   | FileCheck -check-prefixes=SPACK-MISS %s
 // RUN: 
%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang 
--version 2>&1 \
 // RUN:   | FileCheck -check-prefixes=SPACK-MISS-SILENT %s
 
@@ -152,21 +144,11 @@
 // SPACK-SAME: "-mlink-builtin-bitcode" 
"[[DIR]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/amdgcn/bitcode/hip.bc"
 // SPACK-SAME: "-idirafter" 
"[[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5/include"
 
-// SPACK-MULT: InstalledDir: 
[[DIR:.*]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin
-// SPACK-MULT-DAG: Cannot use SPACK package hip-4.0.0 at [[DIR]] due to 
multiple installations for the same version
-// SPACK-MULT-NOT: Found HIP installation: 
[[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5, version 4.0.20214-a2917cd
-// SPACK-MULT-NOT: "-internal-isystem" 
"[[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5/include"
-
 // SPACK-SET: InstalledDir: 
[[DIR:.*]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin
 // SPACK-SET: Found HIP installation: [[DIR]]/hip-4.0.0-abcd, version 
4.0.20214-a2917cd
 // SPACK-SET: "-triple" "amdgcn-amd-amdhsa"
 // SPACK-SET-SAME: "-mlink-builtin-bitcode" 
"[[DIR]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/amdgcn/bitcode/hip.bc"
 // SPACK-SET-SAME: "-idirafter" "[[DIR]]/hip-4.0.0-abcd/include"
 
-// SPACK-MISS: InstalledDir: 
[[DIR:.*]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin
-// SPACK-MISS-DAG: SPACK package hip-4.0.0 not found at [[DIR]]
-// SPACK-MISS-NOT: Found HIP installation: 
[[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5,

[clang] 61f3ce7 - [Driver] Change some group DocName from "flags" to "options"

2023-08-02 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-08-02T13:07:26-07:00
New Revision: 61f3ce7bb305d875bca4c7f22aaaf0940602448b

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

LOG: [Driver] Change some group DocName from "flags" to "options"

"Flags" usually refers to boolean options and is used as such in other
places of Options.td (e.g. "Target-dependent compilation options",
"").
This patch changes some misnomer group DocName from "flags" to
"options".

Added: 


Modified: 
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 3756b42da3b329..7d719234192a93 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -104,13 +104,13 @@ def Action_Group : OptionGroup<"">, 
DocName<"Actions">,
 // Meta-group for options which are only used for compilation,
 // and not linking etc.
 def CompileOnly_Group : OptionGroup<"">,
-DocName<"Compilation flags">, DocBrief<[{
+DocName<"Compilation options">, DocBrief<[{
 Flags controlling the behavior of Clang during compilation. These flags have
 no effect during actions that do not perform compilation.}]>;
 
 def Preprocessor_Group : OptionGroup<"">,
  Group,
- DocName<"Preprocessor flags">, DocBrief<[{
+ DocName<"Preprocessor options">, DocBrief<[{
 Flags controlling the behavior of the Clang preprocessor.}]>;
 
 def IncludePath_Group : OptionGroup<"">, Group,
@@ -132,7 +132,7 @@ def d_Group : OptionGroup<"">, 
Group,
 Flags allowing the state of the preprocessor to be dumped in various ways.}]>;
 
 def Diag_Group : OptionGroup<"">, Group,
- DocName<"Diagnostic flags">, DocBrief<[{
+ DocName<"Diagnostic options">, DocBrief<[{
 Flags controlling which warnings, errors, and remarks Clang will generate.
 See the :doc:`full list of warning and remark flags 
`.}]>;
 
@@ -151,10 +151,10 @@ def f_clang_Group : OptionGroup<"">,
 def pedantic_Group : OptionGroup<"">, Group,
  DocFlatten;
 def opencl_Group : OptionGroup<"">, Group,
-   DocName<"OpenCL flags">;
+   DocName<"OpenCL options">;
 
 def sycl_Group : OptionGroup<"">, Group,
- DocName<"SYCL flags">;
+ DocName<"SYCL options">;
 
 def m_Group : OptionGroup<"">, Group,
   DocName<"Target-dependent compilation options">;
@@ -213,20 +213,20 @@ def ggdbN_Group : OptionGroup<"">, 
Group, DocFlatten;
 def gTune_Group : OptionGroup<"">, Group,
   DocName<"Debugger to tune debug information for">;
 def g_flags_Group : OptionGroup<"">, Group,
-DocName<"Debug information flags">;
+DocName<"Debug information options">;
 
 def StaticAnalyzer_Group : OptionGroup<"">,
-   DocName<"Static analyzer flags">, DocBrief<[{
+   DocName<"Static analyzer options">, DocBrief<[{
 Flags controlling the behavior of the Clang Static Analyzer.}]>;
 
 // gfortran options that we recognize in the driver and pass along when
 // invoking GCC to compile Fortran code.
 def gfortran_Group : OptionGroup<"">,
- DocName<"Fortran compilation flags">, DocBrief<[{
+ DocName<"Fortran compilation options">, DocBrief<[{
 Flags that will be passed onto the ``gfortran`` compiler when Clang is given
 a Fortran input.}]>;
 
-def Link_Group : OptionGroup<"">, DocName<"Linker flags">,
+def Link_Group : OptionGroup<"">, DocName<"Linker options">,
  DocBrief<[{Flags that are passed on to the linker}]>;
 def T_Group : OptionGroup<"">, Group, DocFlatten;
 def u_Group : OptionGroup<"">, Group, DocFlatten;
@@ -252,7 +252,7 @@ def clang_ignored_legacy_options_Group : 
OptionGroup<"">,
   Group, Flags<[Ignored]>;
 
 def LongDouble_Group : OptionGroup<"">, Group,
-  DocName<"Long double flags">,
+  DocName<"Long double options">,
   DocBrief<[{Selects the long double implementation}]>;
 
 // Retired with clang-5.0



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


[PATCH] D156935: [HIP] Fix test rocm-detect.hip

2023-08-02 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: tra, MaskRay, jhuber6.
Herald added a project: All.
yaxunl requested review of this revision.

Two run lines fail due to missing device libs for gfx902, which are fixed by
using gfx1010 which has device lib.

The other two spack tests have to be removed since there is no reliable
way to make them pass/fail not depending on whether there is ROCm
installed on the system.


https://reviews.llvm.org/D156935

Files:
  clang/test/Driver/rocm-detect.hip


Index: clang/test/Driver/rocm-detect.hip
===
--- clang/test/Driver/rocm-detect.hip
+++ clang/test/Driver/rocm-detect.hip
@@ -21,8 +21,8 @@
 // RUN:   | FileCheck -check-prefixes=COMMON,NODEFAULTLIBS %s
 
 // Test environment variable ROCM_PATH.
-// RUN: env ROCM_PATH=%S/Inputs/rocm not %clang -### --target=x86_64-linux-gnu 
\
-// RUN:   --print-rocm-search-dirs %s 2>&1 \
+// RUN: env ROCM_PATH=%S/Inputs/rocm %clang -### --target=x86_64-linux-gnu \
+// RUN:   --print-rocm-search-dirs --offload-arch=gfx1010 %s 2>&1 \
 // RUN:   | FileCheck -check-prefixes=ROCM-ENV %s
 
 // Test interaction between environment variables HIP_PATH and ROCM_PATH.
@@ -82,7 +82,7 @@
 // RUN: mkdir -p %T/opt
 // RUN: cp -r %S/Inputs/rocm %T/opt/rocm-3.9.0-1234
 // RUN: cp -r %S/Inputs/rocm %T/opt/rocm-3.10.0
-// RUN: not %clang -### --target=x86_64-linux-gnu --sysroot=%T \
+// RUN: %clang -### --target=x86_64-linux-gnu --offload-arch=gfx1010 
--sysroot=%T \
 // RUN:   --print-rocm-search-dirs %s 2>&1 \
 // RUN:   | FileCheck -check-prefixes=ROCM-REL %s
 
@@ -98,26 +98,18 @@
 // RUN:   | FileCheck -check-prefixes=SPACK %s
 
 // Test SPACK installation with multiple hip and rocm-device-libs packages of 
the same
-// ROCm release. Clang cannot determine which one to use and emit diagnostics. 
--hip-path
-// and --rocm-device-lib-path can be used to specify them.
+// ROCm release. --hip-path and --rocm-device-lib-path can be used to specify 
them.
 
 // RUN: cp -r %T/rocm-spack/hip-* %T/rocm-spack/hip-4.0.0-abcd
-// RUN: not 
%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang -### 
-v \
-// RUN:   -target x86_64-linux-gnu --cuda-gpu-arch=gfx900 %s 2>&1 \
-// RUN:   | FileCheck -check-prefixes=SPACK-MULT %s
 // RUN: 
%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang -### 
-v \
 // RUN:   -target x86_64-linux-gnu --cuda-gpu-arch=gfx900 \
 // RUN:   --hip-path=%T/rocm-spack/hip-4.0.0-abcd \
 // RUN:%s 2>&1 | FileCheck -check-prefixes=SPACK-SET %s
 
 // Test invalid SPACK ROCm installation missing hip and rocm-device-libs 
packages.
-// The message about SPACK is emitted only if -v is specified.
 
 // RUN: rm -rf %T/rocm-spack/hip-*
 // RUN: rm -rf 
%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/amdgcn
-// RUN: not 
%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang -### 
-v \
-// RUN:   -target x86_64-linux-gnu --cuda-gpu-arch=gfx900 %s 2>&1 \
-// RUN:   | FileCheck -check-prefixes=SPACK-MISS %s
 // RUN: 
%T/rocm-spack/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin/clang 
--version 2>&1 \
 // RUN:   | FileCheck -check-prefixes=SPACK-MISS-SILENT %s
 
@@ -152,21 +144,11 @@
 // SPACK-SAME: "-mlink-builtin-bitcode" 
"[[DIR]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/amdgcn/bitcode/hip.bc"
 // SPACK-SAME: "-idirafter" 
"[[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5/include"
 
-// SPACK-MULT: InstalledDir: 
[[DIR:.*]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin
-// SPACK-MULT-DAG: Cannot use SPACK package hip-4.0.0 at [[DIR]] due to 
multiple installations for the same version
-// SPACK-MULT-NOT: Found HIP installation: 
[[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5, version 4.0.20214-a2917cd
-// SPACK-MULT-NOT: "-internal-isystem" 
"[[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5/include"
-
 // SPACK-SET: InstalledDir: 
[[DIR:.*]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin
 // SPACK-SET: Found HIP installation: [[DIR]]/hip-4.0.0-abcd, version 
4.0.20214-a2917cd
 // SPACK-SET: "-triple" "amdgcn-amd-amdhsa"
 // SPACK-SET-SAME: "-mlink-builtin-bitcode" 
"[[DIR]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/amdgcn/bitcode/hip.bc"
 // SPACK-SET-SAME: "-idirafter" "[[DIR]]/hip-4.0.0-abcd/include"
 
-// SPACK-MISS: InstalledDir: 
[[DIR:.*]]/llvm-amdgpu-4.0.0-ieagcs7inf7runpyfvepqkurasoglq4z/bin
-// SPACK-MISS-DAG: SPACK package hip-4.0.0 not found at [[DIR]]
-// SPACK-MISS-NOT: Found HIP installation: 
[[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5, version 4.0.20214-a2917cd
-// SPACK-MISS-NOT: "-idirafter" 
"[[DIR]]/hip-4.0.0-5f63slrursbrvfe2txrrjkynbsywsob5/include"
-
 // SPACK-MISS-SILENT-NOT: SPACK package hip-{{.*}} not found at
 // SPACK-MISS-SILENT-NOT: Found HIP installation


Index: clang/test/Driver/rocm-detect.hip
===
--- clang/test/Driver/rocm-detect.hip
+++ cl

[PATCH] D153557: [clang][ExtractAPI] Add support for C++ classes

2023-08-02 Thread Erick Velez via Phabricator via cfe-commits
evelez7 added a comment.

In D153557#4554980 , @haowei wrote:

> Hi, we are seeing a test error on `Clang :: 
> ExtractAPI/constructor_destructor.cpp` after this patch was landed. Error 
> message:

Hi! Sorry about that, I see you've made some changes. Do you still need me to 
revert this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153557

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


[PATCH] D156901: [OpenMP] Change OpenMP default version in documentation and help text for -fopenmp-version

2023-08-02 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added inline comments.



Comment at: flang/test/Driver/driver-help.f90:55
 ! HELP-NEXT: -fopenmp-version=
-! HELP-NEXT:Set OpenMP version (e.g. 45 for OpenMP 
4.5, 50 for OpenMP 5.0). Default value is 50 for Clang and 11 for Flang
+! HELP-NEXT:Set OpenMP version (e.g. 45 for OpenMP 
4.5, 51 for OpenMP 5.1). Default value is 51 for Clang and 11 for Flang
 ! HELP-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel 
code.

clementval wrote:
> AntonRydahl wrote:
> > tianshilei1992 wrote:
> > > Does Flang also switch to 5.1 by default?
> > As far as I know, `flang` is still OpenMP 1.1 by default but still depends 
> > on the same command line options as `clang`. 
> `flang` does not differentiate between versions. 
I see.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156901

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


[PATCH] D156901: [OpenMP] Change OpenMP default version in documentation and help text for -fopenmp-version

2023-08-02 Thread Valentin Clement via Phabricator via cfe-commits
clementval added inline comments.



Comment at: flang/test/Driver/driver-help.f90:55
 ! HELP-NEXT: -fopenmp-version=
-! HELP-NEXT:Set OpenMP version (e.g. 45 for OpenMP 
4.5, 50 for OpenMP 5.0). Default value is 50 for Clang and 11 for Flang
+! HELP-NEXT:Set OpenMP version (e.g. 45 for OpenMP 
4.5, 51 for OpenMP 5.1). Default value is 51 for Clang and 11 for Flang
 ! HELP-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel 
code.

AntonRydahl wrote:
> tianshilei1992 wrote:
> > Does Flang also switch to 5.1 by default?
> As far as I know, `flang` is still OpenMP 1.1 by default but still depends on 
> the same command line options as `clang`. 
`flang` does not differentiate between versions. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156901

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


[PATCH] D156933: [HLSL] Add reversebits library function

2023-08-02 Thread Xiang Li via Phabricator via cfe-commits
python3kgae added inline comments.



Comment at: clang/test/CodeGenHLSL/builtins/bitreverse.hlsl:32
+// CHECK: call <4 x i16> @llvm.bitreverse.v4i16
+// NO_HALF: define noundef <4 x i16> 
@"?test_bitreverse_short4@@YAT?$__vector@F$03@__clang@@T12@@Z"(
+// NO_HALF: call <4 x i16> @llvm.bitreverse.v4i16(

Not NO_HALF, it is integer :).

And __HLSL_ENABLE_16_BIT only defined once.
Maybe just one RUN line is enough.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156933

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


[PATCH] D156930: [Clang] Fix Offloading related tests after D156363

2023-08-02 Thread Joseph Huber via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbc080221b3a2: [Clang] Fix Offloading related tests after 
D156363 (authored by jhuber6).

Changed prior to commit:
  https://reviews.llvm.org/D156930?vs=546564&id=546578#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156930

Files:
  clang/test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_35.bc
  clang/test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_52.bc
  clang/test/Driver/Inputs/libomptarget/subdir/libomptarget-nvptx-sm_35.bc
  clang/test/Driver/Inputs/libomptarget/subdir/libomptarget-nvptx-sm_52.bc
  clang/test/Driver/amdgpu-hip-system-arch.c
  clang/test/Driver/cuda-bad-arch.cu
  clang/test/Driver/hip-autolink.hip
  clang/test/Driver/hip-binding.hip
  clang/test/Driver/hip-cuid-hash.hip
  clang/test/Driver/hip-cuid.hip
  clang/test/Driver/hip-default-gpu-arch.hip
  clang/test/Driver/hip-device-compile.hip
  clang/test/Driver/hip-host-cpu-features.hip
  clang/test/Driver/hip-launch-api.hip
  clang/test/Driver/hip-link-bc-to-bc.hip
  clang/test/Driver/hip-link-bundle-archive.hip
  clang/test/Driver/hip-no-device-libs.hip
  clang/test/Driver/hip-options.hip
  clang/test/Driver/hip-output-file-name.hip
  clang/test/Driver/hip-printf.hip
  clang/test/Driver/hip-save-temps.hip
  clang/test/Driver/hip-std.hip
  clang/test/Driver/hip-syntax-only.hip
  clang/test/Driver/hip-toolchain-dwarf.hip
  clang/test/Driver/hip-toolchain-features.hip
  clang/test/Driver/hip-toolchain-mllvm.hip
  clang/test/Driver/hip-toolchain-opt.hip
  clang/test/Driver/lto.cu
  clang/test/Driver/openmp-offload-gpu.c
  clang/test/Driver/openmp-offload-infer.c

Index: clang/test/Driver/openmp-offload-infer.c
===
--- clang/test/Driver/openmp-offload-infer.c
+++ clang/test/Driver/openmp-offload-infer.c
@@ -2,8 +2,8 @@
 // REQUIRES: nvptx-registered-target
 // REQUIRES: amdgpu-registered-target
 
-// RUN:   not %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp \
-// RUN:  --offload-arch=sm_52 --offload-arch=gfx803 \
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp \
+// RUN:  -nogpulib --offload-arch=sm_52 --offload-arch=gfx803 \
 // RUN:  --libomptarget-amdgpu-bc-path=%S/Inputs/hip_dev_lib/libomptarget-amdgpu-gfx803.bc \
 // RUN:  --libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-nvptx-test.bc %s 2>&1 \
 // RUN:   | FileCheck %s
@@ -39,9 +39,7 @@
 // CHECK-ARCH-BINDINGS: "x86_64-unknown-linux-gnu" - "clang", inputs: ["[[HOST_BC]]", "[[BINARY]]"], output: "[[HOST_OBJ:.*]]"
 // CHECK-ARCH-BINDINGS: "x86_64-unknown-linux-gnu" - "Offload::Linker", inputs: ["[[HOST_OBJ]]"], output: "a.out"
 
-// RUN:   not %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -fopenmp=libomp \
-// RUN: --offload-arch=sm_70 --offload-arch=gfx908 --offload-arch=native \
-// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -fopenmp \
+// RUN:   not %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -fopenmp \
 // RUN: --offload-arch=sm_70 --offload-arch=gfx908 --offload-arch=skylake \
 // RUN: -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-FAILED
 
Index: clang/test/Driver/openmp-offload-gpu.c
===
--- clang/test/Driver/openmp-offload-gpu.c
+++ clang/test/Driver/openmp-offload-gpu.c
@@ -10,33 +10,33 @@
 /// ###
 
 /// Check -Xopenmp-target uses one of the archs provided when several archs are used.
-// RUN:   not %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
-// RUN:  -Xopenmp-target -march=sm_35 -Xopenmp-target -march=sm_60 %s 2>&1 \
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -nogpulib -nogpuinc \
+// RUN:  -Xopenmp-target -march=sm_52 -Xopenmp-target -march=sm_60 %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-FOPENMP-TARGET-ARCHS %s
 
 // CHK-FOPENMP-TARGET-ARCHS: ptxas{{.*}}" "--gpu-name" "sm_60"
 
 /// ###
 
-/// Check -Xopenmp-target -march=sm_35 works as expected when two triples are present.
-// RUN:   not %clang -### -fopenmp=libomp \
+/// Check -Xopenmp-target -march=sm_52 works as expected when two triples are present.
+// RUN:   %clang -### -fopenmp=libomp \
 // RUN:  -fopenmp-targets=powerpc64le-ibm-linux-gnu,nvptx64-nvidia-cuda \
-// RUN:  -Xopenmp-target=nvptx64-nvidia-cuda -march=sm_35 %s 2>&1 \
+// RUN:  -nogpulib -nogpuinc -Xopenmp-target=nvptx64-nvidia-cuda -march=sm_52 %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-FOPENMP-TARGET-COMPILATION %s
 
-// CHK-FOPENMP-TARGET-COMPILATION: ptx

[clang] bc08022 - [Clang] Fix Offloading related tests after D156363

2023-08-02 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2023-08-02T14:34:51-05:00
New Revision: bc080221b3a2c73739caa2bf0521dd3984d0a934

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

LOG: [Clang] Fix Offloading related tests after D156363

This patch fixes failing tests after checking the return code from the
driver. This is mostly due to the ROCm libraries not being present
during most compilations. Passing `-nogpuinc` should allow us to compile
without it for tests that require it. Additionally, some old tests set
the architecture of Nvidia tests to `sm_35` which is officially
unsupported in CUDA 12+ so it prints an error. We just increase in this
case.

Reviewed By: MaskRay, yaxunl

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

Added: 
clang/test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_52.bc
clang/test/Driver/Inputs/libomptarget/subdir/libomptarget-nvptx-sm_52.bc

Modified: 
clang/test/Driver/amdgpu-hip-system-arch.c
clang/test/Driver/cuda-bad-arch.cu
clang/test/Driver/hip-autolink.hip
clang/test/Driver/hip-binding.hip
clang/test/Driver/hip-cuid-hash.hip
clang/test/Driver/hip-cuid.hip
clang/test/Driver/hip-default-gpu-arch.hip
clang/test/Driver/hip-device-compile.hip
clang/test/Driver/hip-host-cpu-features.hip
clang/test/Driver/hip-launch-api.hip
clang/test/Driver/hip-link-bc-to-bc.hip
clang/test/Driver/hip-link-bundle-archive.hip
clang/test/Driver/hip-no-device-libs.hip
clang/test/Driver/hip-options.hip
clang/test/Driver/hip-output-file-name.hip
clang/test/Driver/hip-printf.hip
clang/test/Driver/hip-save-temps.hip
clang/test/Driver/hip-std.hip
clang/test/Driver/hip-syntax-only.hip
clang/test/Driver/hip-toolchain-dwarf.hip
clang/test/Driver/hip-toolchain-features.hip
clang/test/Driver/hip-toolchain-mllvm.hip
clang/test/Driver/hip-toolchain-opt.hip
clang/test/Driver/lto.cu
clang/test/Driver/openmp-offload-gpu.c
clang/test/Driver/openmp-offload-infer.c

Removed: 
clang/test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_35.bc
clang/test/Driver/Inputs/libomptarget/subdir/libomptarget-nvptx-sm_35.bc



diff  --git a/clang/test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_35.bc 
b/clang/test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_52.bc
similarity index 100%
rename from clang/test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_35.bc
rename to clang/test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_52.bc

diff  --git 
a/clang/test/Driver/Inputs/libomptarget/subdir/libomptarget-nvptx-sm_35.bc 
b/clang/test/Driver/Inputs/libomptarget/subdir/libomptarget-nvptx-sm_52.bc
similarity index 100%
rename from 
clang/test/Driver/Inputs/libomptarget/subdir/libomptarget-nvptx-sm_35.bc
rename to 
clang/test/Driver/Inputs/libomptarget/subdir/libomptarget-nvptx-sm_52.bc

diff  --git a/clang/test/Driver/amdgpu-hip-system-arch.c 
b/clang/test/Driver/amdgpu-hip-system-arch.c
index 1c72c2d413032c..6b2955c274135b 100644
--- a/clang/test/Driver/amdgpu-hip-system-arch.c
+++ b/clang/test/Driver/amdgpu-hip-system-arch.c
@@ -26,8 +26,8 @@
 // EMPTY-OUTPUT: error: cannot determine amdgcn architecture: No AMD GPU 
detected in the system; consider passing it via '--offload-arch'
 
 // case when amdgpu-arch returns a gfx906 GPU.
-// RUN:   not %clang -### --target=x86_64-unknown-linux-gnu -nogpulib 
--offload-arch=native --amdgpu-arch-tool=%t/amdgpu_arch_gfx906 -x hip %s 2>&1 \
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpuinc -nogpulib 
--offload-arch=native --amdgpu-arch-tool=%t/amdgpu_arch_gfx906 -x hip %s 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=ARCH-GFX906
-// RUN:   not %clang -### --target=x86_64-unknown-linux-gnu -nogpulib 
--offload-new-driver --offload-arch=native 
--amdgpu-arch-tool=%t/amdgpu_arch_gfx906 -x hip %s 2>&1 \
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpuinc -nogpulib 
--offload-new-driver --offload-arch=native 
--amdgpu-arch-tool=%t/amdgpu_arch_gfx906 -x hip %s 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=ARCH-GFX906
 // ARCH-GFX906: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-target-cpu" 
"gfx906"

diff  --git a/clang/test/Driver/cuda-bad-arch.cu 
b/clang/test/Driver/cuda-bad-arch.cu
index 68988712d83a5f..877b20bc9351bc 100644
--- a/clang/test/Driver/cuda-bad-arch.cu
+++ b/clang/test/Driver/cuda-bad-arch.cu
@@ -20,23 +20,19 @@
 
 // BAD_CUDA9: GPU arch sm_21 is supported by CUDA versions between 7.0 and 8.0
 
-// RUN: not %clang -### --target=x86_64-linux-gnu --cuda-gpu-arch=sm_20 -c %s 
2>&1 \
+// RUN: %clang -### -target x86_64-linux-gnu -nogpulib -nogpuinc 
--cuda-gpu-arch=sm_52 -c --cuda-path=%S/Inputs/CUDA_80/usr/local/cuda %s 2>&1 \
 // RUN: | FileCheck -check-prefix OK %s
-// RUN: %clang -### -target x86_64-linux-

[PATCH] D156933: [HLSL] Add bitreverse library function

2023-08-02 Thread Joshua Batista via Phabricator via cfe-commits
bob80905 updated this revision to Diff 546576.
bob80905 added a comment.

- change builtin name to reversebits


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156933

Files:
  clang/lib/Headers/hlsl/hlsl_intrinsics.h
  clang/test/CodeGenHLSL/builtins/bitreverse.hlsl

Index: clang/test/CodeGenHLSL/builtins/bitreverse.hlsl
===
--- /dev/null
+++ clang/test/CodeGenHLSL/builtins/bitreverse.hlsl
@@ -0,0 +1,166 @@
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -fnative-half-type \
+// RUN:   -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
+// RUN:   -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF
+
+#ifdef __HLSL_ENABLE_16_BIT
+// CHECK: define noundef i16 @
+// CHECK: call i16 @llvm.bitreverse.i16(
+// NO_HALF: define noundef i16 @"?test_bitreverse_short@@YAFF@Z"(
+// NO_HALF: call i16 @llvm.bitreverse.i16(
+int16_t test_bitreverse_short ( int16_t p0 ) {
+  return reversebits( p0 );
+}
+// CHECK: define noundef <2 x i16> @
+// CHECK: call <2 x i16> @llvm.bitreverse.v2i16(
+// NO_HALF: define noundef <2 x i16> @"?test_bitreverse_short2@@YAT?$__vector@F$01@__clang@@T12@@Z"(
+// NO_HALF: call <2 x i16> @llvm.bitreverse.v2i16(
+int16_t2 test_bitreverse_short2 ( int16_t2 p0 ) {
+  return reversebits( p0 );
+}
+// CHECK: define noundef <3 x i16> @
+// CHECK: call <3 x i16> @llvm.bitreverse.v3i16
+// NO_HALF: define noundef <3 x i16> @"?test_bitreverse_short3@@YAT?$__vector@F$02@__clang@@T12@@Z"(
+// NO_HALF: call <3 x i16> @llvm.bitreverse.v3i16(
+int16_t3 test_bitreverse_short3 ( int16_t3 p0 ) {
+  return reversebits( p0 );
+}
+// CHECK: define noundef <4 x i16> @
+// CHECK: call <4 x i16> @llvm.bitreverse.v4i16
+// NO_HALF: define noundef <4 x i16> @"?test_bitreverse_short4@@YAT?$__vector@F$03@__clang@@T12@@Z"(
+// NO_HALF: call <4 x i16> @llvm.bitreverse.v4i16(
+int16_t4 test_bitreverse_short4 ( int16_t4 p0 ) {
+  return reversebits( p0 );
+}
+
+// CHECK: define noundef i16 @
+// CHECK: call i16 @llvm.bitreverse.i16(
+// NO_HALF: define noundef i16 @"?test_bitreverse_ushort@@YAGG@Z"(
+// NO_HALF: call i16 @llvm.bitreverse.i16(
+uint16_t test_bitreverse_ushort ( uint16_t p0 ) {
+  return reversebits( p0 );
+}
+// CHECK: define noundef <2 x i16> @
+// CHECK: call <2 x i16> @llvm.bitreverse.v2i16
+// NO_HALF: define noundef <2 x i16> @"?test_bitreverse_ushort2@@YAT?$__vector@G$01@__clang@@T12@@Z"(
+// NO_HALF: call <2 x i16> @llvm.bitreverse.v2i16(
+uint16_t2 test_bitreverse_ushort2 ( uint16_t2 p0 ) {
+  return reversebits( p0 );
+}
+// CHECK: define noundef <3 x i16> @
+// CHECK: call <3 x i16> @llvm.bitreverse.v3i16
+// NO_HALF: define noundef <3 x i16> @"?test_bitreverse_ushort3@@YAT?$__vector@G$02@__clang@@T12@@Z"(
+// NO_HALF: call <3 x i16> @llvm.bitreverse.v3i16(
+uint16_t3 test_bitreverse_ushort3 ( uint16_t3 p0 ) {
+  return reversebits( p0 );
+}
+// CHECK: define noundef <4 x i16> @
+// CHECK: call <4 x i16> @llvm.bitreverse.v4i16
+// NO_HALF: define noundef <4 x i16> @"?test_bitreverse_ushort4@@YAT?$__vector@G$03@__clang@@T12@@Z"(
+// NO_HALF: call <4 x i16> @llvm.bitreverse.v4i16(
+uint16_t4 test_bitreverse_ushort4 ( uint16_t4 p0 ) {
+  return reversebits( p0 );
+}
+#endif
+
+// CHECK: define noundef i32 @
+// CHECK: call i32 @llvm.bitreverse.i32(
+int test_bitreverse_int(int p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <2 x i32> @
+// CHECK: call <2 x i32> @llvm.bitreverse.v2i32
+int2 test_bitreverse_int2(int2 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <3 x i32> @
+// CHECK: call <3 x i32> @llvm.bitreverse.v3i32
+int3 test_bitreverse_int3(int3 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <4 x i32> @
+// CHECK: call <4 x i32> @llvm.bitreverse.v4i32
+int4 test_bitreverse_int4(int4 p0)
+{
+	return reversebits(p0);
+}
+
+// CHECK: define noundef i32 @
+// CHECK: call i32 @llvm.bitreverse.i32(
+int test_bitreverse_uint(uint p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <2 x i32> @
+// CHECK: call <2 x i32> @llvm.bitreverse.v2i32
+uint2 test_bitreverse_uint2(uint2 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <3 x i32> @
+// CHECK: call <3 x i32> @llvm.bitreverse.v3i32
+uint3 test_bitreverse_uint3(uint3 p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <4 x i32> @
+// CHECK: call <4 x i32> @llvm.bitreverse.v4i32
+uint4 test_bitreverse_uint4(uint4 p0)
+{
+	return reversebits(p0);
+}
+
+// CHECK: define noundef i64 @
+// CHECK: call i64 @llvm.bitreverse.i64(
+int64_t test_bitreverse_long(int64_t p0)
+{
+	return reversebits(p0);
+}
+// CHECK: define noundef <2 x i64> @
+// CHECK: call <2 x i64> @llvm.bitreverse.v2i64
+in

[PATCH] D156933: [HLSL] Add bitreverse library function

2023-08-02 Thread Joshua Batista via Phabricator via cfe-commits
bob80905 created this revision.
Herald added a subscriber: Anastasia.
Herald added a project: All.
bob80905 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156933

Files:
  clang/lib/Headers/hlsl/hlsl_intrinsics.h
  clang/test/CodeGenHLSL/builtins/bitreverse.hlsl

Index: clang/test/CodeGenHLSL/builtins/bitreverse.hlsl
===
--- /dev/null
+++ clang/test/CodeGenHLSL/builtins/bitreverse.hlsl
@@ -0,0 +1,167 @@
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -fnative-half-type \
+// RUN:   -emit-llvm -disable-llvm-passes -O3 -o - | FileCheck %s
+// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \
+// RUN:   dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
+// RUN:   -D__HLSL_ENABLE_16_BIT -o - | FileCheck %s --check-prefix=NO_HALF
+
+#ifdef __HLSL_ENABLE_16_BIT
+// CHECK: define noundef i16 @
+// CHECK: call i16 @llvm.bitreverse.i16(
+// NO_HALF: define noundef i16 @"?test_bitreverse_short@@YAFF@Z"(
+// NO_HALF: call i16 @llvm.bitreverse.i16(
+int16_t test_bitreverse_short ( int16_t p0 ) {
+  return bitreverse ( p0 );
+}
+// CHECK: define noundef <2 x i16> @
+// CHECK: call <2 x i16> @llvm.bitreverse.v2i16(
+// NO_HALF: define noundef <2 x i16> @"?test_bitreverse_short2@@YAT?$__vector@F$01@__clang@@T12@@Z"(
+// NO_HALF: call <2 x i16> @llvm.bitreverse.v2i16(
+int16_t2 test_bitreverse_short2 ( int16_t2 p0 ) {
+  return bitreverse ( p0 );
+}
+// CHECK: define noundef <3 x i16> @
+// CHECK: call <3 x i16> @llvm.bitreverse.v3i16
+// NO_HALF: define noundef <3 x i16> @"?test_bitreverse_short3@@YAT?$__vector@F$02@__clang@@T12@@Z"(
+// NO_HALF: call <3 x i16> @llvm.bitreverse.v3i16(
+int16_t3 test_bitreverse_short3 ( int16_t3 p0 ) {
+  return bitreverse ( p0 );
+}
+// CHECK: define noundef <4 x i16> @
+// CHECK: call <4 x i16> @llvm.bitreverse.v4i16
+// NO_HALF: define noundef <4 x i16> @"?test_bitreverse_short4@@YAT?$__vector@F$03@__clang@@T12@@Z"(
+// NO_HALF: call <4 x i16> @llvm.bitreverse.v4i16(
+int16_t4 test_bitreverse_short4 ( int16_t4 p0 ) {
+  return bitreverse ( p0 );
+}
+
+// CHECK: define noundef i16 @
+// CHECK: call i16 @llvm.bitreverse.i16(
+// NO_HALF: define noundef i16 @"?test_bitreverse_ushort@@YAGG@Z"(
+// NO_HALF: call i16 @llvm.bitreverse.i16(
+uint16_t test_bitreverse_ushort ( uint16_t p0 ) {
+  return bitreverse ( p0 );
+}
+// CHECK: define noundef <2 x i16> @
+// CHECK: call <2 x i16> @llvm.bitreverse.v2i16
+// NO_HALF: define noundef <2 x i16> @"?test_bitreverse_ushort2@@YAT?$__vector@G$01@__clang@@T12@@Z"(
+// NO_HALF: call <2 x i16> @llvm.bitreverse.v2i16(
+uint16_t2 test_bitreverse_ushort2 ( uint16_t2 p0 ) {
+  return bitreverse ( p0 );
+}
+// CHECK: define noundef <3 x i16> @
+// CHECK: call <3 x i16> @llvm.bitreverse.v3i16
+// NO_HALF: define noundef <3 x i16> @"?test_bitreverse_ushort3@@YAT?$__vector@G$02@__clang@@T12@@Z"(
+// NO_HALF: call <3 x i16> @llvm.bitreverse.v3i16(
+uint16_t3 test_bitreverse_ushort3 ( uint16_t3 p0 ) {
+  return bitreverse ( p0 );
+}
+// CHECK: define noundef <4 x i16> @
+// CHECK: call <4 x i16> @llvm.bitreverse.v4i16
+// NO_HALF: define noundef <4 x i16> @"?test_bitreverse_ushort4@@YAT?$__vector@G$03@__clang@@T12@@Z"(
+// NO_HALF: call <4 x i16> @llvm.bitreverse.v4i16(
+uint16_t4 test_bitreverse_ushort4 ( uint16_t4 p0 ) {
+  return bitreverse ( p0 );
+}
+#endif
+
+// CHECK: define noundef i32 @
+// CHECK: call i32 @llvm.bitreverse.i32(
+int test_bitreverse_int(int p0)
+{
+	return bitreverse(p0);
+}
+// CHECK: define noundef <2 x i32> @
+// CHECK: call <2 x i32> @llvm.bitreverse.v2i32
+int2 test_bitreverse_int2(int2 p0)
+{
+	return bitreverse(p0);
+}
+// CHECK: define noundef <3 x i32> @
+// CHECK: call <3 x i32> @llvm.bitreverse.v3i32
+int3 test_bitreverse_int3(int3 p0)
+{
+	return bitreverse(p0);
+}
+// CHECK: define noundef <4 x i32> @
+// CHECK: call <4 x i32> @llvm.bitreverse.v4i32
+int4 test_bitreverse_int4(int4 p0)
+{
+	return bitreverse(p0);
+}
+
+// CHECK: define noundef i32 @
+// CHECK: call i32 @llvm.bitreverse.i32(
+int test_bitreverse_uint(uint p0)
+{
+	return bitreverse(p0);
+}
+// CHECK: define noundef <2 x i32> @
+// CHECK: call <2 x i32> @llvm.bitreverse.v2i32
+uint2 test_bitreverse_uint2(uint2 p0)
+{
+	return bitreverse(p0);
+}
+// CHECK: define noundef <3 x i32> @
+// CHECK: call <3 x i32> @llvm.bitreverse.v3i32
+uint3 test_bitreverse_uint3(uint3 p0)
+{
+	return bitreverse(p0);
+}
+// CHECK: define noundef <4 x i32> @
+// CHECK: call <4 x i32> @llvm.bitreverse.v4i32
+uint4 test_bitreverse_uint4(uint4 p0)
+{
+	return bitreverse(p0);
+}
+
+// CHECK: define noundef i64 @
+// CHECK: call i64 @llvm.bitreverse.i64(
+int64_t test_bitreverse_long(int64_t p0)
+{
+	return bitreverse(p0);
+}
+// CHECK: define noundef <2 x i64> @
+// CHECK: call <2 x i64> 

[PATCH] D156556: [AggressiveInstCombine][NFC] Fix typo

2023-08-02 Thread Noah Goldstein via Phabricator via cfe-commits
goldstein.w.n accepted this revision.
goldstein.w.n added a comment.
This revision is now accepted and ready to land.

In D156556#4555036 , @kitaisreal 
wrote:

> In D156556#4554436 , @goldstein.w.n 
> wrote:
>
>> Can you mark the title as NFC?
>
> It seems that title of revision is "[AggressiveInstCombine][NFC] Fix typo". 
> Do you mean to put NFC at the beginning ?

No its good. I just can't read.
LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156556

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


[PATCH] D156928: [Clang][AMDGPU] Fix handling of -mcode-object-version=none arg

2023-08-02 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D156928#4555121 , @yaxunl wrote:

> `-mcode-object-version=none` was intentionally designed to work with `clang 
> -cc1` only, since it does not work with clang driver if users link with 
> device library. Device library can still use it by  using it with `-Xclang`.

If the intended use is the deviceRTL then that should be sufficient.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156928

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


[PATCH] D156928: [Clang][AMDGPU] Fix handling of -mcode-object-version=none arg

2023-08-02 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

`-mcode-object-version=none` was intentionally designed to work with `clang 
-cc1` only, since it does not work with clang driver if users link with device 
library. Device library can still use it by  using it with `-Xclang`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156928

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


[PATCH] D156363: [Driver] -###: exit with code 1 if hasErrorOccurred

2023-08-02 Thread Rainer Orth via Phabricator via cfe-commits
ro added a comment.

In D156363#4554884 , @MaskRay wrote:

> In D156363#4554812 , @jhuber6 wrote:
>
>> 



>> Probably because we're not specifying the `--target=` I'll add that in my 
>> fix for AMDGPU I'm working on and see if it solves the problem.
>
> Thank you for fixing these tests. I agree that clang_f_opts.c:117 with 
> `-flto` needs a `--target=`, to not cause this error on 
> `amd64-pc-solaris2.11'`.
> This should be the only line. I unfortunately did not catch this because I do 
> not have access to a target using `HasNativeLLVMSupport` == false`.

Confirmed: adding `-target x86_64-unknown-linux` to both `clang_f_opts.c:117` 
and `lto.c:19` let both tests `PASS` on `amd64-pc-solaris2.11`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156363

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


[PATCH] D156277: [Parser][ObjC] Fix parser crash on nested top-level block with better recovery path

2023-08-02 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM.  Small wording suggestion for the comment, but feel free to commit with 
that change.




Comment at: clang/lib/Parse/ParseObjc.cpp:742
 
-// Eat the identifier.
+// Bail out as if we saw an '@end'
+if (isTopLevelObjCKeyword(DirectiveKind))

"If we see something like '@interface' that's only allowed at the top level,
bail out as if we saw an '@end'.  We'll diagnose this below."


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156277

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


[PATCH] D156930: [Clang] Fix Offloading related tests after D156363

2023-08-02 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.

LGTM. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156930

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


[PATCH] D156930: [Clang] Fix Offloading related tests after D156363

2023-08-02 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

Thanks! I guess `--rocm-path=` can be used in some places, but `-nogpulib 
-nogpuinc` is good as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156930

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


[clang] 2e65a42 - [Driver][test] Ensure --target= for -flto commands

2023-08-02 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-08-02T11:57:02-07:00
New Revision: 2e65a423e277b40a885b9de8a2cbf60f2f812cd6

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

LOG: [Driver][test] Ensure --target= for -flto commands

Otherwise if the default target triple has `HasNativeLLVMSupport() ==
false`, the %clang command will exit with code 1 due to
err_drv_no_linker_llvm_support.

The issue is exposed by D156363.

Added: 


Modified: 
clang/test/Driver/clang_f_opts.c
clang/test/Driver/lto.c

Removed: 




diff  --git a/clang/test/Driver/clang_f_opts.c 
b/clang/test/Driver/clang_f_opts.c
index a59496fb0b313d..1704da892687d2 100644
--- a/clang/test/Driver/clang_f_opts.c
+++ b/clang/test/Driver/clang_f_opts.c
@@ -114,7 +114,7 @@
 // RUN: %clang -### -S -fprofile-instr-generate -fcoverage-mapping 
-fno-coverage-mapping %s 2>&1 | FileCheck -check-prefix=CHECK-DISABLE-COVERAGE 
%s
 // RUN: %clang -### -S -fprofile-remapping-file=foo/bar.txt %s 2>&1 | 
FileCheck -check-prefix=CHECK-PROFILE-REMAP %s
 // RUN: %clang -### -S -forder-file-instrumentation %s 2>&1 | FileCheck 
-check-prefix=CHECK-ORDERFILE-INSTR %s
-// RUN: %clang -### -flto -forder-file-instrumentation %s 2>&1 | FileCheck 
-check-prefix=CHECK-ORDERFILE-INSTR-LTO %s
+// RUN: %clang -### --target=x86_64-linux-gnu -flto 
-forder-file-instrumentation %s 2>&1 | FileCheck 
-check-prefix=CHECK-ORDERFILE-INSTR-LTO %s
 // CHECK-PROFILE-GENERATE: "-fprofile-instrument=clang"
 // CHECK-PROFILE-GENERATE-LLVM: "-fprofile-instrument=llvm"
 // CHECK-PROFILE-GENERATE-DIR: 
"-fprofile-instrument-path=/some/dir{{/|}}{{.*}}"

diff  --git a/clang/test/Driver/lto.c b/clang/test/Driver/lto.c
index 2c540780ba4fce..62bdbd6f5d3cfa 100644
--- a/clang/test/Driver/lto.c
+++ b/clang/test/Driver/lto.c
@@ -16,7 +16,7 @@
 
 // llvm-bc and llvm-ll outputs need to match regular suffixes
 // (unfortunately).
-// RUN: %clang %s -flto -save-temps -### 2> %t
+// RUN: %clang --target=x86_64-linux-gnu %s -flto -save-temps -### 2> %t
 // RUN: FileCheck -check-prefix=CHECK-COMPILELINK-SUFFIXES < %t %s
 //
 // CHECK-COMPILELINK-SUFFIXES: "-o" "{{.*}}lto.i" "-x" "c" "{{.*}}lto.c"
@@ -24,7 +24,7 @@
 // CHECK-COMPILELINK-SUFFIXES: "-o" "{{.*}}lto.o" {{.*}}"{{.*}}lto.bc"
 // CHECK-COMPILELINK-SUFFIXES: "{{.*}}a.{{(out|exe)}}" {{.*}}"{{.*}}lto.o"
 
-// RUN: %clang %s -flto -S -### 2> %t
+// RUN: %clang --target=x86_64-linux-gnu %s -flto -S -### 2> %t
 // RUN: FileCheck -check-prefix=CHECK-COMPILE-SUFFIXES < %t %s
 //
 // CHECK-COMPILE-SUFFIXES: "-o" "{{.*}}lto.s" "-x" "c" "{{.*}}lto.c"



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


[PATCH] D156928: [Clang][AMDGPU] Fix handling of -mcode-object-version=none arg

2023-08-02 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added inline comments.



Comment at: clang/include/clang/Basic/TargetOptions.h:90
+COV_Default = 400,
+COV_MAX = 500
   };

Typically we just put a `COV_LAST` to indicate that it's over the accepted 
enumerations.



Comment at: clang/lib/Driver/ToolChain.cpp:1364
 // at all, target and host share a toolchain.
 if (A->getOption().matches(options::OPT_m_Group)) {
   if (SameTripleAsHost)

Is this flag not in the `m` group? It should be caught here right?



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:1058
 unsigned CodeObjVer = getAMDGPUCodeObjectVersion(D, Args);
+if(CodeObjVer != 0) {
 CmdArgs.insert(CmdArgs.begin() + 1,

Use clang-format.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:1066
+if (!IsCC1As) {
+  std::string CodeObjVerStr = (CodeObjVer ? Twine(CodeObjVer) : 
"none").str();
   CmdArgs.insert(CmdArgs.begin() + 1,

arsenm wrote:
> don't need to go through std::string? stick with Twine everywhere?
You shouldn't assign to a Twine, but in general I think we should probably put 
this ternary in-line with the other stuff to avoid the temporary.

The handling here is a little confusing, we do
```
Args.getLastArg(options::OPT_mcode_object_version_EQ);
```
Which expects a number, if it's not present we get an empty string which 
default converts to zero which we then convert into "none"?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156928

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


[PATCH] D156556: [AggressiveInstCombine][NFC] Fix typo

2023-08-02 Thread Maksim Kita via Phabricator via cfe-commits
kitaisreal added a comment.

In D156556#4554436 , @goldstein.w.n 
wrote:

> Can you mark the title as NFC?

It seems that title of revision is "[AggressiveInstCombine][NFC] Fix typo". Do 
you mean to put NFC at the beginning ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156556

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


[PATCH] D156930: [Clang] Fix Offloading related tests after D156363

2023-08-02 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: MaskRay, yaxunl, JonChesterfield, tra, jdoerfert, 
ronlieb, jplehr.
Herald added subscribers: mattd, asavonic, ormris, kerbowa, steven_wu, 
hiraditya, jvesely.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

This patch fixes failing tests after checking the return code from the
driver. This is mostly due to the ROCm libraries not being present
during most compilations. Passing `-nogpuinc` should allow us to compile
without it for tests that require it. Additionally, some old tests set
the architecture of Nvidia tests to `sm_35` which is officially
unsupported in CUDA 12+ so it prints an error. We just increase in this
case.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156930

Files:
  clang/test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_35.bc
  clang/test/Driver/Inputs/libomptarget/libomptarget-nvptx-sm_52.bc
  clang/test/Driver/Inputs/libomptarget/subdir/libomptarget-nvptx-sm_35.bc
  clang/test/Driver/Inputs/libomptarget/subdir/libomptarget-nvptx-sm_52.bc
  clang/test/Driver/amdgpu-hip-system-arch.c
  clang/test/Driver/cuda-bad-arch.cu
  clang/test/Driver/hip-autolink.hip
  clang/test/Driver/hip-binding.hip
  clang/test/Driver/hip-cuid-hash.hip
  clang/test/Driver/hip-cuid.hip
  clang/test/Driver/hip-default-gpu-arch.hip
  clang/test/Driver/hip-device-compile.hip
  clang/test/Driver/hip-host-cpu-features.hip
  clang/test/Driver/hip-launch-api.hip
  clang/test/Driver/hip-link-bc-to-bc.hip
  clang/test/Driver/hip-link-bundle-archive.hip
  clang/test/Driver/hip-no-device-libs.hip
  clang/test/Driver/hip-options.hip
  clang/test/Driver/hip-output-file-name.hip
  clang/test/Driver/hip-printf.hip
  clang/test/Driver/hip-save-temps.hip
  clang/test/Driver/hip-std.hip
  clang/test/Driver/hip-syntax-only.hip
  clang/test/Driver/hip-toolchain-dwarf.hip
  clang/test/Driver/hip-toolchain-features.hip
  clang/test/Driver/hip-toolchain-mllvm.hip
  clang/test/Driver/hip-toolchain-opt.hip
  clang/test/Driver/lto.cu
  clang/test/Driver/openmp-offload-gpu.c
  clang/test/Driver/openmp-offload-infer.c

Index: clang/test/Driver/openmp-offload-infer.c
===
--- clang/test/Driver/openmp-offload-infer.c
+++ clang/test/Driver/openmp-offload-infer.c
@@ -2,8 +2,8 @@
 // REQUIRES: nvptx-registered-target
 // REQUIRES: amdgpu-registered-target
 
-// RUN:   not %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp \
-// RUN:  --offload-arch=sm_52 --offload-arch=gfx803 \
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp=libomp \
+// RUN:  -nogpulib --offload-arch=sm_52 --offload-arch=gfx803 \
 // RUN:  --libomptarget-amdgpu-bc-path=%S/Inputs/hip_dev_lib/libomptarget-amdgpu-gfx803.bc \
 // RUN:  --libomptarget-nvptx-bc-path=%S/Inputs/libomptarget/libomptarget-nvptx-test.bc %s 2>&1 \
 // RUN:   | FileCheck %s
@@ -39,9 +39,7 @@
 // CHECK-ARCH-BINDINGS: "x86_64-unknown-linux-gnu" - "clang", inputs: ["[[HOST_BC]]", "[[BINARY]]"], output: "[[HOST_OBJ:.*]]"
 // CHECK-ARCH-BINDINGS: "x86_64-unknown-linux-gnu" - "Offload::Linker", inputs: ["[[HOST_OBJ]]"], output: "a.out"
 
-// RUN:   not %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -fopenmp=libomp \
-// RUN: --offload-arch=sm_70 --offload-arch=gfx908 --offload-arch=native \
-// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -fopenmp \
+// RUN:   not %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -fopenmp \
 // RUN: --offload-arch=sm_70 --offload-arch=gfx908 --offload-arch=skylake \
 // RUN: -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-FAILED
 
Index: clang/test/Driver/openmp-offload-gpu.c
===
--- clang/test/Driver/openmp-offload-gpu.c
+++ clang/test/Driver/openmp-offload-gpu.c
@@ -10,33 +10,33 @@
 /// ###
 
 /// Check -Xopenmp-target uses one of the archs provided when several archs are used.
-// RUN:   not %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda \
-// RUN:  -Xopenmp-target -march=sm_35 -Xopenmp-target -march=sm_60 %s 2>&1 \
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -nogpulib -nogpuinc \
+// RUN:  -Xopenmp-target -march=sm_52 -Xopenmp-target -march=sm_60 %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHK-FOPENMP-TARGET-ARCHS %s
 
 // CHK-FOPENMP-TARGET-ARCHS: ptxas{{.*}}" "--gpu-name" "sm_60"
 
 /// ###
 
-/// Check -Xopenmp-target -march=sm_35 works as expected when two triples are present.
-// RUN:   not %clang -### -fopenmp=libomp \
+/// Check -Xopenmp-target -march=sm_52 works as expected when two triples are present.
+// RU

[clang] f4de606 - fix use-after-free introduced in 8b76b44e46ac

2023-08-02 Thread Augie Fackler via cfe-commits

Author: Augie Fackler
Date: 2023-08-02T14:38:08-04:00
New Revision: f4de606ef271fe362f03d30c53a850f9877ec238

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

LOG: fix use-after-free introduced in 8b76b44e46ac

ASan catches this easily enough.

Added: 


Modified: 
clang/lib/ExtractAPI/DeclarationFragments.cpp

Removed: 




diff  --git a/clang/lib/ExtractAPI/DeclarationFragments.cpp 
b/clang/lib/ExtractAPI/DeclarationFragments.cpp
index ea72835c995313..375bdfbb02fbfd 100644
--- a/clang/lib/ExtractAPI/DeclarationFragments.cpp
+++ b/clang/lib/ExtractAPI/DeclarationFragments.cpp
@@ -606,7 +606,7 @@ DeclarationFragments
 DeclarationFragmentsBuilder::getFragmentsForSpecialCXXMethod(
 const CXXMethodDecl *Method) {
   DeclarationFragments Fragments;
-  StringRef Name;
+  std::string Name;
   if (isa(Method)) {
 auto *Constructor = dyn_cast(Method);
 Name = cast(Constructor->getDeclContext())->getName();
@@ -614,7 +614,7 @@ 
DeclarationFragmentsBuilder::getFragmentsForSpecialCXXMethod(
   Fragments.append("explicit", DeclarationFragments::FragmentKind::Keyword)
   .appendSpace();
   } else if (isa(Method))
-Name = StringRef(Method->getNameAsString());
+Name = Method->getNameAsString();
 
   DeclarationFragments After;
   Fragments.append(Name, DeclarationFragments::FragmentKind::Identifier)



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


[PATCH] D156928: [Clang][AMDGPU] Fix handling of -mcode-object-version=none arg

2023-08-02 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

missing tests




Comment at: clang/lib/Driver/ToolChains/Clang.cpp:1066
+if (!IsCC1As) {
+  std::string CodeObjVerStr = (CodeObjVer ? Twine(CodeObjVer) : 
"none").str();
   CmdArgs.insert(CmdArgs.begin() + 1,

don't need to go through std::string? stick with Twine everywhere?



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:2309
+  auto CovStr = StringRef(CodeObjArg->getValue());
+  if(CovStr.starts_with("none")) return;
+  

missing space after if, also return on separate line. Also why starts with, and 
not ==?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156928

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


[clang] 11b7ce2 - [ASanStableABI][Driver] Stop linking to asan dylib when stable abi is enabled

2023-08-02 Thread Blue Gaston via cfe-commits

Author: Blue Gaston
Date: 2023-08-02T11:30:29-07:00
New Revision: 11b7ce26f2a22ca147feaaf1cfd2d21b85fc3d83

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

LOG: [ASanStableABI][Driver] Stop linking to asan dylib when stable abi is 
enabled

This patch enables linking of the static archive when fsanitize-stable-abi is 
set and stops linking to the asan dylib.

To link to the Address Sanitizer stable abi static library use 
"-fsanitize=address -fsanitize-stable-abi"

Updates a test with these flags.

rdar://112480890

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

Added: 


Modified: 
clang/include/clang/Driver/SanitizerArgs.h
clang/lib/Driver/ToolChains/Darwin.cpp
compiler-rt/test/asan_abi/CMakeLists.txt
compiler-rt/test/asan_abi/TestCases/Darwin/llvm_interface_symbols.cpp
compiler-rt/test/asan_abi/TestCases/linkstaticlibrary.cpp
compiler-rt/test/asan_abi/lit.site.cfg.py.in

Removed: 




diff  --git a/clang/include/clang/Driver/SanitizerArgs.h 
b/clang/include/clang/Driver/SanitizerArgs.h
index 047b50626c44c5..07070ec4fc0653 100644
--- a/clang/include/clang/Driver/SanitizerArgs.h
+++ b/clang/include/clang/Driver/SanitizerArgs.h
@@ -76,6 +76,7 @@ class SanitizerArgs {
 bool DiagnoseErrors = true);
 
   bool needsSharedRt() const { return SharedRuntime; }
+  bool needsStableAbi() const { return StableABI; }
 
   bool needsMemProfRt() const { return NeedsMemProfRt; }
   bool needsAsanRt() const { return Sanitizers.has(SanitizerKind::Address); }

diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index 65bd6c6a7eb35a..239fbf21d77f5a 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1484,9 +1484,13 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList 
&Args,
 
   if (Sanitize.linkRuntimes()) {
 if (Sanitize.needsAsanRt()) {
-  assert(Sanitize.needsSharedRt() &&
- "Static sanitizer runtimes not supported");
-  AddLinkSanitizerLibArgs(Args, CmdArgs, "asan");
+  if (Sanitize.needsStableAbi()) {
+AddLinkSanitizerLibArgs(Args, CmdArgs, "asan_abi", /*shared=*/false);
+  } else {
+assert(Sanitize.needsSharedRt() &&
+   "Static sanitizer runtimes not supported");
+AddLinkSanitizerLibArgs(Args, CmdArgs, "asan");
+  }
 }
 if (Sanitize.needsLsanRt())
   AddLinkSanitizerLibArgs(Args, CmdArgs, "lsan");

diff  --git a/compiler-rt/test/asan_abi/CMakeLists.txt 
b/compiler-rt/test/asan_abi/CMakeLists.txt
index a1f42ca076edf7..f28cf6cd1da6ea 100644
--- a/compiler-rt/test/asan_abi/CMakeLists.txt
+++ b/compiler-rt/test/asan_abi/CMakeLists.txt
@@ -13,7 +13,6 @@ set(ASAN_ABI_TEST_DEPS ${SANITIZER_COMMON_LIT_TEST_DEPS})
 if(NOT COMPILER_RT_STANDALONE_BUILD)
   list(APPEND ASAN_ABI_TEST_DEPS asan_abi)
 endif()
-set(ASAN_ABI_DYNAMIC_TEST_DEPS ${ASAN_ABI_TEST_DEPS})
 
 set(ASAN_ABI_TEST_ARCH ${ASAN_ABI_SUPPORTED_ARCH})
 if(APPLE)
@@ -27,7 +26,6 @@ foreach(arch ${ASAN_ABI_TEST_ARCH})
   string(TOLOWER "-${arch}-${OS_NAME}" ASAN_ABI_TEST_CONFIG_SUFFIX)
   get_bits_for_arch(${arch} ASAN_ABI_TEST_BITS)
   get_test_cc_for_arch(${arch} ASAN_ABI_TEST_TARGET_CC 
ASAN_ABI_TEST_TARGET_CFLAGS)
-  set(ASAN_ABI_TEST_DYNAMIC True)
 
   string(TOUPPER ${arch} ARCH_UPPER_CASE)
   set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}Config)

diff  --git 
a/compiler-rt/test/asan_abi/TestCases/Darwin/llvm_interface_symbols.cpp 
b/compiler-rt/test/asan_abi/TestCases/Darwin/llvm_interface_symbols.cpp
index 96f59191b8d46a..c651c32b489e4e 100644
--- a/compiler-rt/test/asan_abi/TestCases/Darwin/llvm_interface_symbols.cpp
+++ b/compiler-rt/test/asan_abi/TestCases/Darwin/llvm_interface_symbols.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_asan_abi -O0 -c -fsanitize-stable-abi -fsanitize=address %s -o 
%t.o
 // RUN: %clangxx -c %p/../../../../lib/asan_abi/asan_abi.cpp -o asan_abi.o
-// RUN: %clangxx -dead_strip -o %t %t.o %libasan_abi asan_abi.o && %run %t 2>&1
+// RUN: %clangxx -dead_strip -o %t %t.o -fsanitize-stable-abi 
-fsanitize=address asan_abi.o && %run %t 2>&1
 // RUN: %clangxx -x c++-header -o - -E 
%p/../../../../lib/asan/asan_interface.inc \
 // RUN: | sed "s/INTERFACE_FUNCTION/\nINTERFACE_FUNCTION/g" > 
%t.asan_interface.inc
 // RUN: llvm-nm -g %libasan_abi   \
@@ -22,6 +22,9 @@
 // RUN: sort %t.exports | uniq > %t.exports-sorted
 // RUN: 
diff  %t.imports-sorted %t.exports-sorted
 
+// Ensure that there is no dynamic dylib linked.
+// RUN: otool -L %t | (! grep -q "dynamic.dylib")
+
 // UNSUPPORTED: ios
 
 int main() { return 0; }

diff  --git a/compiler-rt/test/asan_abi/TestCases/linkstaticlibrary.cpp 
b/compiler-rt/test/asan_abi/TestCases/linkstaticlibrary.cpp
index 0bb14d322c67c2

[PATCH] D156718: [ASanStableABI][Driver] Stop linking to asan dylib when stable abi is enabled

2023-08-02 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG11b7ce26f2a2: [ASanStableABI][Driver] Stop linking to asan 
dylib when stable abi is enabled (authored by Blue Gaston 
).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156718

Files:
  clang/include/clang/Driver/SanitizerArgs.h
  clang/lib/Driver/ToolChains/Darwin.cpp
  compiler-rt/test/asan_abi/CMakeLists.txt
  compiler-rt/test/asan_abi/TestCases/Darwin/llvm_interface_symbols.cpp
  compiler-rt/test/asan_abi/TestCases/linkstaticlibrary.cpp
  compiler-rt/test/asan_abi/lit.site.cfg.py.in


Index: compiler-rt/test/asan_abi/lit.site.cfg.py.in
===
--- compiler-rt/test/asan_abi/lit.site.cfg.py.in
+++ compiler-rt/test/asan_abi/lit.site.cfg.py.in
@@ -8,7 +8,6 @@
 config.arm_thumb = "@COMPILER_RT_ARM_THUMB@"
 config.apple_platform = "@ASAN_ABI_TEST_APPLE_PLATFORM@"
 config.apple_platform_min_deployment_target_flag = 
"@ASAN_ABI_TEST_MIN_DEPLOYMENT_TARGET_FLAG@"
-config.asan_abi_dynamic = @ASAN_ABI_TEST_DYNAMIC@
 config.target_arch = "@ASAN_ABI_TEST_TARGET_ARCH@"
 
 # Load common config for all compiler-rt lit tests.
Index: compiler-rt/test/asan_abi/TestCases/linkstaticlibrary.cpp
===
--- compiler-rt/test/asan_abi/TestCases/linkstaticlibrary.cpp
+++ compiler-rt/test/asan_abi/TestCases/linkstaticlibrary.cpp
@@ -1,5 +1,5 @@
 // RUN: %clang_asan_abi  -O2 -c -fsanitize-stable-abi -fsanitize=address -O0 
%s -o %t.o
 // RUN: %clangxx -c %p/../../../lib/asan_abi/asan_abi.cpp -o asan_abi.o
-// RUN: %clangxx -o %t %t.o %libasan_abi asan_abi.o && %run %t 2>&1
+// RUN: %clangxx -o %t %t.o -fsanitize-stable-abi -fsanitize=address 
asan_abi.o && %run %t 2>&1
 
 int main() { return 0; }
Index: compiler-rt/test/asan_abi/TestCases/Darwin/llvm_interface_symbols.cpp
===
--- compiler-rt/test/asan_abi/TestCases/Darwin/llvm_interface_symbols.cpp
+++ compiler-rt/test/asan_abi/TestCases/Darwin/llvm_interface_symbols.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_asan_abi -O0 -c -fsanitize-stable-abi -fsanitize=address %s -o 
%t.o
 // RUN: %clangxx -c %p/../../../../lib/asan_abi/asan_abi.cpp -o asan_abi.o
-// RUN: %clangxx -dead_strip -o %t %t.o %libasan_abi asan_abi.o && %run %t 2>&1
+// RUN: %clangxx -dead_strip -o %t %t.o -fsanitize-stable-abi 
-fsanitize=address asan_abi.o && %run %t 2>&1
 // RUN: %clangxx -x c++-header -o - -E 
%p/../../../../lib/asan/asan_interface.inc \
 // RUN: | sed "s/INTERFACE_FUNCTION/\nINTERFACE_FUNCTION/g" > 
%t.asan_interface.inc
 // RUN: llvm-nm -g %libasan_abi   \
@@ -22,6 +22,9 @@
 // RUN: sort %t.exports | uniq > %t.exports-sorted
 // RUN: diff %t.imports-sorted %t.exports-sorted
 
+// Ensure that there is no dynamic dylib linked.
+// RUN: otool -L %t | (! grep -q "dynamic.dylib")
+
 // UNSUPPORTED: ios
 
 int main() { return 0; }
Index: compiler-rt/test/asan_abi/CMakeLists.txt
===
--- compiler-rt/test/asan_abi/CMakeLists.txt
+++ compiler-rt/test/asan_abi/CMakeLists.txt
@@ -13,7 +13,6 @@
 if(NOT COMPILER_RT_STANDALONE_BUILD)
   list(APPEND ASAN_ABI_TEST_DEPS asan_abi)
 endif()
-set(ASAN_ABI_DYNAMIC_TEST_DEPS ${ASAN_ABI_TEST_DEPS})
 
 set(ASAN_ABI_TEST_ARCH ${ASAN_ABI_SUPPORTED_ARCH})
 if(APPLE)
@@ -27,7 +26,6 @@
   string(TOLOWER "-${arch}-${OS_NAME}" ASAN_ABI_TEST_CONFIG_SUFFIX)
   get_bits_for_arch(${arch} ASAN_ABI_TEST_BITS)
   get_test_cc_for_arch(${arch} ASAN_ABI_TEST_TARGET_CC 
ASAN_ABI_TEST_TARGET_CFLAGS)
-  set(ASAN_ABI_TEST_DYNAMIC True)
 
   string(TOUPPER ${arch} ARCH_UPPER_CASE)
   set(CONFIG_NAME ${ARCH_UPPER_CASE}${OS_NAME}Config)
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1484,9 +1484,13 @@
 
   if (Sanitize.linkRuntimes()) {
 if (Sanitize.needsAsanRt()) {
-  assert(Sanitize.needsSharedRt() &&
- "Static sanitizer runtimes not supported");
-  AddLinkSanitizerLibArgs(Args, CmdArgs, "asan");
+  if (Sanitize.needsStableAbi()) {
+AddLinkSanitizerLibArgs(Args, CmdArgs, "asan_abi", /*shared=*/false);
+  } else {
+assert(Sanitize.needsSharedRt() &&
+   "Static sanitizer runtimes not supported");
+AddLinkSanitizerLibArgs(Args, CmdArgs, "asan");
+  }
 }
 if (Sanitize.needsLsanRt())
   AddLinkSanitizerLibArgs(Args, CmdArgs, "lsan");
Index: clang/include/clang/Driver/SanitizerArgs.h
===
--- clang/include/clang/Driver/SanitizerArgs.h
+++ clang/include/clang/Driver/SanitizerArgs.h
@@ -76,6 +76,7 @@
 bool DiagnoseErro

[PATCH] D156928: [Clang][AMDGPU] Fix handling of -mcode-object-version=none arg

2023-08-02 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam created this revision.
saiislam added reviewers: jhuber6, yaxunl.
Herald added subscribers: tpr, dstuttard, kzhuravl.
Herald added a project: All.
saiislam requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, wdng.
Herald added a project: clang.

-mcode-object-version=none is a special argument which allows
abi-agnostic code to be generated for device runtime libraries.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156928

Files:
  clang/include/clang/Basic/TargetOptions.h
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp

Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -25,6 +25,7 @@
 #include "clang/Basic/CharInfo.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/ObjCRuntime.h"
+#include "clang/Basic/TargetOptions.h"
 #include "clang/Basic/Version.h"
 #include "clang/Config/config.h"
 #include "clang/Driver/Action.h"
@@ -2299,16 +2300,16 @@
 
 void tools::checkAMDGPUCodeObjectVersion(const Driver &D,
  const llvm::opt::ArgList &Args) {
-  const unsigned MinCodeObjVer = 2;
-  const unsigned MaxCodeObjVer = 5;
 
   if (auto *CodeObjArg = getAMDGPUCodeObjectArgument(D, Args)) {
 if (CodeObjArg->getOption().getID() ==
 options::OPT_mcode_object_version_EQ) {
-  unsigned CodeObjVer = MaxCodeObjVer;
-  auto Remnant =
-  StringRef(CodeObjArg->getValue()).getAsInteger(0, CodeObjVer);
-  if (Remnant || CodeObjVer < MinCodeObjVer || CodeObjVer > MaxCodeObjVer)
+  unsigned CodeObjVer = TargetOptions::COV_Default / 100;
+  auto CovStr = StringRef(CodeObjArg->getValue());
+  if(CovStr.starts_with("none")) return;
+  
+  CovStr.getAsInteger(0, CodeObjVer);
+  if (CodeObjVer < TargetOptions::COV_None || CodeObjVer > TargetOptions::COV_MAX)
 D.Diag(diag::err_drv_invalid_int_value)
 << CodeObjArg->getAsString(Args) << CodeObjArg->getValue();
 }
@@ -2317,9 +2318,13 @@
 
 unsigned tools::getAMDGPUCodeObjectVersion(const Driver &D,
const llvm::opt::ArgList &Args) {
-  unsigned CodeObjVer = 4; // default
-  if (auto *CodeObjArg = getAMDGPUCodeObjectArgument(D, Args))
-StringRef(CodeObjArg->getValue()).getAsInteger(0, CodeObjVer);
+
+  unsigned CodeObjVer = TargetOptions::COV_Default / 100; // default
+  if (haveAMDGPUCodeObjectVersionArgument(D, Args)) {
+auto CodeObjArg = StringRef(getAMDGPUCodeObjectArgument(D, Args)->getValue());
+if(CodeObjArg.starts_with("none"))  return TargetOptions::COV_None;
+CodeObjArg.getAsInteger(0, CodeObjVer);
+  }
   return CodeObjVer;
 }
 
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -1055,15 +1055,19 @@
   // provided the user (e.g. front end tests) can use the default.
   if (haveAMDGPUCodeObjectVersionArgument(D, Args)) {
 unsigned CodeObjVer = getAMDGPUCodeObjectVersion(D, Args);
+if(CodeObjVer != 0) {
 CmdArgs.insert(CmdArgs.begin() + 1,
Args.MakeArgString(Twine("--amdhsa-code-object-version=") +
   Twine(CodeObjVer)));
 CmdArgs.insert(CmdArgs.begin() + 1, "-mllvm");
+}
 // -cc1as does not accept -mcode-object-version option.
-if (!IsCC1As)
+if (!IsCC1As) {
+  std::string CodeObjVerStr = (CodeObjVer ? Twine(CodeObjVer) : "none").str();
   CmdArgs.insert(CmdArgs.begin() + 1,
  Args.MakeArgString(Twine("-mcode-object-version=") +
-Twine(CodeObjVer)));
+CodeObjVerStr));
+}
   }
 }
 
Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -1354,6 +1354,9 @@
 
   // Handle -Xopenmp-target flags
   for (auto *A : Args) {
+if (A->getOption().matches(options::OPT_mcode_object_version_EQ))
+  DAL->append(A);
+
 // Exclude flags which may only apply to the host toolchain.
 // Do not exclude flags when the host triple (AuxTriple)
 // matches the current toolchain triple. If it is not present
Index: clang/include/clang/Basic/TargetOptions.h
===
--- clang/include/clang/Basic/TargetOptions.h
+++ clang/include/clang/Basic/TargetOptions.h
@@ -86,6 +86,8 @@
 COV_3 = 300,
 COV_4 = 400,
 COV_5 = 500,
+COV_Default = 400,
+COV_MAX = 500
   };
   /// \brief Code object version for AMDGPU.
   CodeObjectVersionKind CodeObjectVersion = CodeObjectVersionKind::COV_Non

[PATCH] D153557: [clang][ExtractAPI] Add support for C++ classes

2023-08-02 Thread Haowei Wu via Phabricator via cfe-commits
haowei added a comment.

Hi, we are seeing a test error on `Clang :: 
ExtractAPI/constructor_destructor.cpp` after this patch was landed. Error 
message:

  Script:
  --
  : 'RUN: at line 1';   rm -rf 
/b/s/w/ir/x/w/llvm_build/tools/clang/test/ExtractAPI/Output/constructor_destructor.cpp.tmp
  : 'RUN: at line 2';   split-file 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/ExtractAPI/constructor_destructor.cpp
 
/b/s/w/ir/x/w/llvm_build/tools/clang/test/ExtractAPI/Output/constructor_destructor.cpp.tmp
  : 'RUN: at line 3';   sed -e 
"s@INPUT_DIR@/b/s/w/ir/x/w/llvm_build/tools/clang/test/ExtractAPI/Output/constructor_destructor.cpp.tmp@g"
  
/b/s/w/ir/x/w/llvm_build/tools/clang/test/ExtractAPI/Output/constructor_destructor.cpp.tmp/reference.output.json.in
 >> 
/b/s/w/ir/x/w/llvm_build/tools/clang/test/ExtractAPI/Output/constructor_destructor.cpp.tmp/reference.output.json
  : 'RUN: at line 5';   /b/s/w/ir/x/w/llvm_build/bin/clang++ -extract-api 
-target arm64-apple-macosx -x c++-header  
/b/s/w/ir/x/w/llvm_build/tools/clang/test/ExtractAPI/Output/constructor_destructor.cpp.tmp/input.h
 -o 
/b/s/w/ir/x/w/llvm_build/tools/clang/test/ExtractAPI/Output/constructor_destructor.cpp.tmp/output.json
 -Xclang -verify
  : 'RUN: at line 9';   sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" 
 
/b/s/w/ir/x/w/llvm_build/tools/clang/test/ExtractAPI/Output/constructor_destructor.cpp.tmp/output.json
 >> 
/b/s/w/ir/x/w/llvm_build/tools/clang/test/ExtractAPI/Output/constructor_destructor.cpp.tmp/output-normalized.json
  : 'RUN: at line 11';   diff 
/b/s/w/ir/x/w/llvm_build/tools/clang/test/ExtractAPI/Output/constructor_destructor.cpp.tmp/reference.output.json
 
/b/s/w/ir/x/w/llvm_build/tools/clang/test/ExtractAPI/Output/constructor_destructor.cpp.tmp/output-normalized.json
  --
  Exit Code: 1
  
  Command Output (stderr):
  --
  clang++: llvm/include/llvm/Support/JSON.h:317: 
llvm::json::Value::Value(std::string): Assertion `false && "Invalid UTF-8 in 
value used as JSON"' failed.
  PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ 
and include the crash backtrace, preprocessed source, and associated run script.
  Stack dump:
  0.Program arguments: /b/s/w/ir/x/w/llvm_build/bin/clang++ -extract-api 
-target arm64-apple-macosx -x c++-header 
/b/s/w/ir/x/w/llvm_build/tools/clang/test/ExtractAPI/Output/constructor_destructor.cpp.tmp/input.h
 -o 
/b/s/w/ir/x/w/llvm_build/tools/clang/test/ExtractAPI/Output/constructor_destructor.cpp.tmp/output.json
 -Xclang -verify
  #0 0x55a2ec85c458 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
(/b/s/w/ir/x/w/llvm_build/bin/clang+++0x83e5458)
  clang++: error: clang frontend command failed with exit code 134 (use -v to 
see invocation)
  Fuchsia clang version 18.0.0 (https://llvm.googlesource.com/llvm-project 
dad9de0ae5360b18c890985d212bec266bf8c122)
  Target: arm64-apple-macosx
  Thread model: posix
  InstalledDir: /b/s/w/ir/x/w/llvm_build/bin
  clang++: note: diagnostic msg: 
  
  
  PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
  Preprocessed source(s) and associated run script(s) are located at:
  clang++: note: diagnostic msg: /b/s/w/ir/x/t/lit-tmp-0iloyqe3/input-5086dc.hh
  clang++: note: diagnostic msg: /b/s/w/ir/x/t/lit-tmp-0iloyqe3/input-5086dc.sh
  clang++: note: diagnostic msg: 
  
  
  
  --

Link to the builder: 
https://ci.chromium.org/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64/b8773854265208228753/overview

It looks like it triggers an assertion error in llvm's JSON library. Could you 
take a look please? If it takes some time to fix, could you revert your change 
please? Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153557

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


[PATCH] D156363: [Driver] -###: exit with code 1 if hasErrorOccurred

2023-08-02 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D156363#4554913 , @yaxunl wrote:

> Thanks. I will wait for your patch. You can leave the tricky ones to me if 
> you would like. e.g. the rocm-detect.hip

You can go ahead and fix that one then.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156363

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


[PATCH] D156925: [Driver] Don't try to spell check unsupported options

2023-08-02 Thread Justin Bogner via Phabricator via cfe-commits
bogner created this revision.
bogner added reviewers: Bigcheese, MaskRay.
Herald added a subscriber: mcrosier.
Herald added a reviewer: sscalpone.
Herald added a reviewer: awarzynski.
Herald added projects: Flang, All.
bogner requested review of this revision.
Herald added subscribers: cfe-commits, wangpc, jdoerfert.
Herald added a project: clang.

We currently spell check options that are listed as unsupported, but
this doesn't make much sense. If an option is explicitly unsupported
why would one that's spelled similarly be useful?

It looks like the reason this was added was that we explicitly mark
all `--something` flags as Unsupported rather than just leaving them
undefined and treating them as unknown. Drop that handling so that we
don't regress on things like misspelling `--help`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156925

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/unsupported-option.c
  flang/test/Driver/driver-version.f90


Index: flang/test/Driver/driver-version.f90
===
--- flang/test/Driver/driver-version.f90
+++ flang/test/Driver/driver-version.f90
@@ -9,7 +9,7 @@
 ! VERSION-NEXT: Thread model:
 ! VERSION-NEXT: InstalledDir:
 
-! ERROR: flang-new: error: unsupported option '--versions'; did you mean 
'--version'?
+! ERROR: flang-new: error: unknown argument '--versions'; did you mean 
'--version'?
 
 ! VERSION-FC1: LLVM version
 
Index: clang/test/Driver/unsupported-option.c
===
--- clang/test/Driver/unsupported-option.c
+++ clang/test/Driver/unsupported-option.c
@@ -1,10 +1,10 @@
 // RUN: not %clang %s --hedonism -### 2>&1 | \
 // RUN: FileCheck %s
-// CHECK: error: unsupported option '--hedonism'
+// CHECK: error: unknown argument: '--hedonism'
 
 // RUN: not %clang %s --hell -### 2>&1 | \
 // RUN: FileCheck %s --check-prefix=DID-YOU-MEAN
-// DID-YOU-MEAN: error: unsupported option '--hell'; did you mean '--help'?
+// DID-YOU-MEAN: error: unknown argument '--hell'; did you mean '--help'?
 
 // RUN: not %clang --target=powerpc-ibm-aix %s -mlong-double-128 2>&1 | \
 // RUN: FileCheck %s --check-prefix=AIX-LONGDOUBLE128-ERR
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -286,19 +286,9 @@
   // Check for unsupported options.
   for (const Arg *A : Args) {
 if (A->getOption().hasFlag(options::Unsupported)) {
-  unsigned DiagID;
-  auto ArgString = A->getAsString(Args);
-  std::string Nearest;
-  if (getOpts().findNearest(
-ArgString, Nearest, IncludedFlagsBitmask,
-ExcludedFlagsBitmask | options::Unsupported) > 1) {
-DiagID = diag::err_drv_unsupported_opt;
-Diag(DiagID) << ArgString;
-  } else {
-DiagID = diag::err_drv_unsupported_opt_with_suggestion;
-Diag(DiagID) << ArgString << Nearest;
-  }
-  ContainsError |= Diags.getDiagnosticLevel(DiagID, SourceLocation()) >
+  Diag(diag::err_drv_unsupported_opt) << A->getAsString(Args);
+  ContainsError |= Diags.getDiagnosticLevel(diag::err_drv_unsupported_opt,
+SourceLocation()) >
DiagnosticsEngine::Warning;
   continue;
 }
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4773,7 +4773,6 @@
 def _warn_ : Joined<["--"], "warn-">, Alias;
 def _write_dependencies : Flag<["--"], "write-dependencies">, Alias;
 def _write_user_dependencies : Flag<["--"], "write-user-dependencies">, 
Alias;
-def _ : Joined<["--"], "">, Flags<[Unsupported]>;
 
 // Hexagon feature flags.
 let Flags = [TargetSpecific] in {


Index: flang/test/Driver/driver-version.f90
===
--- flang/test/Driver/driver-version.f90
+++ flang/test/Driver/driver-version.f90
@@ -9,7 +9,7 @@
 ! VERSION-NEXT: Thread model:
 ! VERSION-NEXT: InstalledDir:
 
-! ERROR: flang-new: error: unsupported option '--versions'; did you mean '--version'?
+! ERROR: flang-new: error: unknown argument '--versions'; did you mean '--version'?
 
 ! VERSION-FC1: LLVM version
 
Index: clang/test/Driver/unsupported-option.c
===
--- clang/test/Driver/unsupported-option.c
+++ clang/test/Driver/unsupported-option.c
@@ -1,10 +1,10 @@
 // RUN: not %clang %s --hedonism -### 2>&1 | \
 // RUN: FileCheck %s
-// CHECK: error: unsupported option '--hedonism'
+// CHECK: error: unknown argument: '--hedonism'
 
 // RUN: not %clang %s --hell -### 2>&1 | \
 // RUN: FileCheck %s --check-prefix=DID-YOU-MEAN
-// DID-YOU-MEAN: error: unsupported option '--hell'; did you m

[PATCH] D156363: [Driver] -###: exit with code 1 if hasErrorOccurred

2023-08-02 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D156363#4554693 , @jhuber6 wrote:

> In D156363#4554687 , @yaxunl wrote:
>
>> In D156363#4554435 , @jhuber6 
>> wrote:
>>
>>>   Clang :: Driver/amdgpu-hip-system-arch.c
>>>   Clang :: Driver/cuda-bad-arch.cu
>>>   Clang :: Driver/hip-autolink.hip
>>>   Clang :: Driver/hip-binding.hip
>>>   Clang :: Driver/hip-cuid-hash.hip
>>>   Clang :: Driver/hip-cuid.hip
>>>   Clang :: Driver/hip-default-gpu-arch.hip
>>>   Clang :: Driver/hip-device-compile.hip
>>>   Clang :: Driver/hip-host-cpu-features.hip
>>>   Clang :: Driver/hip-launch-api.hip
>>>   Clang :: Driver/hip-link-bc-to-bc.hip
>>>   Clang :: Driver/hip-link-bundle-archive.hip
>>>   Clang :: Driver/hip-no-device-libs.hip
>>>   Clang :: Driver/hip-options.hip
>>>   Clang :: Driver/hip-output-file-name.hip
>>>   Clang :: Driver/hip-printf.hip
>>>   Clang :: Driver/hip-save-temps.hip
>>>   Clang :: Driver/hip-std.hip
>>>   Clang :: Driver/hip-syntax-only.hip
>>>   Clang :: Driver/hip-toolchain-dwarf.hip
>>>   Clang :: Driver/hip-toolchain-features.hip
>>>   Clang :: Driver/hip-toolchain-mllvm.hip
>>>   Clang :: Driver/hip-toolchain-opt.hip
>>>   Clang :: Driver/lto.cu
>>>   Clang :: Driver/openmp-offload-gpu.c
>>>   Clang :: Driver/openmp-offload-infer.c
>>>   Clang :: Driver/rocm-detect.hip
>>>
>>> These are the tests I'm seeing fail locally.
>>
>> These tests fail because the lit tests expect clang driver to run without 
>> ROCm.
>>
>> I will update these tests so that they pass on systems with or w/o ROCm.
>
> I've got a patch half done that mostly adds `-nogpuinc` to all these run 
> lines.

Thanks. I will wait for your patch. You can leave the tricky ones to me if you 
would like. e.g. the rocm-detect.hip


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156363

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


[PATCH] D156363: [Driver] -###: exit with code 1 if hasErrorOccurred

2023-08-02 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D156363#4554812 , @jhuber6 wrote:

> In D156363#4554790 , @ro wrote:
>
>> In D156363#4553043 , @ro wrote:
>>
>>> It seems the latest commit of this patch has (re-)introduced two failures 
>>> on the Solaris/amd64 buildbot 
>>> :
>>>
>>>   FAIL: Clang::clang_f_opts.c
>>>   FAIL: Clang::lto.c
>>>
>>> I cannot really make sense of that.
>>
>> I think I found it: running the matching '*.script' files under `bash -x` 
>> shows the tests ending with:
>>
>> - for `clang_f_lto.c`:
>>
>>   + : 'RUN: at line 117'
>>   + /var/llvm/local-amd64-debug-stage2/tools/clang/stage2-bins/bin/clang 
>> -### -flto -forder-file-instrumentation 
>> /vol/llvm/src/llvm-project/local/clang/test/Driver/clang_f_opts.c
>>   + /var/llvm/local-amd64-debug-stage2/tools/clang/stage2-bins/bin/FileCheck 
>> -check-prefix=CHECK-ORDERFILE-INSTR-LTO 
>> /vol/llvm/src/llvm-project/local/clang/test/Driver/clang_f_opts.c
>>
>> - for `lto.c`, it's similar:
>>
>>   + : 'RUN: at line 19'
>>   + /var/llvm/local-amd64-debug-stage2/tools/clang/stage2-bins/bin/clang 
>> /vol/llvm/src/llvm-project/local/clang/test/Driver/lto.c -flto -save-temps 
>> -###
>>   ro@niers 79 > 
>> /var/llvm/local-amd64-debug-stage2/tools/clang/stage2-bins/bin/clan
>>
>> Manually re-running `clang` gives
>>
>>   clang: error: 'amd64-pc-solaris2.11': unable to pass LLVM bit-code files 
>> to linker
>>
>> in both cases.
>
> Probably because we're not specifying the `--target=` I'll add that in my fix 
> for AMDGPU I'm working on and see if it solves the problem.

Thank you for fixing these tests. I agree that clang_f_opts.c:117 with `-flto` 
needs a `--target=`, to not cause this error on `amd64-pc-solaris2.11'`.
This should be the only line. I unfortunately did not catch this because I do 
not have access to a target using `HasNativeLLVMSupport` == false`.

For the AMDGPU tests, I do not have local ROCm, so I am unable to catch the 
issues. I have managed to fix many others before relanding this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156363

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


[PATCH] D76096: [clang] allow const structs/unions/arrays to be constant expressions for C

2023-08-02 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

In D76096#4540442 , @nickdesaulniers 
wrote:

> Consider the following code:
>
>   long x [] = {1, 2, 3, 4, 5 + 4};
>
> Even with some of my recent changes, because the fast path parallel 
> implementation doesn't currently handle BinaryOperator Exprs, we'll visit all 
> of the ImplicitCastExpr and IntegerLiteral, then eventually figure out that 
> we can't constant evaluate the final element (for the wrong reasons; i.e. 
> VisitBinaryOperator not implemented).  That's a slow down because then we'll 
> fall back to EvaluateAsLValue/EvaluateAsRValue which will then succeed.
>
> So we pretty much need a fair amount of parallel implementation for the fast 
> path to succeed.  I'm happy to implement all that, if that's the direction 
> you're advising?
>
> Or did you mean something else when you said "for structs and arrays?"

The given example doesn't fallback in the "bad" way: we don't create an APValue 
representing `x[]`.  If you look at the code for lowering InitListExpr, you'll 
note that it doesn't actually just recursively Visit() like we do in other 
places.  We do create an lvalue for "5+4", but that isn't expensive in the same 
way.

> Is there another way I can prove the absence of regression to you?

At this point, I'm basically convinced the regressions are only going to be in 
obscure cases we aren't going to find by benchmarking.  I'm sure someone will 
find them eventually, but we can deal with them as they come up, I think.

So LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76096

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


[PATCH] D138810: [RISCV] Support vector crypto extension C intrinsics

2023-08-02 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:4496
 
+static bool CheckInValidEGW(const TargetInfo &TI, CallExpr *TheCall, Sema &S,
+QualType Type, int EGW) {

InValid -> Invalid



Comment at: clang/lib/Sema/SemaChecking.cpp:4499
+  assert((EGW == 128 || EGW == 256) && "EGW can only be 128 or 256 bits");
+  llvm::SmallVector> ValidPairs128 =
+  {{1, "zvl256b"}, {2, "zvl128b"}, {4, "zvl64b"}};

Can this be a plain array or a std::array instead of SmallVector since the size 
is fixed.



Comment at: clang/lib/Sema/SemaChecking.cpp:4693
+  }
+  case RISCVVector::BI__builtin_rvv_vaesdf_vv:
+  case RISCVVector::BI__builtin_rvv_vaesdf_vs:

Are there `tu` versions of these builtins?



Comment at: clang/test/Sema/zvk-invalid.c:19
+  __riscv_vaesdf_vv_u32mf2(vd, vs2, vl); // expected-error {{RISC-V type 
'vuint32mf2_t' (aka '__rvv_uint32mf2_t') requires the 'zvl256b' extension}}
+}

Test a _vs intrinsic since the vs operand has a different type than the result?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138810

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


[PATCH] D155809: [NFC] [Clang] Fix strict weak ordering in ItaniumVTableBuilder

2023-08-02 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

I think `assert((A == B || (A->getOverloadedOperator() == OO_EqualEqual && 
B->getOverloadedOperator() == OO_EqualEqual)) && ...);` would look better , but 
the current form is fine as well.

> You will see 2 failures in 
> llvm/llvm-project/clang/test/CodeGen:available-externally-hidden.cpp.test and 
> llvm/llvm-project/clang/test/CodeGenCXX:cxx2a-three-way-comparison.cpp.test (

This is the gist and I think it should have been included in the patch 
summary/git message, so that readers can get the information from the commit 
message, not just by reading the long discussions on this page.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155809

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


[PATCH] D156363: [Driver] -###: exit with code 1 if hasErrorOccurred

2023-08-02 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D156363#4554790 , @ro wrote:

> In D156363#4553043 , @ro wrote:
>
>> It seems the latest commit of this patch has (re-)introduced two failures on 
>> the Solaris/amd64 buildbot 
>> :
>>
>>   FAIL: Clang::clang_f_opts.c
>>   FAIL: Clang::lto.c
>>
>> I cannot really make sense of that.
>
> I think I found it: running the matching '*.script' files under `bash -x` 
> shows the tests ending with:
>
> - for `clang_f_lto.c`:
>
>   + : 'RUN: at line 117'
>   + /var/llvm/local-amd64-debug-stage2/tools/clang/stage2-bins/bin/clang -### 
> -flto -forder-file-instrumentation 
> /vol/llvm/src/llvm-project/local/clang/test/Driver/clang_f_opts.c
>   + /var/llvm/local-amd64-debug-stage2/tools/clang/stage2-bins/bin/FileCheck 
> -check-prefix=CHECK-ORDERFILE-INSTR-LTO 
> /vol/llvm/src/llvm-project/local/clang/test/Driver/clang_f_opts.c
>
> - for `lto.c`, it's similar:
>
>   + : 'RUN: at line 19'
>   + /var/llvm/local-amd64-debug-stage2/tools/clang/stage2-bins/bin/clang 
> /vol/llvm/src/llvm-project/local/clang/test/Driver/lto.c -flto -save-temps 
> -###
>   ro@niers 79 > 
> /var/llvm/local-amd64-debug-stage2/tools/clang/stage2-bins/bin/clan
>
> Manually re-running `clang` gives
>
>   clang: error: 'amd64-pc-solaris2.11': unable to pass LLVM bit-code files to 
> linker
>
> in both cases.

Probably because we're not specifying the `--target=` I'll add that in my fix 
for AMDGPU I'm working on and see if it solves the problem.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156363

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


  1   2   3   >