[PATCH] D122542: [flang][driver] Make --version and -version consistent with clang

2022-03-27 Thread Emil Kieri via Phabricator via cfe-commits
ekieri created this revision.
ekieri added reviewers: PeteSteinfeld, awarzynski.
Herald added a reviewer: sscalpone.
Herald added projects: Flang, All.
ekieri requested review of this revision.
Herald added subscribers: cfe-commits, jdoerfert.
Herald added a project: clang.

This patch makes -version valid, and --version invalid, for
flang-new -fc1. The invocation

  flang-new --version

remains valid. This behaviour is consistent with clang
(and with clang -cc1 and clang -cc1as).

Previously, flang-new -fc1 accepted --version (as per Options.td), but
the frontend driver acutally checks for -version. As a result,

  flang-new -fc1 --version

triggered no action, emitted no messaged, and stalled waiting for
standard input.

Fixes #51438


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122542

Files:
  clang/include/clang/Driver/Options.td
  flang/test/Driver/driver-help.f90
  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
@@ -2,15 +2,21 @@
 !---
 ! RUN LINES
 !---
-! RUN: %flang --version 2>&1 | FileCheck %s
+! RUN: %flang --version 2>&1 | FileCheck %s --check-prefix=VERSION
 ! RUN: not %flang --versions 2>&1 | FileCheck %s --check-prefix=ERROR
+! RUN: %flang_fc1 -version 2>&1 | FileCheck %s --check-prefix=VERSION-FC1
+! RUN: not %flang_fc1 --version 2>&1 | FileCheck %s --check-prefix=ERROR-FC1
 
 !---
 ! EXPECTED OUTPUT
 !---
-! CHECK: flang-new version
-! CHECK-NEXT: Target:
-! CHECK-NEXT: Thread model:
-! CHECK-NEXT: InstalledDir:
+! VERSION: flang-new version
+! VERSION-NEXT: Target:
+! VERSION-NEXT: Thread model:
+! VERSION-NEXT: InstalledDir:
 
 ! ERROR: flang-new: error: unsupported option '--versions'; did you mean 
'--version'?
+
+! VERSION-FC1: LLVM version
+
+! ERROR-FC1: error: unknown argument '--version'; did you mean '-version'?
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -135,7 +135,7 @@
 ! HELP-FC1-NEXT: -test-io   Run the InputOuputTest action. Use for 
development and testing only.
 ! HELP-FC1-NEXT: -triple Specify target triple (e.g. 
i686-apple-darwin9)
 ! HELP-FC1-NEXT: -U  Undefine macro 
-! HELP-FC1-NEXT: --version  Print version information
+! HELP-FC1-NEXT: -version   Print the compiler version
 ! HELP-FC1-NEXT: -WEnable the specified warning
 
 !---
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4203,7 +4203,7 @@
   HelpText<"Serialize compiler diagnostics to a file">;
 // We give --version different semantics from -version.
 def _version : Flag<["--"], "version">,
-  Flags<[CoreOption, FC1Option, FlangOption]>,
+  Flags<[CoreOption, FlangOption]>,
   HelpText<"Print version information">;
 def _signed_char : Flag<["--"], "signed-char">, Alias;
 def _std : Separate<["--"], "std">, Alias;
@@ -5747,11 +5747,16 @@
 // Language Options
 
//===--===//
 
-let Flags = [CC1Option, CC1AsOption, NoDriverOption] in {
+let Flags = [CC1Option, CC1AsOption, FC1Option, NoDriverOption] in {
 
 def version : Flag<["-"], "version">,
   HelpText<"Print the compiler version">,
   MarshallingInfoFlag>;
+
+}
+
+let Flags = [CC1Option, CC1AsOption, NoDriverOption] in {
+
 def main_file_name : Separate<["-"], "main-file-name">,
   HelpText<"Main file name to use for debug info and source if missing">,
   MarshallingInfoString>;


Index: flang/test/Driver/driver-version.f90
===
--- flang/test/Driver/driver-version.f90
+++ flang/test/Driver/driver-version.f90
@@ -2,15 +2,21 @@
 !---
 ! RUN LINES
 !---
-! RUN: %flang --version 2>&1 | FileCheck %s
+! RUN: %flang --version 2>&1 | FileCheck %s --check-prefix=VERSION
 ! RUN: not %flang --versions 2>&1 | FileCheck %s --check-prefix=ERROR
+! RUN: %flang_fc1 -version 2>&1 | FileCheck %s --check-prefix=VERSION-FC1
+! RUN: not %flang_fc1 --version 2>&1 | FileCheck %s --check-prefix=ERROR-FC1
 
 !---
 ! EXPECTED OUTPUT
 !---
-! CHECK: flang-new version
-! CHECK-NEXT: Target:
-! CHECK-NEXT: Thread model:
-! CHECK-NEXT: InstalledDir:
+! VERSION: flang-new version
+! VERSION-NEXT: Target:
+! VERSION-NEXT: Thread model:
+! VERSION-NEXT: InstalledDir:
 
 ! ERROR: flang-new: error: unsupported option '--versions'; did you mean '--version'?
+
+! VERSION-FC1: LLVM version
+
+! ERROR-FC1: error: unknown argument '--version'; did you mean '-version'?
Index: flang/tes

[clang] d9cea8d - [C++20][Modules][HU 4/5] Handle pre-processed header units.

2022-03-27 Thread Iain Sandoe via cfe-commits

Author: Iain Sandoe
Date: 2022-03-27T09:38:06+01:00
New Revision: d9cea8d3a8fff86672174780312674871729578c

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

LOG: [C++20][Modules][HU 4/5] Handle pre-processed header units.

We wish to support emitting a pre-processed output for an importable
header unit, that can be consumed to produce the same header units as
the original source.

This means that ee need to find the original filename used to produce
the re-preprocessed output, so that it can be assigned as the module
name.  This is peeked from the first line of the pre-processed source
when the action sets up the files.

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

Added: 
clang/test/Modules/cxx20-hu-05.cpp

Modified: 
clang/lib/Frontend/FrontendAction.cpp
clang/lib/Sema/SemaModule.cpp

Removed: 




diff  --git a/clang/lib/Frontend/FrontendAction.cpp 
b/clang/lib/Frontend/FrontendAction.cpp
index 68b823252130c..45245f3f0fef4 100644
--- a/clang/lib/Frontend/FrontendAction.cpp
+++ b/clang/lib/Frontend/FrontendAction.cpp
@@ -843,6 +843,21 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
   if (!CI.InitializeSourceManager(Input))
 return false;
 
+  if (CI.getLangOpts().CPlusPlusModules && Input.getKind().isHeaderUnit() &&
+  Input.getKind().isPreprocessed() && !usesPreprocessorOnly()) {
+// We have an input filename like foo.iih, but we want to find the right
+// module name (and original file, to build the map entry).
+// Check if the first line specifies the original source file name with a
+// linemarker.
+std::string PresumedInputFile = std::string(getCurrentFileOrBufferName());
+ReadOriginalFileName(CI, PresumedInputFile);
+// Unless the user overrides this, the module name is the name by which the
+// original file was known.
+if (CI.getLangOpts().ModuleName.empty())
+  CI.getLangOpts().ModuleName = std::string(PresumedInputFile);
+CI.getLangOpts().CurrentModule = CI.getLangOpts().ModuleName;
+  }
+
   // For module map files, we first parse the module map and synthesize a
   // "" buffer before more conventional processing.
   if (Input.getKind().getFormat() == InputKind::ModuleMap) {

diff  --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp
index e28de8c79b273..893b913194aae 100644
--- a/clang/lib/Sema/SemaModule.cpp
+++ b/clang/lib/Sema/SemaModule.cpp
@@ -109,10 +109,18 @@ void Sema::HandleStartOfHeaderUnit() {
 const_cast(getLangOpts()).CurrentModule = HUName.str();
   }
 
-  auto &Map = PP.getHeaderSearchInfo().getModuleMap();
   // TODO: Make the C++20 header lookup independent.
-  Module::Header H{getLangOpts().CurrentModule, getLangOpts().CurrentModule,
-   SourceMgr.getFileEntryForID(SourceMgr.getMainFileID())};
+  // When the input is pre-processed source, we need a file ref to the original
+  // file for the header map.
+  auto F = SourceMgr.getFileManager().getFile(HUName);
+  // For the sake of error recovery (if someone has moved the original header
+  // after creating the pre-processed output) fall back to obtaining the file
+  // ref for the input file, which must be present.
+  if (!F)
+F = SourceMgr.getFileEntryForID(SourceMgr.getMainFileID());
+  assert(F && "failed to find the header unit source?");
+  Module::Header H{HUName.str(), HUName.str(), *F};
+  auto &Map = PP.getHeaderSearchInfo().getModuleMap();
   Module *Mod = Map.createHeaderUnit(StartOfTU, HUName, H);
   assert(Mod && "module creation should not fail");
   ModuleScopes.push_back({}); // No GMF

diff  --git a/clang/test/Modules/cxx20-hu-05.cpp 
b/clang/test/Modules/cxx20-hu-05.cpp
new file mode 100644
index 0..b0d7c0f3c9e76
--- /dev/null
+++ b/clang/test/Modules/cxx20-hu-05.cpp
@@ -0,0 +1,32 @@
+// Test macro preservation in C++20 Header Units.
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+// RUN: cd %t
+
+// Produce a pre-processed file.
+// RUN: %clang_cc1 -std=c++20 -E -xc++-user-header hu-01.h -o hu-01.iih
+
+// consume that to produce the heder unit.
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit \
+// RUN: -xc++-header-unit-header-cpp-output hu-01.iih -o hu-01.pcm
+
+// check that the header unit is named for the original file, not the .iih.
+// RUN: %clang_cc1 -std=c++20 -module-file-info hu-01.pcm | \
+// RUN: FileCheck --check-prefix=CHECK-HU %s -DTDIR=%t
+
+//--- hu-01.h
+#ifndef __GUARD
+#define __GUARD
+
+int baz(int);
+#define FORTYTWO 42
+
+#define SHOULD_NOT_BE_DEFINED -1
+#undef SHOULD_NOT_BE_DEFINED
+
+#endif // __GUARD
+
+// CHECK-HU:  == C++20 Module structure ==
+// CHECK-HU-NEXT:  Header Unit './hu-01.h' is the Primary Module at index #1



___
cfe-com

[PATCH] D121098: [C++20][Modules][HU 4/5] Handle pre-processed header units.

2022-03-27 Thread Iain Sandoe via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd9cea8d3a8ff: [C++20][Modules][HU 4/5] Handle pre-processed 
header units. (authored by iains).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121098

Files:
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Sema/SemaModule.cpp
  clang/test/Modules/cxx20-hu-05.cpp


Index: clang/test/Modules/cxx20-hu-05.cpp
===
--- /dev/null
+++ clang/test/Modules/cxx20-hu-05.cpp
@@ -0,0 +1,32 @@
+// Test macro preservation in C++20 Header Units.
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+// RUN: cd %t
+
+// Produce a pre-processed file.
+// RUN: %clang_cc1 -std=c++20 -E -xc++-user-header hu-01.h -o hu-01.iih
+
+// consume that to produce the heder unit.
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit \
+// RUN: -xc++-header-unit-header-cpp-output hu-01.iih -o hu-01.pcm
+
+// check that the header unit is named for the original file, not the .iih.
+// RUN: %clang_cc1 -std=c++20 -module-file-info hu-01.pcm | \
+// RUN: FileCheck --check-prefix=CHECK-HU %s -DTDIR=%t
+
+//--- hu-01.h
+#ifndef __GUARD
+#define __GUARD
+
+int baz(int);
+#define FORTYTWO 42
+
+#define SHOULD_NOT_BE_DEFINED -1
+#undef SHOULD_NOT_BE_DEFINED
+
+#endif // __GUARD
+
+// CHECK-HU:  == C++20 Module structure ==
+// CHECK-HU-NEXT:  Header Unit './hu-01.h' is the Primary Module at index #1
Index: clang/lib/Sema/SemaModule.cpp
===
--- clang/lib/Sema/SemaModule.cpp
+++ clang/lib/Sema/SemaModule.cpp
@@ -109,10 +109,18 @@
 const_cast(getLangOpts()).CurrentModule = HUName.str();
   }
 
-  auto &Map = PP.getHeaderSearchInfo().getModuleMap();
   // TODO: Make the C++20 header lookup independent.
-  Module::Header H{getLangOpts().CurrentModule, getLangOpts().CurrentModule,
-   SourceMgr.getFileEntryForID(SourceMgr.getMainFileID())};
+  // When the input is pre-processed source, we need a file ref to the original
+  // file for the header map.
+  auto F = SourceMgr.getFileManager().getFile(HUName);
+  // For the sake of error recovery (if someone has moved the original header
+  // after creating the pre-processed output) fall back to obtaining the file
+  // ref for the input file, which must be present.
+  if (!F)
+F = SourceMgr.getFileEntryForID(SourceMgr.getMainFileID());
+  assert(F && "failed to find the header unit source?");
+  Module::Header H{HUName.str(), HUName.str(), *F};
+  auto &Map = PP.getHeaderSearchInfo().getModuleMap();
   Module *Mod = Map.createHeaderUnit(StartOfTU, HUName, H);
   assert(Mod && "module creation should not fail");
   ModuleScopes.push_back({}); // No GMF
Index: clang/lib/Frontend/FrontendAction.cpp
===
--- clang/lib/Frontend/FrontendAction.cpp
+++ clang/lib/Frontend/FrontendAction.cpp
@@ -843,6 +843,21 @@
   if (!CI.InitializeSourceManager(Input))
 return false;
 
+  if (CI.getLangOpts().CPlusPlusModules && Input.getKind().isHeaderUnit() &&
+  Input.getKind().isPreprocessed() && !usesPreprocessorOnly()) {
+// We have an input filename like foo.iih, but we want to find the right
+// module name (and original file, to build the map entry).
+// Check if the first line specifies the original source file name with a
+// linemarker.
+std::string PresumedInputFile = std::string(getCurrentFileOrBufferName());
+ReadOriginalFileName(CI, PresumedInputFile);
+// Unless the user overrides this, the module name is the name by which the
+// original file was known.
+if (CI.getLangOpts().ModuleName.empty())
+  CI.getLangOpts().ModuleName = std::string(PresumedInputFile);
+CI.getLangOpts().CurrentModule = CI.getLangOpts().ModuleName;
+  }
+
   // For module map files, we first parse the module map and synthesize a
   // "" buffer before more conventional processing.
   if (Input.getKind().getFormat() == InputKind::ModuleMap) {


Index: clang/test/Modules/cxx20-hu-05.cpp
===
--- /dev/null
+++ clang/test/Modules/cxx20-hu-05.cpp
@@ -0,0 +1,32 @@
+// Test macro preservation in C++20 Header Units.
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+// RUN: cd %t
+
+// Produce a pre-processed file.
+// RUN: %clang_cc1 -std=c++20 -E -xc++-user-header hu-01.h -o hu-01.iih
+
+// consume that to produce the heder unit.
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit \
+// RUN: -xc++-header-unit-header-cpp-output hu-01.iih -o hu-01.pcm
+
+// check that the header unit is named for the original file, not the .iih.
+// RUN: %clang_cc1 -std=c++20 -module-file-info hu-01.pcm | \
+// RUN: FileCheck --check-prefix=CHECK-HU %s -DTDIR=%t
+
+//--- hu-01.h
+#ifndef __GUARD
+#define __GUARD
+
+int baz(int);
+

[PATCH] D122533: [AVR] Remove AVRRelaxMemOperations

2022-03-27 Thread Ben Shi via Phabricator via cfe-commits
benshi001 added a comment.

I have built (with -DCMAKE_BUILD_TYPE=Debug) and tested your patch, but got the 
following failure

  FAIL: LLVM :: CodeGen/AVR/pseudo/STDWPtrQRr.mir (150 of 152)
   TEST 'LLVM :: CodeGen/AVR/pseudo/STDWPtrQRr.mir' FAILED 

  Script:
  --
  : 'RUN: at line 1';   /home/shiben/work/llvm-project/build-x/bin/llc -O0 
-run-pass=avr-expand-pseudo 
/home/shiben/work/llvm-project/llvm/test/CodeGen/AVR/pseudo/STDWPtrQRr.mir -o - 
| /home/shiben/work/llvm-project/build-x/bin/FileCheck 
/home/shiben/work/llvm-project/llvm/test/CodeGen/AVR/pseudo/STDWPtrQRr.mir
  --
  Exit Code: 2
  
  Command Output (stderr):
  --
  
  # After AVR pseudo instruction expansion pass
  # Machine code for function test: IsSSA, NoPHIs, TracksLiveness, NoVRegs
  
  bb.0.entry:
STDPtrQRr $r29r28, 3, $r0
STDPtrQRr $r29r28, 4, $r1
STDPtrQRr $r29r28, 3, $r0
STDPtrQRr killed $r29r28, 4, $r1
STDPtrQRr $r29r28, 3, killed $r0
STDPtrQRr $r29r28, 4, killed $r1
STDPtrQRr $r29r28, 62, $r0
STDPtrQRr $r29r28, 63, $r1
PUSHRr $r28, implicit-def $sp, implicit $sp
PUSHRr $r29, implicit-def $sp, implicit $sp
$r28 = SBCIRdK killed $r28(tied-def 0), 193, implicit-def $sreg, implicit 
killed $sreg
$r29 = SBCIRdK killed $r29(tied-def 0), 255, implicit-def $sreg, implicit 
killed $sreg
STPtrRr $r29r28, $r0
STDPtrQRr $r29r28, 1, $r1
$r29 = POPRd implicit-def $sp, implicit $sp
$r28 = POPRd implicit-def $sp, implicit $sp
$r28 = SBCIRdK killed $r28(tied-def 0), 193, implicit-def $sreg, implicit 
killed $sreg
$r29 = SBCIRdK killed $r29(tied-def 0), 255, implicit-def $sreg, implicit 
killed $sreg
STPtrRr $r29r28, $r0
STDPtrQRr $r29r28, 1, $r1
PUSHRr $r28, implicit-def $sp, implicit $sp
PUSHRr $r29, implicit-def $sp, implicit $sp
$r28 = SBCIRdK killed $r28(tied-def 0), 193, implicit-def $sreg, implicit 
killed $sreg
$r29 = SBCIRdK killed $r29(tied-def 0), 255, implicit-def $sreg, implicit 
killed $sreg
STPtrRr $r29r28, killed $r0
STDPtrQRr $r29r28, 1, killed $r1
$r29 = POPRd implicit-def $sp, implicit $sp
$r28 = POPRd implicit-def $sp, implicit $sp
  
  # End machine code for function test.
  
  *** Bad machine code: Using an undefined physical register ***
  - function:test
  - basic block: %bb.0 entry (0x563a083b79e8)
  - instruction: $r28 = SBCIRdK killed $r28(tied-def 0), 193, implicit-def 
$sreg, implicit killed $sreg
  - operand 4:   implicit killed $sreg
  LLVM ERROR: Found 1 machine code errors.
  PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ 
and include the crash backtrace.
  Stack dump:
  0.  Program arguments: /home/shiben/work/llvm-project/build-x/bin/llc -O0 
-run-pass=avr-expand-pseudo 
/home/shiben/work/llvm-project/llvm/test/CodeGen/AVR/pseudo/STDWPtrQRr.mir -o -
  1.  Running pass 'Function Pass Manager' on module 
'/home/shiben/work/llvm-project/llvm/test/CodeGen/AVR/pseudo/STDWPtrQRr.mir'.
  2.  Running pass 'Verify generated machine code' on function '@test'
   #0 0x563a036e61a8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
/home/shiben/work/llvm-project/llvm/lib/Support/Unix/Signals.inc:565:0
   #1 0x563a036e625f PrintStackTraceSignalHandler(void*) 
/home/shiben/work/llvm-project/llvm/lib/Support/Unix/Signals.inc:632:0
   #2 0x563a036e3e22 llvm::sys::RunSignalHandlers() 
/home/shiben/work/llvm-project/llvm/lib/Support/Signals.cpp:103:0
   #3 0x563a036e5b29 SignalHandler(int) 
/home/shiben/work/llvm-project/llvm/lib/Support/Unix/Signals.inc:407:0
   #4 0x7f1480842980 __restore_rt 
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
   #5 0x7f147f4f2e87 raise 
/build/glibc-uZu3wS/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
   #6 0x7f147f4f47f1 abort 
/build/glibc-uZu3wS/glibc-2.27/stdlib/abort.c:81:0
   #7 0x563a036202ea llvm::install_bad_alloc_error_handler(void (*)(void*, 
char const*, bool), void*) 
/home/shiben/work/llvm-project/llvm/lib/Support/ErrorHandling.cpp:126:0
   #8 0x563a026cec3f (anonymous 
namespace)::MachineVerifierPass::runOnMachineFunction(llvm::MachineFunction&) 
/home/shiben/work/llvm-project/llvm/lib/CodeGen/MachineVerifier.cpp:307:0
   #9 0x563a0259c657 
llvm::MachineFunctionPass::runOnFunction(llvm::Function&) 
/home/shiben/work/llvm-project/llvm/lib/CodeGen/MachineFunctionPass.cpp:73:0
  #10 0x563a02c7f2b3 llvm::FPPassManager::runOnFunction(llvm::Function&) 
/home/shiben/work/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1430:0
  #11 0x563a02c7f633 llvm::FPPassManager::runOnModule(llvm::Module&) 
/home/shiben/work/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1476:0
  #12 0x563a02c7fa7b (anonymous 
namespace)::MPPassManager::runOnModule(llvm::Module&) 
/home/shiben/work/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1545:0
  #13 0x563a02c7a95b llvm::legacy::PassManagerImpl::run(llvm::Module&) 
/home/shiben/work/llvm-project/llvm/li

[PATCH] D122533: [AVR] Remove AVRRelaxMemOperations

2022-03-27 Thread Patryk Wychowaniec via Phabricator via cfe-commits
Patryk27 added a comment.

Hmm, that's weird - I've just re-checked and everything's working correctly on 
my side; maybe you're testing it on an older LLVM revision? (for reference, my 
patch is based off of the current LLVM's main branch, which - at the time of 
writing this comment - is the d9cea8d3a8fff86672174780312674871729578c 
 commit).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122533

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


[PATCH] D122533: [AVR] Remove AVRRelaxMemOperations

2022-03-27 Thread Ben Shi via Phabricator via cfe-commits
benshi001 added inline comments.



Comment at: llvm/lib/Target/AVR/AVRExpandPseudoInsts.cpp:1174
 
-  auto MIBLO = buildMI(MBB, MBBI, OpLo)
-   .addReg(DstReg)
-   .addImm(Imm)
-   .addReg(SrcLoReg, getKillRegState(SrcIsKill));
+buildMI(MBB, MBBI, AVR::SBCIWRdK)
+.addReg(DstReg, RegState::Define)

The above built error is caused by this line, this should be a SUBI other than 
a SBCI.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122533

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


[PATCH] D122533: [AVR] Remove AVRRelaxMemOperations

2022-03-27 Thread Ben Shi via Phabricator via cfe-commits
benshi001 added a comment.

In D122533#3410064 , @Patryk27 wrote:

> Hmm, that's weird - I've just re-checked and everything's working correctly 
> on my side; maybe you're testing it on an older LLVM revision? (for 
> reference, my patch is based off of the current LLVM's main branch, which - 
> at the time of writing this comment - is the 
> d9cea8d3a8fff86672174780312674871729578c 
>  commit).

I tested based on 
https://github.com/llvm/llvm-project/commit/674d52e8ced27bf427b3ea2c763a566ca9b8212a,
 which is also today's (March 27) revision. Did you build LLVM with 
-DCMAKE_BUILD_TYPE=Debug , it seems only debug version of llvm will get this 
issue be triggered.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122533

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


[PATCH] D122533: [AVR] Remove AVRRelaxMemOperations

2022-03-27 Thread Patryk Wychowaniec via Phabricator via cfe-commits
Patryk27 added inline comments.



Comment at: llvm/lib/Target/AVR/AVRExpandPseudoInsts.cpp:1174
 
-  auto MIBLO = buildMI(MBB, MBBI, OpLo)
-   .addReg(DstReg)
-   .addImm(Imm)
-   .addReg(SrcLoReg, getKillRegState(SrcIsKill));
+buildMI(MBB, MBBI, AVR::SBCIWRdK)
+.addReg(DstReg, RegState::Define)

benshi001 wrote:
> The above built error is caused by this line, this should be a SUBI other 
> than a SBCI.
Out of curiosity, why SUBI? (just trying to understand what is the difference 
between both)

It looks like currently - 
https://github.com/llvm/llvm-project/blob/d9cea8d3a8fff86672174780312674871729578c/llvm/lib/Target/AVR/AVRRelaxMemOperations.cpp#L101
 - we expand to SBCI.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122533

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


[PATCH] D122533: [AVR] Remove AVRRelaxMemOperations

2022-03-27 Thread Ben Shi via Phabricator via cfe-commits
benshi001 added inline comments.



Comment at: llvm/test/CodeGen/AVR/pseudo/STDWPtrQRr.mir:1
-# RUN: llc -O0 -run-pass=avr-expand-pseudo  %s -o - | FileCheck %s
+# RUN: llc -O0 -run-pass=avr-expand-pseudo %s -o - | FileCheck %s
 

You can trigger the bug, with `-verify-machineinstrs` option after the 
`-run-pass=avr-expand-pseudo` option.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122533

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


[PATCH] D122533: [AVR] Remove AVRRelaxMemOperations

2022-03-27 Thread Patryk Wychowaniec via Phabricator via cfe-commits
Patryk27 added a comment.

I think I'm using `=Release` instead of `=Debug`, that would explain the 
difference, yeah;


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122533

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


[PATCH] D122533: [AVR] Remove AVRRelaxMemOperations

2022-03-27 Thread Ben Shi via Phabricator via cfe-commits
benshi001 added inline comments.



Comment at: llvm/lib/Target/AVR/AVRExpandPseudoInsts.cpp:1174
 
-  auto MIBLO = buildMI(MBB, MBBI, OpLo)
-   .addReg(DstReg)
-   .addImm(Imm)
-   .addReg(SrcLoReg, getKillRegState(SrcIsKill));
+buildMI(MBB, MBBI, AVR::SBCIWRdK)
+.addReg(DstReg, RegState::Define)

Patryk27 wrote:
> benshi001 wrote:
> > The above built error is caused by this line, this should be a SUBI other 
> > than a SBCI.
> Out of curiosity, why SUBI? (just trying to understand what is the difference 
> between both)
> 
> It looks like currently - 
> https://github.com/llvm/llvm-project/blob/d9cea8d3a8fff86672174780312674871729578c/llvm/lib/Target/AVR/AVRRelaxMemOperations.cpp#L101
>  - we expand to SBCI.
I thought this should be an old bug which has never been triggered. Actually if 
C bit in SREG is set before current `STWPtrPdRr`, then it is sure to run into  
wrong.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122533

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


[PATCH] D122533: [AVR] Remove AVRRelaxMemOperations

2022-03-27 Thread Ben Shi via Phabricator via cfe-commits
benshi001 added a comment.

In D122533#3410072 , @Patryk27 wrote:

> I think I'm using `=Release` instead of `=Debug`, that would explain the 
> difference, yeah;

You need not Debug, just add `-verify-machineinstrs` option after the 
`-run-pass=avr-expand-pseudo`, then the bug will also be triggered.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122533

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


[PATCH] D122533: [AVR] Remove AVRRelaxMemOperations

2022-03-27 Thread Patryk Wychowaniec via Phabricator via cfe-commits
Patryk27 updated this revision to Diff 418443.
Patryk27 added a comment.

SBCI -> SUBI


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122533

Files:
  clang/docs/tools/clang-formatted-files.txt
  llvm/lib/Target/AVR/AVR.h
  llvm/lib/Target/AVR/AVRExpandPseudoInsts.cpp
  llvm/lib/Target/AVR/AVRRelaxMemOperations.cpp
  llvm/lib/Target/AVR/AVRTargetMachine.cpp
  llvm/lib/Target/AVR/CMakeLists.txt
  llvm/test/CodeGen/AVR/pseudo/STDWPtrQRr.mir
  llvm/test/CodeGen/AVR/relax-mem/STDWPtrQRr.mir
  llvm/utils/gn/secondary/llvm/lib/Target/AVR/BUILD.gn

Index: llvm/utils/gn/secondary/llvm/lib/Target/AVR/BUILD.gn
===
--- llvm/utils/gn/secondary/llvm/lib/Target/AVR/BUILD.gn
+++ llvm/utils/gn/secondary/llvm/lib/Target/AVR/BUILD.gn
@@ -37,7 +37,6 @@
 "AVRInstrInfo.cpp",
 "AVRMCInstLower.cpp",
 "AVRRegisterInfo.cpp",
-"AVRRelaxMemOperations.cpp",
 "AVRShiftExpand.cpp",
 "AVRSubtarget.cpp",
 "AVRTargetMachine.cpp",
Index: llvm/test/CodeGen/AVR/relax-mem/STDWPtrQRr.mir
===
--- llvm/test/CodeGen/AVR/relax-mem/STDWPtrQRr.mir
+++ /dev/null
@@ -1,31 +0,0 @@
-# RUN: llc -O0 -run-pass=avr-relax-mem %s -o - | FileCheck %s
-
 |
-  target triple = "avr--"
-  define void @test() {
-  entry:
-ret void
-  }
-...
-

-name:test
-body: |
-  bb.0.entry:
-
-; CHECK-LABEL: test
-
-; We shouldn't expand things which already have 6-bit imms.
-; CHECK: STDWPtrQRr $r29r28, 63, $r1r0
-STDWPtrQRr $r29r28, 63, $r1r0
-
-; We shouldn't expand things which already have 6-bit imms.
-; CHECK-NEXT: STDWPtrQRr $r29r28, 0, $r1r0
-STDWPtrQRr $r29r28, 0, $r1r0
-
-; CHECK-NEXT: PUSHWRr $r29r28, implicit-def $sp, implicit $sp
-; CHECK-NEXT: $r29r28 = SBCIWRdK $r29r28, -64, implicit-def $sreg, implicit $sreg
-; CHECK-NEXT: STWPtrRr $r29r28, $r1r0
-; CHECK-NEXT: $r29r28 = POPWRd implicit-def $sp, implicit $sp
-STDWPtrQRr $r29r28, 64, $r1r0
-...
Index: llvm/test/CodeGen/AVR/pseudo/STDWPtrQRr.mir
===
--- llvm/test/CodeGen/AVR/pseudo/STDWPtrQRr.mir
+++ llvm/test/CodeGen/AVR/pseudo/STDWPtrQRr.mir
@@ -1,4 +1,4 @@
-# RUN: llc -O0 -run-pass=avr-expand-pseudo  %s -o - | FileCheck %s
+# RUN: llc -O0 -run-pass=avr-expand-pseudo %s -o - | FileCheck %s
 
 --- |
   target triple = "avr--"
@@ -15,8 +15,52 @@
 
 ; CHECK-LABEL: test
 
-; CHECK:  STDPtrQRr $r29r28, 10, $r0
-; CHECK-NEXT: STDPtrQRr $r29r28, 11, $r1
+; Small displacement (<63):
+; CHECK:  STDPtrQRr $r29r28, 3, $r0
+; CHECK-NEXT: STDPtrQRr $r29r28, 4, $r1
+STDWPtrQRr $r29r28, 3, $r1r0
 
-STDWPtrQRr $r29r28, 10, $r1r0
+; Small displacement where the destination register is killed:
+; CHECK:  STDPtrQRr $r29r28, 3, $r0
+; CHECK-NEXT: STDPtrQRr killed $r29r28, 4, $r1
+STDWPtrQRr killed $r29r28, 3, $r1r0
+
+; Small displacement where the source register is killed:
+; CHECK:  STDPtrQRr $r29r28, 3, killed $r0
+; CHECK-NEXT: STDPtrQRr $r29r28, 4, killed $r1
+STDWPtrQRr $r29r28, 3, killed $r1r0
+
+; Small displacement, near the limit (=62):
+; CHECK:  STDPtrQRr $r29r28, 62, $r0
+; CHECK-NEXT: STDPtrQRr $r29r28, 63, $r1
+STDWPtrQRr $r29r28, 62, $r1r0
+
+; Large displacement (>=63):
+; CHECK: PUSHRr $r28, implicit-def $sp, implicit $sp
+; CHECK-NEXT: PUSHRr $r29, implicit-def $sp, implicit $sp
+; CHECK-NEXT: $r28 = SUBIRdK killed $r28, 193, implicit-def $sreg
+; CHECK-NEXT: $r29 = SBCIRdK killed $r29, 255, implicit-def $sreg, implicit killed $sreg
+; CHECK-NEXT: STPtrRr $r29r28, $r0
+; CHECK-NEXT: STDPtrQRr $r29r28, 1, $r1
+; CHECK-NEXT: $r29 = POPRd implicit-def $sp, implicit $sp
+; CHECK-NEXT: $r28 = POPRd implicit-def $sp, implicit $sp
+STDWPtrQRr $r29r28, 63, $r1r0
+
+; Large displacement where the destination register is killed:
+; CHECK: $r28 = SUBIRdK killed $r28, 193, implicit-def $sreg
+; CHECK-NEXT: $r29 = SBCIRdK killed $r29, 255, implicit-def $sreg, implicit killed $sreg
+; CHECK-NEXT: STPtrRr $r29r28, $r0
+; CHECK-NEXT: STDPtrQRr $r29r28, 1, $r1
+STDWPtrQRr killed $r29r28, 63, $r1r0
+
+; Large displacement where the source register is killed:
+; CHECK: PUSHRr $r28, implicit-def $sp, implicit $sp
+; CHECK-NEXT: PUSHRr $r29, implicit-def $sp, implicit $sp
+; CHECK-NEXT: $r28 = SUBIRdK killed $r28, 193, implicit-def $sreg
+; CHECK-NEXT: $r29 = SBCIRdK killed $r29, 255, implicit-def $sreg, implicit killed $sreg
+; CHECK-NEXT: STPtrRr $r29r28, killed $r0
+; CHECK-NEXT: STDPtrQRr $r29r28, 1, killed $r1
+; CHECK-NEXT: $r29 = POPRd implicit-def $sp, implicit $sp
+; CHECK-NEXT: $r28 = POPRd implicit-def $sp, implicit $sp
+STDWPtrQRr $r29r28, 63, kille

[PATCH] D122533: [AVR] Remove AVRRelaxMemOperations

2022-03-27 Thread Ben Shi via Phabricator via cfe-commits
benshi001 added inline comments.



Comment at: llvm/lib/Target/AVR/AVRExpandPseudoInsts.cpp:1174
 
-  auto MIBLO = buildMI(MBB, MBBI, OpLo)
-   .addReg(DstReg)
-   .addImm(Imm)
-   .addReg(SrcLoReg, getKillRegState(SrcIsKill));
+buildMI(MBB, MBBI, AVR::SBCIWRdK)
+.addReg(DstReg, RegState::Define)

benshi001 wrote:
> Patryk27 wrote:
> > benshi001 wrote:
> > > The above built error is caused by this line, this should be a SUBI other 
> > > than a SBCI.
> > Out of curiosity, why SUBI? (just trying to understand what is the 
> > difference between both)
> > 
> > It looks like currently - 
> > https://github.com/llvm/llvm-project/blob/d9cea8d3a8fff86672174780312674871729578c/llvm/lib/Target/AVR/AVRRelaxMemOperations.cpp#L101
> >  - we expand to SBCI.
> I thought this should be an old bug which has never been triggered. Actually 
> if C bit in SREG is set before current `STWPtrPdRr`, then it is sure to run 
> into  wrong.
Sorry, I think this should be a SUBIW, neither SBCIW nor SUBI.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122533

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


[PATCH] D122533: [AVR] Remove AVRRelaxMemOperations

2022-03-27 Thread Patryk Wychowaniec via Phabricator via cfe-commits
Patryk27 marked 2 inline comments as done.
Patryk27 added inline comments.



Comment at: llvm/lib/Target/AVR/AVRExpandPseudoInsts.cpp:1174
 
-  auto MIBLO = buildMI(MBB, MBBI, OpLo)
-   .addReg(DstReg)
-   .addImm(Imm)
-   .addReg(SrcLoReg, getKillRegState(SrcIsKill));
+buildMI(MBB, MBBI, AVR::SBCIWRdK)
+.addReg(DstReg, RegState::Define)

benshi001 wrote:
> benshi001 wrote:
> > Patryk27 wrote:
> > > benshi001 wrote:
> > > > The above built error is caused by this line, this should be a SUBI 
> > > > other than a SBCI.
> > > Out of curiosity, why SUBI? (just trying to understand what is the 
> > > difference between both)
> > > 
> > > It looks like currently - 
> > > https://github.com/llvm/llvm-project/blob/d9cea8d3a8fff86672174780312674871729578c/llvm/lib/Target/AVR/AVRRelaxMemOperations.cpp#L101
> > >  - we expand to SBCI.
> > I thought this should be an old bug which has never been triggered. 
> > Actually if C bit in SREG is set before current `STWPtrPdRr`, then it is 
> > sure to run into  wrong.
> Sorry, I think this should be a SUBIW, neither SBCIW nor SUBI.
Right, great catch - fixed!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122533

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


[PATCH] D122533: [AVR] Remove AVRRelaxMemOperations

2022-03-27 Thread Patryk Wychowaniec via Phabricator via cfe-commits
Patryk27 added a comment.

Ah, sorry - I've pushed my changes at the same time you created your comment; 
one moment, let me change to SUBIW, then.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122533

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


[PATCH] D122533: [AVR] Remove AVRRelaxMemOperations

2022-03-27 Thread Patryk Wychowaniec via Phabricator via cfe-commits
Patryk27 added a comment.

Ah, nevermind - looks like I've already actually used `SUBIWRdK`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122533

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


[PATCH] D122533: [AVR] Remove AVRRelaxMemOperations

2022-03-27 Thread Ben Shi via Phabricator via cfe-commits
benshi001 added inline comments.



Comment at: llvm/test/CodeGen/AVR/pseudo/STDWPtrQRr.mir:1
-# RUN: llc -O0 -run-pass=avr-expand-pseudo  %s -o - | FileCheck %s
+# RUN: llc -O0 -run-pass=avr-expand-pseudo %s -o - | FileCheck %s
 

benshi001 wrote:
> You can trigger the bug, with `-verify-machineinstrs` option after the 
> `-run-pass=avr-expand-pseudo` option.
I still suggest you add a `-verify-machineinstrs` option after the 
`-run-pass=avr-expand-pseudo` option.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122533

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


[PATCH] D122077: [InstCombine] Fold (ctpop(X) == 1) | (X == 0) into ctpop(X) < 2

2022-03-27 Thread Sanjay Patel via Phabricator via cfe-commits
spatel added a comment.

Thank you for the making the test changes. I pushed the baseline tests on your 
behalf here:
ebaa28e0750b 


Please rebase and update the patch here in Phabricator - it should only show 
changes in the CHECK lines after the update.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122077

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


[PATCH] D122104: [X86][regcall] Support passing / returning structures

2022-03-27 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei updated this revision to Diff 418448.
pengfei marked 2 inline comments as done.
pengfei added a comment.

Address Yuanke's comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122104

Files:
  clang/include/clang/CodeGen/CGFunctionInfo.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/X86/x86_64-arguments.c
  clang/test/CodeGen/aarch64-neon-tbl.c
  clang/test/CodeGen/regcall2.c

Index: clang/test/CodeGen/regcall2.c
===
--- /dev/null
+++ clang/test/CodeGen/regcall2.c
@@ -0,0 +1,28 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -emit-llvm %s -o - -ffreestanding -target-feature +avx512vl -triple=x86_64-pc-win32 | FileCheck %s --check-prefix=Win
+// RUN: %clang_cc1 -emit-llvm %s -o - -ffreestanding -target-feature +avx512vl -triple=x86_64-pc-linux-gnu | FileCheck %s --check-prefix=Lin
+
+#include 
+
+typedef struct {
+  __m512d r1[4];
+  __m512 r2[4];
+} __sVector;
+__sVector A;
+
+__sVector __regcall foo(int a) {
+  return A;
+}
+
+double __regcall bar(__sVector a) {
+  return a.r1[0][4];
+}
+
+// FIXME: Do we need to change for Windows?
+// Win: define dso_local x86_regcallcc void @__regcall3__foo(%struct.__sVector* noalias sret(%struct.__sVector) align 64 %agg.result, i32 noundef %a) #0
+// Win: define dso_local x86_regcallcc double @__regcall3__bar(%struct.__sVector* noundef %a) #0
+// Win: attributes #0 = { noinline nounwind optnone "frame-pointer"="none" "min-legal-vector-width"="0" "no-builtins" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+avx,+avx2,+avx512f,+avx512vl,+crc32,+cx8,+f16c,+fma,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave" }
+
+// Lin: define dso_local x86_regcallcc %struct.__sVector @__regcall3__foo(i32 noundef %a) #0
+// Lin: define dso_local x86_regcallcc double @__regcall3__bar([4 x <8 x double>] %a.coerce0, [4 x <16 x float>] %a.coerce1) #0
+// Lin: attributes #0 = { noinline nounwind optnone "frame-pointer"="none" "min-legal-vector-width"="512" "no-builtins" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+avx,+avx2,+avx512f,+avx512vl,+crc32,+cx8,+f16c,+fma,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87,+xsave" }
Index: clang/test/CodeGen/aarch64-neon-tbl.c
===
--- clang/test/CodeGen/aarch64-neon-tbl.c
+++ clang/test/CodeGen/aarch64-neon-tbl.c
@@ -42,7 +42,7 @@
   return vtbl2_s8(a, b);
 }
 
-// CHECK-LABEL: define{{.*}} <8 x i8> @test_vqtbl2_s8([2 x <16 x i8>] %a.coerce, <8 x i8> noundef %b) #0 {
+// CHECK-LABEL: define{{.*}} <8 x i8> @test_vqtbl2_s8([2 x <16 x i8>] %a.coerce, <8 x i8> noundef %b) #1 {
 // CHECK:   [[__P0_I:%.*]] = alloca %struct.int8x16x2_t, align 16
 // CHECK:   [[A:%.*]] = alloca %struct.int8x16x2_t, align 16
 // CHECK:   [[COERCE_DIVE:%.*]] = getelementptr inbounds %struct.int8x16x2_t, %struct.int8x16x2_t* [[A]], i32 0, i32 0
@@ -89,7 +89,7 @@
   return vtbl3_s8(a, b);
 }
 
-// CHECK-LABEL: define{{.*}} <8 x i8> @test_vqtbl3_s8([3 x <16 x i8>] %a.coerce, <8 x i8> noundef %b) #0 {
+// CHECK-LABEL: define{{.*}} <8 x i8> @test_vqtbl3_s8([3 x <16 x i8>] %a.coerce, <8 x i8> noundef %b) #1 {
 // CHECK:   [[__P0_I:%.*]] = alloca %struct.int8x16x3_t, align 16
 // CHECK:   [[A:%.*]] = alloca %struct.int8x16x3_t, align 16
 // CHECK:   [[COERCE_DIVE:%.*]] = getelementptr inbounds %struct.int8x16x3_t, %struct.int8x16x3_t* [[A]], i32 0, i32 0
@@ -142,7 +142,7 @@
   return vtbl4_s8(a, b);
 }
 
-// CHECK-LABEL: define{{.*}} <8 x i8> @test_vqtbl4_s8([4 x <16 x i8>] %a.coerce, <8 x i8> noundef %b) #0 {
+// CHECK-LABEL: define{{.*}} <8 x i8> @test_vqtbl4_s8([4 x <16 x i8>] %a.coerce, <8 x i8> noundef %b) #1 {
 // CHECK:   [[__P0_I:%.*]] = alloca %struct.int8x16x4_t, align 16
 // CHECK:   [[A:%.*]] = alloca %struct.int8x16x4_t, align 16
 // CHECK:   [[COERCE_DIVE:%.*]] = getelementptr inbounds %struct.int8x16x4_t, %struct.int8x16x4_t* [[A]], i32 0, i32 0
@@ -352,7 +352,7 @@
   return vqtbx1_s8(a, b, c);
 }
 
-// CHECK-LABEL: define{{.*}} <8 x i8> @test_vqtbx2_s8(<8 x i8> noundef %a, [2 x <16 x i8>] %b.coerce, <8 x i8> noundef %c) #0 {
+// CHECK-LABEL: define{{.*}} <8 x i8> @test_vqtbx2_s8(<8 x i8> noundef %a, [2 x <16 x i8>] %b.coerce, <8 x i8> noundef %c) #1 {
 // CHECK:   [[__P1_I:%.*]] = alloca %struct.int8x16x2_t, align 16
 // CHECK:   [[B:%.*]] = alloca %struct.int8x16x2_t, align 16
 // CHECK:   [[COERCE_DIVE:%.*]] = getelementptr inbounds %struct.int8x16x2_t, %struct.int8x16x2_t* [[B]], i32 0, i32 0
@@ -373,7 +373,7 @@
   return vqtbx2_s8(a, b, c);
 }
 
-// CHECK-LABEL: define{{.*}} <8 x i8> @test_vqtbx3_s8(<8 x i8> noundef %a, [3 x <16 x i8>] %b.coerce, <8 x i8> noundef %c) #0 {
+// CHECK-LABEL: define{{.*}} <8 x i8> @tes

[PATCH] D122104: [X86][regcall] Support passing / returning structures

2022-03-27 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added inline comments.



Comment at: clang/include/clang/CodeGen/CGFunctionInfo.h:590
+  /// Log 2 of the maximum vector width.
+  unsigned MaxVectorWidth : 4;
+

LuoYuanke wrote:
> I notice some code would indicate it is log 2 size with Log2 suffix in the 
> variable name. Do you think it is more readable to add Log2 suffix?
I think it doesn't matter. We have getter and setter for the variable. People 
won't access it directly.



Comment at: clang/lib/CodeGen/CGCall.cpp:5238
+  for (unsigned i = 0; i < IRCallArgs.size(); ++i)
+LargestVectorWidth = std::max(LargestVectorWidth,
+  getMaxVectorWidth(IRCallArgs[i]->getType()));

LuoYuanke wrote:
> Does this also affect other calling convention besides fastcall?
I don't think so. The change here adds for the missing cases like `[2 x <4 x 
double>]` or `{ <2 x double>, <4 x double> }` which should also set 
`min-legal-width-width` to the maximum of the vector length.
There're several reasons why other calling convention won't be affected.
1. If a target has ability to pass arguments like `[2 x <4 x double>]`, it must 
have the ability for `<4 x double>` and have set `min-legal-width-width` to 256 
when passing it. So it makes more sense to set `min-legal-width-width` to 256 
for `[2 x <4 x double>]` rather than keeping it as 0;
2. AFAIK, targets other than X86 simply ignore `min-legal-width-width`. So the 
change won't affect them;
3. On x86, calling conventions other than regcall don't allow arguments size 
larger than 512, see `if (!IsRegCall && Size > 512)`. They will be turned into 
pointers, so they won't be affected by this change;
4. For arguments size no larger than 512 and only contain single vector 
element, we have already turned them into pure vectors. So they have already 
set `min-legal-width-width` to the correct value;
5. For arguments have more then one vector elements. Clang has bug which 
doesn't match with GCC and ICC. I have filed a bug here 
https://github.com/llvm/llvm-project/issues/54582
6. Thus, only regcall can generate arguments type like `[2 x <4 x double>]` on 
X86. So only it will be affected by this.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:3031
 // than eight eightbytes, ..., it has class MEMORY.
-if (Size > 512)
+if (!IsRegCall && Size > 512)
   return;

LuoYuanke wrote:
> Would you add a test for non regcall? Pass 1024 bit vector parameter and 
> check if it is well handled both with regcall and without regcall.
> Would you add comments to depict why regcall accept the size which is more 
> than 512?
Added one to non regcall. regcall doesn't specify how to handle 1024 bit 
vector. I'd take it as UB, so we don't need such a test.
https://www.intel.com/content/www/us/en/develop/documentation/cpp-compiler-developer-guide-and-reference/top/compiler-reference/c-c-calling-conventions.html



Comment at: clang/test/CodeGen/aarch64-neon-tbl.c:45
 
-// CHECK-LABEL: define{{.*}} <8 x i8> @test_vqtbl2_s8([2 x <16 x i8>] 
%a.coerce, <8 x i8> noundef %b) #0 {
+// CHECK-LABEL: define{{.*}} <8 x i8> @test_vqtbl2_s8([2 x <16 x i8>] 
%a.coerce, <8 x i8> noundef %b) #1 {
 // CHECK:   [[__P0_I:%.*]] = alloca %struct.int8x16x2_t, align 16

LuoYuanke wrote:
> I'm curious why aarch64 test cases are affected by the patch.
As I explained above, `[2 x <16 x i8>]` should have the same value of 
`min-legal-vector-width` as `<16 x i8>`. The difference between `#0` and `#1` 
is the value of `min-legal-vector-width`.



Comment at: clang/test/CodeGen/regcall2.c:2
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -emit-llvm %s -o - -ffreestanding -target-feature +avx512vl 
-triple=x86_64-pc-win32 | FileCheck %s --check-prefix=Win
+// RUN: %clang_cc1 -emit-llvm %s -o - -ffreestanding -target-feature +avx512vl 
-triple=x86_64-pc-linux-gnu | FileCheck %s --check-prefix=Lin

LuoYuanke wrote:
> Add test case for target that has no avx512 feature?
I'd take it as UB for Clang and GCC using 512 bit vector without avx512 
feature. ICC always promotes to avx512 when it finds 512 bit vector. So we 
don't need such tests.



Comment at: clang/test/CodeGen/regcall2.c:9
+  __m512d r1[4];
+  __m512 r2[4];
+} __sVector;

LuoYuanke wrote:
> May add a test case to show what's the max register we can pass with regcall.
We have tests for it in `clang/test/CodeGen/regcall.c`. This patch doesn't 
affect the capability of regcall.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122104

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


[PATCH] D122544: Utilize comparison operation implemented in APInt

2022-03-27 Thread Danny Mösch via Phabricator via cfe-commits
SimplyDanny created this revision.
SimplyDanny added a reviewer: njames93.
Herald added a subscriber: carlosgalvezp.
Herald added a project: All.
SimplyDanny requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

This is a fix for #53963.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122544

Files:
  clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
@@ -172,7 +172,10 @@
 template 
 int Bar() { T A[5]; return sizeof(A[0]) / sizeof(T); }
 // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: suspicious usage of sizeof 
pointer 'sizeof(T)/sizeof(T)'
-int Test3() { return Foo<42>() + Bar(); }
+template <__int128_t N> 
+bool Baz() { return sizeof(A) < N; }
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: suspicious comparison of 
'sizeof(expr)' to a constant
+int Test3() { return Foo<42>() + Bar() + Baz<-1>(); }
 
 static const char* kABC = "abc";
 static const wchar_t* kDEF = L"def";
Index: clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
@@ -20,7 +20,7 @@
 namespace {
 
 AST_MATCHER_P(IntegerLiteral, isBiggerThan, unsigned, N) {
-  return Node.getValue().getZExtValue() > N;
+  return Node.getValue().ugt(N);
 }
 
 AST_MATCHER_P2(Expr, hasSizeOfDescendant, int, Depth,


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-sizeof-expression.cpp
@@ -172,7 +172,10 @@
 template 
 int Bar() { T A[5]; return sizeof(A[0]) / sizeof(T); }
 // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: suspicious usage of sizeof pointer 'sizeof(T)/sizeof(T)'
-int Test3() { return Foo<42>() + Bar(); }
+template <__int128_t N> 
+bool Baz() { return sizeof(A) < N; }
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: suspicious comparison of 'sizeof(expr)' to a constant
+int Test3() { return Foo<42>() + Bar() + Baz<-1>(); }
 
 static const char* kABC = "abc";
 static const wchar_t* kDEF = L"def";
Index: clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/SizeofExpressionCheck.cpp
@@ -20,7 +20,7 @@
 namespace {
 
 AST_MATCHER_P(IntegerLiteral, isBiggerThan, unsigned, N) {
-  return Node.getValue().getZExtValue() > N;
+  return Node.getValue().ugt(N);
 }
 
 AST_MATCHER_P2(Expr, hasSizeOfDescendant, int, Depth,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D122524: [clang][AVR] Generate link warnings properly

2022-03-27 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/test/Driver/avr-toolchain.c:39
+
+// RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 
-mmcu=atmega328 2>&1 | FileCheck --check-prefix=CHECK5 %s
+// CHECK5-NOT: warning: no target microcontroller specified on command line, 
cannot link standard libraries

`-target ` is legacy spelling. Better use `--target=` for new RUN lines.



Comment at: clang/test/Driver/avr-toolchain.c:40
+// RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 
-mmcu=atmega328 2>&1 | FileCheck --check-prefix=CHECK5 %s
+// CHECK5-NOT: warning: no target microcontroller specified on command line, 
cannot link standard libraries
+// CHECK5-NOT: warning: no avr-gcc installation can be found on the system, 
cannot link standard libraries

negative patterns easily go stale without being noticed.
Check whether you can just use `CHECK5-NOT: warning:` instead of specifying the 
full diagnostic.


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

https://reviews.llvm.org/D122524

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


[PATCH] D122524: [clang][AVR] Generate link warnings properly

2022-03-27 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/Driver/ToolChains/AVR.cpp:379
   !Args.hasArg(options::OPT_nodefaultlibs) &&
+  !Args.hasArg(options::OPT_S) &&
   !Args.hasArg(options::OPT_c /* does not apply when not linking */)) {

This is insufficient. -fsyntax-only, -E, etc should not need the diagnostic as 
well.
I know there may be test coverage gap but it is excessive to test all of -S -c 
-E ... that there is no diagnostic.


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

https://reviews.llvm.org/D122524

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


[PATCH] D122533: [AVR] Remove AVRRelaxMemOperations

2022-03-27 Thread Patryk Wychowaniec via Phabricator via cfe-commits
Patryk27 updated this revision to Diff 418460.
Patryk27 added a comment.

Add `-verify-machineinstrs`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122533

Files:
  clang/docs/tools/clang-formatted-files.txt
  llvm/lib/Target/AVR/AVR.h
  llvm/lib/Target/AVR/AVRExpandPseudoInsts.cpp
  llvm/lib/Target/AVR/AVRRelaxMemOperations.cpp
  llvm/lib/Target/AVR/AVRTargetMachine.cpp
  llvm/lib/Target/AVR/CMakeLists.txt
  llvm/test/CodeGen/AVR/pseudo/STDWPtrQRr.mir
  llvm/test/CodeGen/AVR/relax-mem/STDWPtrQRr.mir
  llvm/utils/gn/secondary/llvm/lib/Target/AVR/BUILD.gn

Index: llvm/utils/gn/secondary/llvm/lib/Target/AVR/BUILD.gn
===
--- llvm/utils/gn/secondary/llvm/lib/Target/AVR/BUILD.gn
+++ llvm/utils/gn/secondary/llvm/lib/Target/AVR/BUILD.gn
@@ -37,7 +37,6 @@
 "AVRInstrInfo.cpp",
 "AVRMCInstLower.cpp",
 "AVRRegisterInfo.cpp",
-"AVRRelaxMemOperations.cpp",
 "AVRShiftExpand.cpp",
 "AVRSubtarget.cpp",
 "AVRTargetMachine.cpp",
Index: llvm/test/CodeGen/AVR/relax-mem/STDWPtrQRr.mir
===
--- llvm/test/CodeGen/AVR/relax-mem/STDWPtrQRr.mir
+++ /dev/null
@@ -1,31 +0,0 @@
-# RUN: llc -O0 -run-pass=avr-relax-mem %s -o - | FileCheck %s
-
 |
-  target triple = "avr--"
-  define void @test() {
-  entry:
-ret void
-  }
-...
-

-name:test
-body: |
-  bb.0.entry:
-
-; CHECK-LABEL: test
-
-; We shouldn't expand things which already have 6-bit imms.
-; CHECK: STDWPtrQRr $r29r28, 63, $r1r0
-STDWPtrQRr $r29r28, 63, $r1r0
-
-; We shouldn't expand things which already have 6-bit imms.
-; CHECK-NEXT: STDWPtrQRr $r29r28, 0, $r1r0
-STDWPtrQRr $r29r28, 0, $r1r0
-
-; CHECK-NEXT: PUSHWRr $r29r28, implicit-def $sp, implicit $sp
-; CHECK-NEXT: $r29r28 = SBCIWRdK $r29r28, -64, implicit-def $sreg, implicit $sreg
-; CHECK-NEXT: STWPtrRr $r29r28, $r1r0
-; CHECK-NEXT: $r29r28 = POPWRd implicit-def $sp, implicit $sp
-STDWPtrQRr $r29r28, 64, $r1r0
-...
Index: llvm/test/CodeGen/AVR/pseudo/STDWPtrQRr.mir
===
--- llvm/test/CodeGen/AVR/pseudo/STDWPtrQRr.mir
+++ llvm/test/CodeGen/AVR/pseudo/STDWPtrQRr.mir
@@ -1,4 +1,4 @@
-# RUN: llc -O0 -run-pass=avr-expand-pseudo  %s -o - | FileCheck %s
+# RUN: llc -O0 -run-pass=avr-expand-pseudo -verify-machineinstrs %s -o - | FileCheck %s
 
 --- |
   target triple = "avr--"
@@ -15,8 +15,52 @@
 
 ; CHECK-LABEL: test
 
-; CHECK:  STDPtrQRr $r29r28, 10, $r0
-; CHECK-NEXT: STDPtrQRr $r29r28, 11, $r1
+; Small displacement (<63):
+; CHECK:  STDPtrQRr $r29r28, 3, $r0
+; CHECK-NEXT: STDPtrQRr $r29r28, 4, $r1
+STDWPtrQRr $r29r28, 3, $r1r0
 
-STDWPtrQRr $r29r28, 10, $r1r0
+; Small displacement where the destination register is killed:
+; CHECK:  STDPtrQRr $r29r28, 3, $r0
+; CHECK-NEXT: STDPtrQRr killed $r29r28, 4, $r1
+STDWPtrQRr killed $r29r28, 3, $r1r0
+
+; Small displacement where the source register is killed:
+; CHECK:  STDPtrQRr $r29r28, 3, killed $r0
+; CHECK-NEXT: STDPtrQRr $r29r28, 4, killed $r1
+STDWPtrQRr $r29r28, 3, killed $r1r0
+
+; Small displacement, near the limit (=62):
+; CHECK:  STDPtrQRr $r29r28, 62, $r0
+; CHECK-NEXT: STDPtrQRr $r29r28, 63, $r1
+STDWPtrQRr $r29r28, 62, $r1r0
+
+; Large displacement (>=63):
+; CHECK: PUSHRr $r28, implicit-def $sp, implicit $sp
+; CHECK-NEXT: PUSHRr $r29, implicit-def $sp, implicit $sp
+; CHECK-NEXT: $r28 = SUBIRdK killed $r28, 193, implicit-def $sreg
+; CHECK-NEXT: $r29 = SBCIRdK killed $r29, 255, implicit-def $sreg, implicit killed $sreg
+; CHECK-NEXT: STPtrRr $r29r28, $r0
+; CHECK-NEXT: STDPtrQRr $r29r28, 1, $r1
+; CHECK-NEXT: $r29 = POPRd implicit-def $sp, implicit $sp
+; CHECK-NEXT: $r28 = POPRd implicit-def $sp, implicit $sp
+STDWPtrQRr $r29r28, 63, $r1r0
+
+; Large displacement where the destination register is killed:
+; CHECK: $r28 = SUBIRdK killed $r28, 193, implicit-def $sreg
+; CHECK-NEXT: $r29 = SBCIRdK killed $r29, 255, implicit-def $sreg, implicit killed $sreg
+; CHECK-NEXT: STPtrRr $r29r28, $r0
+; CHECK-NEXT: STDPtrQRr $r29r28, 1, $r1
+STDWPtrQRr killed $r29r28, 63, $r1r0
+
+; Large displacement where the source register is killed:
+; CHECK: PUSHRr $r28, implicit-def $sp, implicit $sp
+; CHECK-NEXT: PUSHRr $r29, implicit-def $sp, implicit $sp
+; CHECK-NEXT: $r28 = SUBIRdK killed $r28, 193, implicit-def $sreg
+; CHECK-NEXT: $r29 = SBCIRdK killed $r29, 255, implicit-def $sreg, implicit killed $sreg
+; CHECK-NEXT: STPtrRr $r29r28, killed $r0
+; CHECK-NEXT: STDPtrQRr $r29r28, 1, killed $r1
+; CHECK-NEXT: $r29 = POPRd implicit-def $sp, implicit $sp
+; CHECK-NEXT: $r28 = POPRd implicit-def $sp, implicit $

[PATCH] D122533: [AVR] Remove AVRRelaxMemOperations

2022-03-27 Thread Patryk Wychowaniec via Phabricator via cfe-commits
Patryk27 added a comment.

Ok, I have added the switch; I think a separate patch that adds that switch to 
all the tests would be handy - what do you think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122533

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


[clang] 8b245ab - [Clang, TBAA] Add test cases for nested pointers and TBAA data.

2022-03-27 Thread Florian Hahn via cfe-commits

Author: Florian Hahn
Date: 2022-03-27T19:59:37+01:00
New Revision: 8b245ab41dfaed153e9ce768470107ec71551e1f

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

LOG: [Clang,TBAA] Add test cases for nested pointers and TBAA data.

Added: 
clang/test/CodeGen/tbaa-pointers.c

Modified: 


Removed: 




diff  --git a/clang/test/CodeGen/tbaa-pointers.c 
b/clang/test/CodeGen/tbaa-pointers.c
new file mode 100644
index 0..bde26d17e1430
--- /dev/null
+++ b/clang/test/CodeGen/tbaa-pointers.c
@@ -0,0 +1,103 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -O1 -disable-llvm-passes %s 
-emit-llvm -o - | FileCheck %s
+
+void p2unsigned(unsigned **ptr) {
+  // CHECK-LABEL: define void @p2unsigned(i32** noundef %ptr)
+  // CHECK-NEXT: entry:
+  // CHECK-NEXT:  %ptr.addr = alloca i32**, align 8
+  // CHECK-NEXT:  store i32** %ptr, i32*** %ptr.addr, align 8, !tbaa 
[[ANY_POINTER_0:!.+]]
+  // CHECK-NEXT:  [[BASE:%.+]] = load i32**, i32*** %ptr.addr, align 8, !tbaa 
[[ANY_POINTER_0]]
+  // CHECK-NEXT:  store i32* null, i32** [[BASE]], align 8, !tbaa 
[[ANY_POINTER_0]]
+  // CHECK-NEXT:  ret void
+  //
+  *ptr = 0;
+}
+
+void p2unsigned_volatile(unsigned *volatile *ptr) {
+  // CHECK-LABEL: define void @p2unsigned_volatile(i32** noundef %ptr)
+  // CHECK-NEXT: entry:
+  // CHECK-NEXT:   %ptr.addr = alloca i32**, align 8
+  // CHECK-NEXT:   store i32** %ptr, i32*** %ptr.addr, align 8, !tbaa 
[[ANY_POINTER_0]]
+  // CHECK-NEXT:   [[BASE:%.+]] = load i32**, i32*** %ptr.addr, align 8, !tbaa 
[[ANY_POINTER_0]]
+  // CHECK-NEXT:   store volatile i32* null, i32** [[BASE]], align 8, !tbaa 
[[ANY_POINTER_0]]
+  // CHECK-NEXT:   ret void
+  //
+  *ptr = 0;
+}
+
+void p3int(int ***ptr) {
+  // CHECK-LABEL: define void @p3int(i32*** noundef %ptr)
+  // CHECK-NEXT: entry:
+  // CHECK-NEXT:   %ptr.addr = alloca i32***, align 8
+  // CHECK-NEXT:   store i32*** %ptr, i32 %ptr.addr, align 8, !tbaa 
[[ANY_POINTER_0]]
+  // CHECK-NEXT:   [[BASE_0:%.+]] = load i32***, i32 %ptr.addr, align 8, 
!tbaa [[ANY_POINTER_0]]
+  // CHECK-NEXT:   [[BASE_1:%.+]] = load i32**, i32*** [[BASE_0]], align 8, 
!tbaa [[ANY_POINTER_0]]
+  // CHECK-NEXT:   store i32* null, i32** [[BASE_1]], align 8, !tbaa 
[[ANY_POINTER_0]]
+  // CHECK-NEXT:   ret void
+  //
+  **ptr = 0;
+}
+
+void p4char(char ptr) {
+  // CHECK-LABEL: define void @p4char(i8 noundef %ptr)
+  // CHECK-NEXT: entry:
+  // CHECK-NEXT:   %ptr.addr = alloca i8, align 8
+  // CHECK-NEXT:   store i8 %ptr, i8* %ptr.addr, align 8, !tbaa 
[[ANY_POINTER_0]]
+  // CHECK-NEXT:   [[BASE_0:%.+]] = load i8, i8* %ptr.addr, align 8, 
!tbaa [[ANY_POINTER_0]]
+  // CHECK-NEXT:   [[BASE_1:%.+]] = load i8***, i8 [[BASE_0]], align 8, 
!tbaa [[ANY_POINTER_0]]
+  // CHECK-NEXT:   [[BASE_2:%.+]] = load i8**, i8*** [[BASE_1]], align 8, 
!tbaa [[ANY_POINTER_0]]
+  // CHECK-NEXT:   store i8* null, i8** [[BASE_2]], align 8, !tbaa 
[[ANY_POINTER_0]]
+  // CHECK-NEXT:   ret void
+  //
+  ***ptr = 0;
+}
+
+void p4char_const1(const char ptr) {
+  // CHECK-LABEL: define void @p4char_const1(i8 noundef %ptr)
+  // CHECK-NEXT: entry:
+  // CHECK-NEXT:   %ptr.addr = alloca i8, align 8
+  // CHECK-NEXT:   store i8 %ptr, i8* %ptr.addr, align 8, !tbaa 
[[ANY_POINTER_0]]
+  // CHECK-NEXT:   [[BASE_0:%.+]] = load i8, i8* %ptr.addr, align 8, 
!tbaa [[ANY_POINTER_0]]
+  // CHECK-NEXT:   [[BASE_1:%.+]] = load i8***, i8 [[BASE_0]], align 8, 
!tbaa [[ANY_POINTER_0]]
+  // CHECK-NEXT:   [[BASE_2:%.+]] = load i8**, i8*** [[BASE_1]], align 8, 
!tbaa [[ANY_POINTER_0]]
+  // CHECK-NEXT:   store i8* null, i8** [[BASE_2]], align 8, !tbaa 
[[ANY_POINTER_0]]
+  // CHECK-NEXT:   ret void
+  //
+  ***ptr = 0;
+}
+
+void p4char_const2(const char **const **ptr) {
+  // CHECK-LABEL: define void @p4char_const2(i8 noundef %ptr)
+  // CHECK-NEXT: entry:
+  // CHECK-NEXT:   %ptr.addr = alloca i8, align 8
+  // CHECK-NEXT:   store i8 %ptr, i8* %ptr.addr, align 8, !tbaa 
[[ANY_POINTER_0]]
+  // CHECK-NEXT:   [[BASE_0:%.+]] = load i8, i8* %ptr.addr, align 8, 
!tbaa [[ANY_POINTER_0]]
+  // CHECK-NEXT:   [[BASE_1:%.+]] = load i8***, i8 [[BASE_0]], align 8, 
!tbaa [[ANY_POINTER_0]]
+  // CHECK-NEXT:   [[BASE_2:%.+]] = load i8**, i8*** [[BASE_1]], align 8, 
!tbaa [[ANY_POINTER_0]]
+  // CHECK-NEXT:   store i8* null, i8** [[BASE_2]], align 8, !tbaa 
[[ANY_POINTER_0]]
+  // CHECK-NEXT:   ret void
+  //
+  ***ptr = 0;
+}
+
+struct S1 {
+  int x;
+  int y;
+};
+
+void p2struct(struct S1 **ptr) {
+  // CHECK-LABEL: define void @p2struct(%struct.S1** noundef %ptr)
+  // CHECK-NEXT: entry:
+  // CHECK-NEXT:   %ptr.addr = alloca %struct.S1**, align 8
+  // CHECK-NEXT:   store %struct.S1** %ptr, %struct.S1*** %ptr.addr, align 8, 
!tbaa [[ANY_P

[PATCH] D122546: Let clang-repl link privately against Clang components

2022-03-27 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert created this revision.
aaronpuchert added a reviewer: v.g.vassilev.
Herald added a subscriber: mgorny.
Herald added a project: All.
aaronpuchert requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

First of all, this is the convention: all other tools have their
dependencies private. While it does not have an effect on linking
(there is no linking against executables), it does have an effect
on exporting: having the targets private allows installing the tools
without the libraries in a statically linked build, or a build against
libclang-cpp.so.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122546

Files:
  clang/tools/clang-repl/CMakeLists.txt


Index: clang/tools/clang-repl/CMakeLists.txt
===
--- clang/tools/clang-repl/CMakeLists.txt
+++ clang/tools/clang-repl/CMakeLists.txt
@@ -11,7 +11,7 @@
   ClangRepl.cpp
   )
 
-clang_target_link_libraries(clang-repl PUBLIC
+clang_target_link_libraries(clang-repl PRIVATE
   clangBasic
   clangFrontend
   clangInterpreter


Index: clang/tools/clang-repl/CMakeLists.txt
===
--- clang/tools/clang-repl/CMakeLists.txt
+++ clang/tools/clang-repl/CMakeLists.txt
@@ -11,7 +11,7 @@
   ClangRepl.cpp
   )
 
-clang_target_link_libraries(clang-repl PUBLIC
+clang_target_link_libraries(clang-repl PRIVATE
   clangBasic
   clangFrontend
   clangInterpreter
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121756: [clang-format] Clean up code looking for if statements

2022-03-27 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

In D121756#3407320 , @owenpan wrote:

> In D121756#3398165 , @sstwcw wrote:
>
>> It turned out this patch does change behavior.
>>
>>   -  while (
>>   -  FormatTok->isOneOf(tok::identifier, tok::kw_requires, 
>> tok::coloncolon)) {
>>   +  while (FormatTok->isOneOf(tok::identifier, tok::kw_requires,
>>   +tok::coloncolon)) {
>>
>> So what do I do?
>
> IMO, refactoring and cleaning up code should be NFC. You can first add 
> `while`, `switch`, etc (if it makes sense) in one patch and then refactor in 
> another patch (or vice versa). It would be much easier to review.

+1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121756

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


[PATCH] D119136: [wip][clang] Implement Change scope of lambda trailing-return-type

2022-03-27 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 418467.
cor3ntin added a comment.

- Rebase (I managed to conflict with myself)
- Fix formatting - which fixes the broken tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119136

Files:
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Scope.h
  clang/include/clang/Sema/ScopeInfo.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Sema/Scope.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaCXXScopeSpec.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p11-1y.cpp
  clang/test/SemaCXX/lambda-capture-type-deduction.cpp
  clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1355,7 +1355,7 @@
 
   Change scope of lambda trailing-return-type
   https://wg21.link/P2036R3";>P2036R3
-  No
+  Clang 15
 
 
   Multidimensional subscript operator
Index: clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
===
--- clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
+++ clang/test/SemaCXX/warn-shadow-in-lambdas.cpp
@@ -95,7 +95,7 @@
 #ifdef AVOID
   auto l4 = [var = param] (int param) { ; }; // no warning
 #else
-  auto l4 = [var = param] (int param) { ; }; // expected-warning {{declaration shadows a local variable}}
+  auto l4 = [var = param](int param) { ; }; // expected-warning 2{{declaration shadows a local variable}}
 #endif
 
   // Make sure that inner lambdas work as well.
Index: clang/test/SemaCXX/lambda-capture-type-deduction.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/lambda-capture-type-deduction.cpp
@@ -0,0 +1,121 @@
+// RUN: %clang_cc1 -std=c++2b -verify -fsyntax-only %s
+
+template 
+constexpr bool is_same = false;
+
+template 
+constexpr bool is_same = true;
+
+void f() {
+
+  int y;
+
+  static_assert(is_same decltype((x)) { return x; }())>);
+
+  static_assert(is_same decltype((x)) { return x; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  static_assert(is_same decltype((y)) { return y; }())>);
+
+  auto ref = [&x = y](
+ decltype([&](decltype(x)) { return 0; }) y) {
+return x;
+  };
+}
+
+void test_noexcept() {
+
+  int y;
+
+  static_assert(noexcept([x = 1] noexcept(is_same) {}()));
+  static_assert(noexcept([x = 1] mutable noexcept(is_same) {}()));
+  static_assert(noexcept([y] noexcept(is_same) {}()));
+  static_assert(noexcept([y] mutable noexcept(is_same) {}()));
+  static_assert(noexcept([=] noexcept(is_same) {}()));
+  static_assert(noexcept([=] mutable noexcept(is_same) {}()));
+  static_assert(noexcept([&] noexcept(is_same) {}()));
+  static_assert(noexcept([&] mutable noexcept(is_same) {}()));
+
+  static_assert(noexcept([&] mutable noexcept(!is_same) {}())); // expected-error {{static_assert failed due}}
+}
+
+void test_requires() {
+
+  int x;
+
+  [x = 1]() requires is_same {}();
+  [x = 1]() mutable requires is_same {}();
+  [x]() requires is_same {} ();
+  [x]() mutable requires is_same {} ();
+  [=]() requires is_same {} ();
+  [=]() mutable requires is_same {} ();
+  [&]() requires is_same {} ();
+  [&]() mutable requires is_same {} ();
+  [&x]() requires is_same {} ();
+  [&x]() mutable requires is_same {}();
+
+  [x = 1]() requires is_same {} (); // expected-error {{no matching function for call to object of type}} \
+  // expected-note {{candidate function not viable}} \
+  // expected-note {{'is_same' evaluated to false}}
+
+  [x = 1]() mutable requires is_same {} (); // expected-error {{no matching function for call to object of type}} \
+// expected-note {{candidate function not viable}} \
+// expected-note {{'is_same' evaluated to false}}
+}
+
+void err() {
+  int y, z;// expected-note 2{{declared here}}
+  auto implicit_tpl = [=]( // expected-note {{variable 'y' is captured here}}
+  decltype([&] { return 0; }) y) { //expected-error{{captured variable 'y' cannot appear}}
+return y;
+  };
+
+  auto init_tpl = [x = 1](  // expected-note{{explicitly captured here}}
+  decltype([&] { 

[PATCH] D122547: [clang] Make Driver tests pass when running with temp dir containing "crt"

2022-03-27 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: hans.
Herald added subscribers: abrachet, emaste.
Herald added a project: All.
thakis requested review of this revision.

In a recent run, temp files got created in /tmp/lit-tmp-2wcrtcx1/foo-xxx.o.
Since the tmp path contained "crt", this made a few tests fail:
http://45.33.8.238/linux/72221/step_7.txt

Not allowing '/' as path of the file name prevents this.


https://reviews.llvm.org/D122547

Files:
  clang/test/Driver/dragonfly.c
  clang/test/Driver/freebsd.c
  clang/test/Driver/fuchsia.c
  clang/test/Driver/linux-cross.cpp
  clang/test/Driver/netbsd.c
  clang/test/Driver/openbsd.c


Index: clang/test/Driver/openbsd.c
===
--- clang/test/Driver/openbsd.c
+++ clang/test/Driver/openbsd.c
@@ -38,7 +38,7 @@
 // RUN:   | FileCheck --check-prefix=CHECK-MIPS64EL-LD %s
 // CHECK-LD-R: "-r"
 // CHECK-LD-R-NOT: "-l
-// CHECK-LD-R-NOT: crt{{[^.]+}}.o
+// CHECK-LD-R-NOT: crt{{[^./]+}}.o
 // CHECK-LD-S: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd"
 // CHECK-LD-S: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" 
"-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" 
"-L{{.*}}" "-s" "{{.*}}.o" "-lcompiler_rt" "-lc" "-lcompiler_rt" 
"{{.*}}crtend.o"
 // CHECK-LD-T: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd"
Index: clang/test/Driver/netbsd.c
===
--- clang/test/Driver/netbsd.c
+++ clang/test/Driver/netbsd.c
@@ -474,4 +474,4 @@
 // RUN: | FileCheck -check-prefix=RELOCATABLE %s
 // RELOCATABLE: "-r"
 // RELOCATABLE-NOT: "-l
-// RELOCATABLE-NOT: crt{{[^.]+}}.o
+// RELOCATABLE-NOT: crt{{[^./]+}}.o
Index: clang/test/Driver/linux-cross.cpp
===
--- clang/test/Driver/linux-cross.cpp
+++ clang/test/Driver/linux-cross.cpp
@@ -220,4 +220,4 @@
 // RELOCATABLE:  "-L
 // RELOCATABLE-SAME: {{^}}[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/10"
 // RELOCATABLE-NOT:  "-l
-// RELOCATABLE-NOT:  crt{{[^.]+}}.o
+// RELOCATABLE-NOT:  crt{{[^./]+}}.o
Index: clang/test/Driver/fuchsia.c
===
--- clang/test/Driver/fuchsia.c
+++ clang/test/Driver/fuchsia.c
@@ -73,7 +73,7 @@
 // CHECK-RELOCATABLE-NOT: "--build-id"
 // CHECK-RELOCATABLE: "-r"
 // CHECK-RELOCATABLE-NOT: "-l
-// CHECK-RELOCATABLE-NOT: crt{{[^.]+}}.o
+// CHECK-RELOCATABLE-NOT: crt{{[^./]+}}.o
 
 // RUN: %clang %s -### --target=x86_64-unknown-fuchsia -nodefaultlibs 
-fuse-ld=lld 2>&1 \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
Index: clang/test/Driver/freebsd.c
===
--- clang/test/Driver/freebsd.c
+++ clang/test/Driver/freebsd.c
@@ -211,4 +211,4 @@
 // RUN:   --sysroot=%S/Inputs/basic_freebsd64_tree 2>&1 | FileCheck %s 
--check-prefix=RELOCATABLE
 // RELOCATABLE: "-r"
 // RELOCATABLE-NOT: "-l
-// RELOCATABLE-NOT: crt{{[^.]+}}.o
+// RELOCATABLE-NOT: crt{{[^./]+}}.o
Index: clang/test/Driver/dragonfly.c
===
--- clang/test/Driver/dragonfly.c
+++ clang/test/Driver/dragonfly.c
@@ -9,4 +9,4 @@
 // RUN:   2>&1 | FileCheck %s --check-prefix=RELOCATABLE
 // RELOCATABLE: "-r"
 // RELOCATABLE-NOT: "-l
-// RELOCATABLE-NOT: {{.*}}crt{{[^.]+}}.o
+// RELOCATABLE-NOT: {{.*}}crt{{[^./]+}}.o


Index: clang/test/Driver/openbsd.c
===
--- clang/test/Driver/openbsd.c
+++ clang/test/Driver/openbsd.c
@@ -38,7 +38,7 @@
 // RUN:   | FileCheck --check-prefix=CHECK-MIPS64EL-LD %s
 // CHECK-LD-R: "-r"
 // CHECK-LD-R-NOT: "-l
-// CHECK-LD-R-NOT: crt{{[^.]+}}.o
+// CHECK-LD-R-NOT: crt{{[^./]+}}.o
 // CHECK-LD-S: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd"
 // CHECK-LD-S: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" "-L{{.*}}" "-s" "{{.*}}.o" "-lcompiler_rt" "-lc" "-lcompiler_rt" "{{.*}}crtend.o"
 // CHECK-LD-T: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd"
Index: clang/test/Driver/netbsd.c
===
--- clang/test/Driver/netbsd.c
+++ clang/test/Driver/netbsd.c
@@ -474,4 +474,4 @@
 // RUN: | FileCheck -check-prefix=RELOCATABLE %s
 // RELOCATABLE: "-r"
 // RELOCATABLE-NOT: "-l
-// RELOCATABLE-NOT: crt{{[^.]+}}.o
+// RELOCATABLE-NOT: crt{{[^./]+}}.o
Index: clang/test/Driver/linux-cross.cpp
===
--- clang/test/Driver/linux-cross.cpp
+++ clang/test/Driver/linux-cross.cpp
@@ -220,4 +220,4 @@
 // RELOCATABLE:  "-L
 // RELOCATABLE-SAME: {{^}}[[SYSROOT]]/usr/lib/gcc/x86_64-linux-gnu/10"
 // RELOCATABLE-NOT:  "-l
-// RELOCATABLE-NOT:  crt{{[^.]+}}.o
+// RELOCATABLE-NOT:  crt{{[^./]+}}.o
Index: clang/test/Driver/fuchsia.c

[PATCH] D122548: [clang-format] Don't format qualifiers in PPDirective

2022-03-27 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision.
owenpan added reviewers: MyDeveloperDay, curdeius, HazardyKnusperkeks.
owenpan added a project: clang-format.
Herald added a project: All.
owenpan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixes #54513 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122548

Files:
  clang/lib/Format/QualifierAlignmentFixer.cpp
  clang/unittests/Format/QualifierFixerTest.cpp


Index: clang/unittests/Format/QualifierFixerTest.cpp
===
--- clang/unittests/Format/QualifierFixerTest.cpp
+++ clang/unittests/Format/QualifierFixerTest.cpp
@@ -815,6 +815,7 @@
   ReplacementCount = 0;
   EXPECT_EQ(ReplacementCount, 0);
   verifyFormat("static const uint32 foo[] = {0, 31};", Style);
+  verifyFormat("#define MACRO static const", Style);
   EXPECT_EQ(ReplacementCount, 0);
 }
 
Index: clang/lib/Format/QualifierAlignmentFixer.cpp
===
--- clang/lib/Format/QualifierAlignmentFixer.cpp
+++ clang/lib/Format/QualifierAlignmentFixer.cpp
@@ -407,6 +407,8 @@
   assert(QualifierToken != tok::identifier && "Unrecognised Qualifier");
 
   for (AnnotatedLine *Line : AnnotatedLines) {
+if (Line->InPPDirective)
+  continue;
 FormatToken *First = Line->First;
 assert(First);
 if (First->Finalized)


Index: clang/unittests/Format/QualifierFixerTest.cpp
===
--- clang/unittests/Format/QualifierFixerTest.cpp
+++ clang/unittests/Format/QualifierFixerTest.cpp
@@ -815,6 +815,7 @@
   ReplacementCount = 0;
   EXPECT_EQ(ReplacementCount, 0);
   verifyFormat("static const uint32 foo[] = {0, 31};", Style);
+  verifyFormat("#define MACRO static const", Style);
   EXPECT_EQ(ReplacementCount, 0);
 }
 
Index: clang/lib/Format/QualifierAlignmentFixer.cpp
===
--- clang/lib/Format/QualifierAlignmentFixer.cpp
+++ clang/lib/Format/QualifierAlignmentFixer.cpp
@@ -407,6 +407,8 @@
   assert(QualifierToken != tok::identifier && "Unrecognised Qualifier");
 
   for (AnnotatedLine *Line : AnnotatedLines) {
+if (Line->InPPDirective)
+  continue;
 FormatToken *First = Line->First;
 assert(First);
 if (First->Finalized)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D122548: [clang-format] Don't format qualifiers in PPDirective

2022-03-27 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.

LGTM thank you for the patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122548

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


[PATCH] D122549: [VFS] RedirectingFileSystem only replace path if not already mapped

2022-03-27 Thread Ben Barham via Phabricator via cfe-commits
bnbarham created this revision.
bnbarham added reviewers: dexonsmith, keith, JDevlieghere, vsapsai, sammccall.
Herald added a subscriber: hiraditya.
Herald added a project: All.
bnbarham requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

If the `ExternalFS` has already remapped a path then the
`RedirectingFileSystem` should not change it to the originally provided
path. This fixes the original path always being used if multiple VFS
overlays were provided and the path wasn't found in the highest (ie.
first in the chain).

This also changes `IsVFSMapped` to mean the returned path is a *mapped*
path, rather than just from a virtual filesystem. But it was only being used
by a hack in `FileManager` for module searching, where `external-names: true`
is always used.

Resolves rdar://90578880 and llvm-project#53306.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122549

Files:
  clang/lib/Basic/FileManager.cpp
  clang/test/VFS/external-names-multi-overlay.c
  llvm/include/llvm/Support/VirtualFileSystem.h
  llvm/lib/Support/VirtualFileSystem.cpp
  llvm/unittests/Support/VirtualFileSystemTest.cpp

Index: llvm/unittests/Support/VirtualFileSystemTest.cpp
===
--- llvm/unittests/Support/VirtualFileSystemTest.cpp
+++ llvm/unittests/Support/VirtualFileSystemTest.cpp
@@ -1478,16 +1478,16 @@
   // file in remapped directory
   S = O->status("//root/mappeddir/a");
   ASSERT_FALSE(S.getError());
-  ASSERT_FALSE(S->isDirectory());
-  ASSERT_TRUE(S->IsVFSMapped);
-  ASSERT_EQ("//root/foo/bar/a", S->getName());
+  EXPECT_FALSE(S->isDirectory());
+  EXPECT_TRUE(S->IsVFSMapped);
+  EXPECT_EQ("//root/foo/bar/a", S->getName());
 
   // file in remapped directory, with use-external-name=false
   S = O->status("//root/mappeddir2/a");
   ASSERT_FALSE(S.getError());
-  ASSERT_FALSE(S->isDirectory());
-  ASSERT_TRUE(S->IsVFSMapped);
-  ASSERT_EQ("//root/mappeddir2/a", S->getName());
+  EXPECT_FALSE(S->isDirectory());
+  EXPECT_FALSE(S->IsVFSMapped);
+  EXPECT_EQ("//root/mappeddir2/a", S->getName());
 
   // file contents in remapped directory
   OpenedF = O->openFileForRead("//root/mappeddir/a");
@@ -1503,7 +1503,7 @@
   OpenedS = (*OpenedF)->status();
   ASSERT_FALSE(OpenedS.getError());
   EXPECT_EQ("//root/mappeddir2/a", OpenedS->getName());
-  EXPECT_TRUE(OpenedS->IsVFSMapped);
+  EXPECT_FALSE(OpenedS->IsVFSMapped);
 
   // broken mapping
   EXPECT_EQ(O->status("//root/file2").getError(),
@@ -1776,12 +1776,12 @@
   auto OpenedS = (*OpenedF)->status();
   ASSERT_FALSE(OpenedS.getError());
   EXPECT_EQ("vfsname", OpenedS->getName());
-  EXPECT_TRUE(OpenedS->IsVFSMapped);
+  EXPECT_FALSE(OpenedS->IsVFSMapped);
 
   auto DirectS = FS->status("vfsname");
   ASSERT_FALSE(DirectS.getError());
   EXPECT_EQ("vfsname", DirectS->getName());
-  EXPECT_TRUE(DirectS->IsVFSMapped);
+  EXPECT_FALSE(DirectS->IsVFSMapped);
 
   EXPECT_EQ(0, NumDiagnostics);
 }
Index: llvm/lib/Support/VirtualFileSystem.cpp
===
--- llvm/lib/Support/VirtualFileSystem.cpp
+++ llvm/lib/Support/VirtualFileSystem.cpp
@@ -2163,10 +2163,16 @@
 static Status getRedirectedFileStatus(const Twine &OriginalPath,
   bool UseExternalNames,
   Status ExternalStatus) {
+  // The path has been mapped by some nested VFS, don't override it with the
+  // original path.
+  if (ExternalStatus.IsVFSMapped)
+return ExternalStatus;
+
   Status S = ExternalStatus;
   if (!UseExternalNames)
 S = Status::copyWithNewName(S, OriginalPath);
-  S.IsVFSMapped = true;
+  else
+S.IsVFSMapped = true;
   return S;
 }
 
@@ -2268,7 +2274,9 @@
 
 ErrorOr>
 File::getWithPath(ErrorOr> Result, const Twine &P) {
-  if (!Result)
+  // See \c getRedirectedFileStatus - don't update path if it's already been
+  // mapped.
+  if (!Result || (*Result)->status()->IsVFSMapped)
 return Result;
 
   ErrorOr> F = std::move(*Result);
Index: llvm/include/llvm/Support/VirtualFileSystem.h
===
--- llvm/include/llvm/Support/VirtualFileSystem.h
+++ llvm/include/llvm/Support/VirtualFileSystem.h
@@ -55,8 +55,12 @@
   llvm::sys::fs::perms Perms;
 
 public:
-  // FIXME: remove when files support multiple names
+  /// Whether the path in this status has been mapped by a VFS to another path.
   bool IsVFSMapped = false;
+  // Note: Currently used by a hack in \c FileManager and internally in
+  // \c RedirectingFileSystem. We should change this to "HasVFSMapping" and
+  // *always* return the virtual path, only providing the mapped/external path
+  // when requested.
 
   Status() = default;
   Status(const llvm::sys::fs::file_status &Status);
Index: clang/test/VFS/external-names-multi-overlay.c
===
--- /d

[PATCH] D122529: [ASTMatchers] Output currently matching node on crash

2022-03-27 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 418473.
njames93 added a comment.

Update tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122529

Files:
  clang/lib/ASTMatchers/ASTMatchFinder.cpp
  clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp
@@ -15,6 +15,7 @@
 #include "llvm/Config/config.h"
 #include "llvm/Support/Host.h"
 #include "llvm/Testing/Support/SupportHelpers.h"
+#include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
 namespace clang {
@@ -39,10 +40,24 @@
 // FIXME: Figure out why back traces aren't being generated on clang builds on
 // windows.
 #if ENABLE_BACKTRACES && (!defined(_MSC_VER) || !defined(__clang__))
+
+AST_MATCHER(Decl, causeCrash) {
+  abort();
+  return true;
+}
+
+TEST(MatcherCrashDeathTest, CrashOnMatcherDump) {
+  llvm::EnablePrettyStackTrace();
+  auto Matcher = testing::HasSubstr(
+  "ASTMatcher: Matching '' against:\n\tFunctionDecl foo : "
+  "");
+  ASSERT_DEATH(matches("void foo();", functionDecl(causeCrash())), Matcher);
+}
+
 template 
 static void crashTestNodeDump(MatcherT Matcher,
   ArrayRef MatchedNodes,
-  StringRef Code) {
+  StringRef Against, StringRef Code) {
   llvm::EnablePrettyStackTrace();
   MatchFinder Finder;
 
@@ -58,7 +73,9 @@
 ASSERT_DEATH(tooling::runToolOnCode(
  newFrontendActionFactory(&Finder)->create(), Code),
  testing::HasSubstr(
- "ASTMatcher: Processing 'CrashTester'\nNo bound nodes"));
+ ("ASTMatcher: Processing 'CrashTester' against:\n\t" +
+  Against + "\nNo bound nodes")
+ .str()));
   } else {
 std::vector>>
@@ -69,7 +86,9 @@
 }
 auto CrashMatcher = testing::AllOf(
 testing::HasSubstr(
-"ASTMatcher: Processing 'CrashTester'\n--- Bound Nodes Begin ---"),
+("ASTMatcher: Processing 'CrashTester' against:\n\t" + Against +
+ "\n--- Bound Nodes Begin ---")
+.str()),
 testing::HasSubstr("--- Bound Nodes End ---"),
 testing::AllOfArray(Matchers));
 
@@ -79,7 +98,8 @@
   }
 }
 TEST(MatcherCrashDeathTest, CrashOnCallbackDump) {
-  crashTestNodeDump(forStmt(), {}, "void foo() { for(;;); }");
+  crashTestNodeDump(forStmt(), {}, "ForStmt : ",
+"void foo() { for(;;); }");
   crashTestNodeDump(
   forStmt(hasLoopInit(declStmt(hasSingleDecl(
varDecl(hasType(qualType().bind("QT")),
@@ -94,6 +114,7 @@
"IL - { IntegerLiteral :  }", "QT - { QualType : int }",
"T - { BuiltinType : int }",
"VD - { VarDecl I :  }"},
+  "ForStmt : ",
   R"cpp(
   void foo() {
 for (int I = 0; I < 5; ++I) {
@@ -106,12 +127,14 @@
   {"Unnamed - { CXXRecordDecl (anonymous) :  }",
"Op+ - { CXXMethodDecl (anonymous struct)::operator+ :  }"},
+  "CXXRecordDecl (anonymous) : ",
   "struct { int operator+(int) const; } Unnamed;");
   crashTestNodeDump(
   cxxRecordDecl(hasMethod(cxxConstructorDecl(isDefaulted()).bind("Ctor")),
 hasMethod(cxxDestructorDecl(isDefaulted()).bind("Dtor"))),
   {"Ctor - { CXXConstructorDecl Foo::Foo :  }",
"Dtor - { CXXDestructorDecl Foo::~Foo :  }"},
+  "CXXRecordDecl Foo : ",
   "struct Foo { Foo() = default; ~Foo() = default; };");
 }
 #endif // ENABLE_BACKTRACES
Index: clang/lib/ASTMatchers/ASTMatchFinder.cpp
===
--- clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -761,53 +761,166 @@
 D);
   }
 
+private:
+  bool TraversingASTNodeNotSpelledInSource = false;
+  bool TraversingASTNodeNotAsIs = false;
+  bool TraversingASTChildrenNotSpelledInSource = false;
+
+  class CurMatchData {
+  public:
+CurMatchData() = default;
+
+template 
+void SetCallbackAndRawNode(const MatchCallback *CB, const NodeType &N) {
+  assertEmpty();
+  Callback = CB;
+  MatchingNode = &N;
+}
+
+const MatchCallback *getCallback() const { return Callback; }
+
+void SetBoundNodes(const BoundNodes &BN) {
+  assertHoldsState();
+  BNodes = &BN;
+}
+
+void clearBoundNodes() {
+  assertHoldsState();
+  BNodes = nullptr;
+}
+
+template  const T *getNode() const {
+  assertHoldsState();
+  return MatchingNode.dyn_cast();
+}
+
+const BoundNodes *getBoundNodes() const {
+  assertHoldsState();
+  return BNodes;
+}
+
+void reset() {
+  assertHoldsState();
+  Callback = nullptr;

[PATCH] D122468: [clang-format] Fix SeparateDefinitionBlocks breaking up function-try-block.

2022-03-27 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

We can refactor by extending `_verifyFormat()` instead of adding a new function.




Comment at: clang/unittests/Format/DefinitionBlockSeparatorTest.cpp:46
 const FormatStyle &Style = getLLVMStyle(),
 llvm::StringRef ExpectedCode = "") {
 ::testing::ScopedTrace t(File, Line, ::testing::Message() << Code.str());





Comment at: clang/unittests/Format/DefinitionBlockSeparatorTest.cpp:54
 
 FormatStyle InverseStyle = Style;
 if (Style.SeparateDefinitionBlocks == FormatStyle::SDS_Always)





Comment at: clang/unittests/Format/DefinitionBlockSeparatorTest.cpp:64
 << "Inverse formatting makes no difference";
 std::string CodeToFormat =
 HasOriginalCode ? Code.str() : removeEmptyLines(Code);





Comment at: clang/unittests/Format/DefinitionBlockSeparatorTest.cpp:476
+  Style.SeparateDefinitionBlocks = FormatStyle::SDS_Always;
+  verifyFormatNoInverse("void FunctionWithInternalTry()\n"
+"{\n"





Comment at: clang/unittests/Format/DefinitionBlockSeparatorTest.cpp:486
+"}",
+Style);
+  verifyFormatNoInverse("void FunctionWithTryBlock()\n"




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122468

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


[PATCH] D121868: [cc1as] Add support for emitting the build version load command for -darwin-target-variant

2022-03-27 Thread Byoungchan Lee via Phabricator via cfe-commits
bc-lee added a comment.

Hi, could you have a look at it once more?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121868

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


[PATCH] D122104: [X86][regcall] Support passing / returning structures

2022-03-27 Thread LuoYuanke via Phabricator via cfe-commits
LuoYuanke accepted this revision.
LuoYuanke added a comment.
This revision is now accepted and ready to land.

LGTM, thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122104

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


[PATCH] D122533: [AVR] Remove AVRRelaxMemOperations

2022-03-27 Thread Ben Shi via Phabricator via cfe-commits
benshi001 accepted this revision.
benshi001 added a comment.
This revision is now accepted and ready to land.

@aykevl How about your opinion? I think current form is good!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122533

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


[PATCH] D122533: [AVR] Remove AVRRelaxMemOperations

2022-03-27 Thread Ben Shi via Phabricator via cfe-commits
benshi001 added a comment.

In D122533#3410259 , @Patryk27 wrote:

> Ok, I have added the switch; I think a separate patch that adds that switch 
> to all of the AVR tests could come handy - what do you think?

No. `-verify-machineinstrs` might be default in the future, which is still 
under discuss. Currently we just make highly risky case with explicit 
`-verify-machineinstrs`, such as yours. ^_^


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122533

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


[PATCH] D121556: [randstruct] Add randomize structure layout support

2022-03-27 Thread Bill Wendling via Phabricator via cfe-commits
void updated this revision to Diff 418480.
void added a comment.

- Make sure the command line seed is properly passed on to each front-end level.
- Some general cleanups.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121556

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/Randstruct.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/AST/CMakeLists.txt
  clang/lib/AST/Decl.cpp
  clang/lib/AST/Randstruct.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/unittests/AST/CMakeLists.txt
  clang/unittests/AST/RandstructTest.cpp

Index: clang/unittests/AST/RandstructTest.cpp
===
--- /dev/null
+++ clang/unittests/AST/RandstructTest.cpp
@@ -0,0 +1,414 @@
+//===- unittest/AST/RandstructTest.cpp ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file contains tests for Clang's structure field layout randomization.
+//
+//===--===//
+
+/*
+ * Build this test suite by running `make ASTTests` in the build folder.
+ *
+ * Run this test suite by running the following in the build folder:
+ * ` ./tools/clang/unittests/AST/ASTTests
+ * --gtest_filter=StructureLayoutRandomization*`
+ */
+
+#include "clang/AST/Randstruct.h"
+#include "gtest/gtest.h"
+
+#include "DeclMatcher.h"
+#include "clang/AST/RecordLayout.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Frontend/ASTUnit.h"
+#include "clang/Testing/CommandLineArgs.h"
+#include "clang/Tooling/Tooling.h"
+
+#include 
+
+using namespace clang;
+using namespace clang::ast_matchers;
+using namespace clang::randstruct;
+
+using field_names = std::vector;
+
+namespace {
+
+std::unique_ptr makeAST(const std::string &SourceCode) {
+  std::vector Args = getCommandLineArgsForTesting(Lang_C99);
+  Args.push_back("-frandstruct-seed=1234567890abcdef");
+
+  std::unique_ptr AST =
+  tooling::buildASTFromCodeWithArgs(SourceCode, Args);
+
+  EXPECT_FALSE(AST->getDiagnostics().hasErrorOccurred());
+  return AST;
+}
+
+RecordDecl *getRecordDeclFromAST(const ASTContext &C, const std::string &Name) {
+  return FirstDeclMatcher().match(C.getTranslationUnitDecl(),
+  recordDecl(hasName(Name)));
+}
+
+std::vector getFieldNamesFromRecord(const RecordDecl *RD) {
+  std::vector Fields;
+
+  Fields.reserve(8);
+  for (auto *Field : RD->fields())
+Fields.push_back(Field->getNameAsString());
+
+  return Fields;
+}
+
+bool isSubsequence(const field_names &Seq, const field_names &Subseq) {
+  unsigned SeqLen = Seq.size();
+  unsigned SubLen = Subseq.size();
+
+  bool IsSubseq = false;
+  for (unsigned I = 0; I < SeqLen; ++I)
+if (Seq[I] == Subseq[0]) {
+  IsSubseq = true;
+  for (unsigned J = 0; J + I < SeqLen && J < SubLen; ++J) {
+if (Seq[J + I] != Subseq[J]) {
+  IsSubseq = false;
+  break;
+}
+  }
+}
+
+  return IsSubseq;
+}
+
+} // end anonymous namespace
+
+namespace clang {
+namespace ast_matchers {
+
+#define RANDSTRUCT_TEST_SUITE_TEST StructureLayoutRandomizationTestSuiteTest
+
+TEST(RANDSTRUCT_TEST_SUITE_TEST, CanDetermineIfSubsequenceExists) {
+  const field_names Seq = {"a", "b", "c", "d"};
+
+  ASSERT_TRUE(isSubsequence(Seq, {"b", "c"}));
+  ASSERT_TRUE(isSubsequence(Seq, {"a", "b", "c", "d"}));
+  ASSERT_TRUE(isSubsequence(Seq, {"b", "c", "d"}));
+  ASSERT_TRUE(isSubsequence(Seq, {"a"}));
+  ASSERT_FALSE(isSubsequence(Seq, {"a", "d"}));
+}
+
+#define RANDSTRUCT_TEST StructureLayoutRandomization
+
+TEST(RANDSTRUCT_TEST, UnmarkedStruct) {
+  const std::unique_ptr AST = makeAST(R"c(
+struct test {
+int bacon;
+long lettuce;
+long long tomato;
+float mayonnaise;
+};
+  )c");
+
+  const RecordDecl *RD = getRecordDeclFromAST(AST->getASTContext(), "test");
+  const field_names Expected = {"bacon", "lettuce", "tomato", "mayonnaise"};
+
+  ASSERT_FALSE(RD->getAttr());
+  ASSERT_FALSE(RD->isRandomized());
+  ASSERT_EQ(Expected, getFieldNamesFromRecord(RD));
+}
+
+TEST(RANDSTRUCT_TEST, MarkedNoRandomize) {
+  const std::unique_ptr AST = makeAST(R"c(
+s

[PATCH] D122524: [clang][AVR] Generate link warnings properly

2022-03-27 Thread Ben Shi via Phabricator via cfe-commits
benshi001 updated this revision to Diff 418481.

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

https://reviews.llvm.org/D122524

Files:
  clang/lib/Driver/ToolChains/AVR.cpp
  clang/test/Driver/avr-toolchain.c

Index: clang/test/Driver/avr-toolchain.c
===
--- clang/test/Driver/avr-toolchain.c
+++ clang/test/Driver/avr-toolchain.c
@@ -1,7 +1,7 @@
 // UNSUPPORTED: system-windows
 // A basic clang -cc1 command-line.
 
-// RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree -resource-dir=%S/Inputs/resource_dir 2>&1 | FileCheck --check-prefix=CHECK1 %s
+// RUN: %clang %s -### --target=avr --sysroot %S/Inputs/basic_avr_tree -resource-dir=%S/Inputs/resource_dir 2>&1 | FileCheck --check-prefix=CHECK1 %s
 // CHECK1: clang{{.*}} "-cc1" "-triple" "avr"
 // CHECK1-SAME: "-resource-dir" "[[RESOURCE:[^"]+]]"
 // CHECK1-SAME: "-isysroot" "[[SYSROOT:[^"]+/basic_avr_tree]]"
@@ -12,26 +12,57 @@
 // CHECK1-SAME: "-o" "a.out"
 // CHECK1-SAME: {{^}} "--gc-sections"
 
-// RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree_2/opt/local -S 2>&1 | FileCheck --check-prefix=CHECK2 %s
+// RUN: %clang %s -### --target=avr --sysroot %S/Inputs/basic_avr_tree_2/opt/local -S 2>&1 | FileCheck --check-prefix=CHECK2 %s
 // CHECK2: clang{{.*}} "-cc1" "-triple" "avr"
 // CHECK2-SAME: "-isysroot" "[[SYSROOT:[^"]+/basic_avr_tree_2/opt/local]]"
 // CHECK2-SAME: "-internal-isystem"
 // CHECK2-SAME: {{^}} "[[SYSROOT]]/lib/gcc/avr/10.3.0/../../../../avr/include"
 
-// RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree_2 -S 2>&1 | FileCheck --check-prefix=CHECK3 %s
+// RUN: %clang %s -### --target=avr --sysroot %S/Inputs/basic_avr_tree_2 -S 2>&1 | FileCheck --check-prefix=CHECK3 %s
 // CHECK3: clang{{.*}} "-cc1" "-triple" "avr"
 // CHECK3-SAME: "-isysroot" "[[SYSROOT:[^"]+/basic_avr_tree_2]]"
 // CHECK3-SAME: "-internal-isystem"
 // CHECK3-SAME: {{^}} "[[SYSROOT]]/usr/avr/include"
 
-// RUN: %clang %s -### -target avr 2>&1 | FileCheck -check-prefix=CC1 %s
+// RUN: %clang %s -### --target=avr 2>&1 | FileCheck -check-prefix=CC1 %s
 // CC1: clang{{.*}} "-cc1" "-triple" "avr" {{.*}} "-fno-use-init-array" "-fno-use-cxa-atexit"
 
-// RUN: %clang %s -### -target avr -fuse-init-array -fuse-cxa-atexit 2>&1 | FileCheck -check-prefix=CHECK4 %s
+// RUN: %clang %s -### --target=avr -fuse-init-array -fuse-cxa-atexit 2>&1 | FileCheck -check-prefix=CHECK4 %s
 // CHECK4: clang{{.*}} "-cc1" "-triple" "avr"
 // CHECK4-NOT: "-fno-use-init-array"
 // CHECK4-NOT: "-fno-use-cxa-atexit"
 
-// RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 -nostdinc | FileCheck --check-prefix=NOSTDINC %s
-// RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 -nostdlibinc | FileCheck --check-prefix=NOSTDINC %s
+// RUN: %clang %s -### --target=avr --sysroot %S/Inputs/basic_avr_tree 2>&1 -nostdinc | FileCheck --check-prefix=NOSTDINC %s
+// RUN: %clang %s -### --target=avr --sysroot %S/Inputs/basic_avr_tree 2>&1 -nostdlibinc | FileCheck --check-prefix=NOSTDINC %s
 // NOSTDINC-NOT: "-internal-isystem" {{".*avr/include"}}
+
+// RUN: %clang %s -### --target=avr --sysroot %S/Inputs/basic_avr_tree -mmcu=atmega328 2>&1 | FileCheck --check-prefix=CHECK5 %s
+// CHECK5-NOT: warning: no {{.*}} microcontroller
+// CHECK5-NOT: warning: no avr-gcc
+// CHECK5-NOT: warning: {{.*}} library not linked
+
+// RUN: %clang %s -### --target=avr --sysroot %S/Inputs/ -mmcu=atmega328 2>&1 | FileCheck --check-prefix=CHECK6 %s
+// CHECK6-NOT: warning: no {{.*}} microcontroller
+// CHECK6: warning: no avr-gcc installation can be found on the system, cannot link standard libraries
+// CHECK6: warning: standard library not linked and so no interrupt vector table or compiler runtime routines will be linked
+
+// RUN: %clang %s -### --target=avr --sysroot %S/Inputs/basic_avr_tree 2>&1 | FileCheck --check-prefix=CHECK7 %s
+// CHECK7: warning: no target microcontroller specified on command line, cannot link standard libraries
+// CHECK7-NOT: warning: no avr-gcc
+// CHECK7: warning: standard library not linked and so no interrupt vector table or compiler runtime routines will be linked
+
+// RUN: %clang %s -### --target=avr --sysroot %S/Inputs/basic_avr_tree -c 2>&1 | FileCheck --check-prefix=CHECK8 %s
+// RUN: %clang %s -### --target=avr --sysroot %S/Inputs/basic_avr_tree -S 2>&1 | FileCheck --check-prefix=CHECK8 %s
+// RUN: %clang %s -### --target=avr --sysroot %S/Inputs/basic_avr_tree -E 2>&1 | FileCheck --check-prefix=CHECK8 %s
+// RUN: %clang %s -### --target=avr --sysroot %S/Inputs/basic_avr_tree -fsyntax-only 2>&1 | FileCheck --check-prefix=CHECK8 %s
+// CHECK8: warning: no target microcontroller specified on command line, cannot link standard libraries
+// CHECK8-NOT: warning: no avr-gcc
+// CHECK8-NOT: warning: {{.*}} library not linked
+
+// RUN: %clang %s -### --target=avr --sysroot %S/Inputs/basic_avr_tree -mmcu=atmega328 -c 2>&1 | FileCheck --

[PATCH] D119409: [C++20] [Modules] Remain dynamic initializing internal-linkage variables in module interface unit

2022-03-27 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D119409#3409806 , @iains wrote:

> I think that this problem might well be a consequence of the bug which is 
> fixed by D122413 .
>
> We have been generating code with module internal entities (always) given the 
> special ModuleInternalLinkage (which means that, although the linkage is 
> formally 'internal', the entities are made global when emitted.  We should 
> only be doing this for fmodules-ts, not for regular standard modules.
>
> If you apply D122413  (which I hope to land 
> soon), then I would expect that iostream should work as expected (with one 
> internal instance of std::__ioinit in each TU that includes iostream).
>
> IFF (after applying D122413  ) you add to 
> the command line -fmodules-ts, then the patch here (D119409 
> ) would, presumably, be needed to work 
> around multiple instances of the globalised std::__ioinit.

Sadly it wouldn't work after D122413  
applied. Since the  is lived in GlobalModuleFragment, the calculated 
linkage wouldn't affect them. So I met the same segfault as before.

> addendum: note we still have work to do on the module initialisers - those 
> are not correct yet (so probably some nesting of modules might not work).

What does the nesting of modules mean?


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

https://reviews.llvm.org/D119409

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


[PATCH] D120129: [NVPTX] Enhance vectorization of ld.param & st.param

2022-03-27 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert requested changes to this revision.
jdoerfert added a comment.
This revision now requires changes to proceed.

Please revert this commit. It breaks any code using the cuda.11.0.2 
libdevice.bc file, the source of the `null` `nvvm.annotations` and the 
annotations with 5 arguments. See below.
Once a fix is in, and a test is added, we can reapply this.

  $ opt -S .../cuda-11.0.2/nvvm/libdevice/libdevice.10.bc | tail
  !nvvm.annotations = !{!1, !2, !1, !3, !3, !3, !3, !4, !4, !3}
  
  !0 = !{i32 1, i32 4}
  !1 = !{null, !"align", i32 8}
  !2 = !{null, !"align", i32 8, !"align", i32 65544, !"align", i32 131080}
  !3 = !{null, !"align", i32 16}
  !4 = !{null, !"align", i32 16, !"align", i32 65552, !"align", i32 131088}
  !5 = distinct !{!5, !6}jdoerfert@jlselogin6 ~ ❯❯❯ opt -S 
/soft/compilers/cuda/cuda-11.0.2/nvvm/libdevice/libdevice.10.bc | tail
  !nvvm.annotations = !{!1, !2, !1, !3, !3, !3, !3, !4, !4, !3}
  
  !0 = !{i32 1, i32 4}
  !1 = !{null, !"align", i32 8}
  !2 = !{null, !"align", i32 8, !"align", i32 65544, !"align", i32 131080}
  !3 = !{null, !"align", i32 16}
  !4 = !{null, !"align", i32 16, !"align", i32 65552, !"align", i32 131088}
  !5 = distinct !{!5, !6}
  !6 = !{!"llvm.loop.unroll.count", i32 1}
  !7 = distinct !{!7, !6}


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120129

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


[PATCH] D122478: [PowerPC] Add max/min intrinsics to Clang and PPC backend

2022-03-27 Thread Ting Wang via Phabricator via cfe-commits
tingwang updated this revision to Diff 418485.
tingwang added a comment.

Option -mlong-double-128 is not supported on AIX currently, and clang fails due 
to type mismatch in the fe case. Add check logic to print diag message in this 
case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122478

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/PowerPC/builtins-ppc.c
  clang/test/Sema/builtins-ppc.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-maxmin.ll

Index: llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-maxmin.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-maxmin.ll
@@ -0,0 +1,150 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mcpu=pwr9 -mtriple=powerpc64le-unknown-linux < %s | FileCheck %s
+
+declare ppc_fp128 @llvm.ppc.maxfe(ppc_fp128 %a, ppc_fp128 %b, ppc_fp128 %c, ...)
+define ppc_fp128 @test_maxfe(ppc_fp128 %a, ppc_fp128 %b, ppc_fp128 %c, ppc_fp128 %d) {
+; CHECK-LABEL: test_maxfe:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:fcmpu 0, 6, 4
+; CHECK-NEXT:fcmpu 1, 5, 3
+; CHECK-NEXT:crand 20, 6, 1
+; CHECK-NEXT:cror 20, 5, 20
+; CHECK-NEXT:bc 12, 20, .LBB0_2
+; CHECK-NEXT:  # %bb.1: # %entry
+; CHECK-NEXT:fmr 6, 4
+; CHECK-NEXT:  .LBB0_2: # %entry
+; CHECK-NEXT:fcmpu 0, 6, 2
+; CHECK-NEXT:bc 12, 20, .LBB0_4
+; CHECK-NEXT:  # %bb.3: # %entry
+; CHECK-NEXT:fmr 5, 3
+; CHECK-NEXT:  .LBB0_4: # %entry
+; CHECK-NEXT:fcmpu 1, 5, 1
+; CHECK-NEXT:crand 20, 6, 1
+; CHECK-NEXT:cror 20, 5, 20
+; CHECK-NEXT:bc 12, 20, .LBB0_6
+; CHECK-NEXT:  # %bb.5: # %entry
+; CHECK-NEXT:fmr 6, 2
+; CHECK-NEXT:  .LBB0_6: # %entry
+; CHECK-NEXT:fcmpu 0, 6, 8
+; CHECK-NEXT:bc 12, 20, .LBB0_8
+; CHECK-NEXT:  # %bb.7: # %entry
+; CHECK-NEXT:fmr 5, 1
+; CHECK-NEXT:  .LBB0_8: # %entry
+; CHECK-NEXT:fcmpu 1, 5, 7
+; CHECK-NEXT:crand 20, 6, 1
+; CHECK-NEXT:cror 20, 5, 20
+; CHECK-NEXT:bc 12, 20, .LBB0_10
+; CHECK-NEXT:  # %bb.9: # %entry
+; CHECK-NEXT:fmr 5, 7
+; CHECK-NEXT:  .LBB0_10: # %entry
+; CHECK-NEXT:bc 12, 20, .LBB0_12
+; CHECK-NEXT:  # %bb.11: # %entry
+; CHECK-NEXT:fmr 6, 8
+; CHECK-NEXT:  .LBB0_12: # %entry
+; CHECK-NEXT:fmr 1, 5
+; CHECK-NEXT:fmr 2, 6
+; CHECK-NEXT:blr
+entry:
+  %0 = call ppc_fp128 (ppc_fp128, ppc_fp128, ppc_fp128, ...) @llvm.ppc.maxfe(ppc_fp128 %a, ppc_fp128 %b, ppc_fp128 %c, ppc_fp128 %d)
+  ret ppc_fp128 %0
+}
+
+declare double @llvm.ppc.maxfl(double %a, double %b, double %c, ...)
+define double @test_maxfl(double %a, double %b, double %c, double %d) {
+; CHECK-LABEL: test_maxfl:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:xsmaxcdp 0, 3, 2
+; CHECK-NEXT:xsmaxcdp 0, 0, 1
+; CHECK-NEXT:xsmaxcdp 1, 0, 4
+; CHECK-NEXT:blr
+entry:
+  %0 = call double (double, double, double, ...) @llvm.ppc.maxfl(double %a, double %b, double %c, double %d)
+  ret double %0
+}
+
+declare float @llvm.ppc.maxfs(float %a, float %b, float %c, ...)
+define float @test_maxfs(float %a, float %b, float %c, float %d) {
+; CHECK-LABEL: test_maxfs:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:xsmaxcdp 0, 3, 2
+; CHECK-NEXT:xsmaxcdp 0, 0, 1
+; CHECK-NEXT:xsmaxcdp 1, 0, 4
+; CHECK-NEXT:blr
+entry:
+  %0 = call float (float, float, float, ...) @llvm.ppc.maxfs(float %a, float %b, float %c, float %d)
+  ret float %0
+}
+
+declare ppc_fp128 @llvm.ppc.minfe(ppc_fp128 %a, ppc_fp128 %b, ppc_fp128 %c, ...)
+define ppc_fp128 @test_minfe(ppc_fp128 %a, ppc_fp128 %b, ppc_fp128 %c, ppc_fp128 %d) {
+; CHECK-LABEL: test_minfe:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:fcmpu 0, 6, 4
+; CHECK-NEXT:fcmpu 1, 5, 3
+; CHECK-NEXT:crand 20, 6, 0
+; CHECK-NEXT:cror 20, 4, 20
+; CHECK-NEXT:bc 12, 20, .LBB3_2
+; CHECK-NEXT:  # %bb.1: # %entry
+; CHECK-NEXT:fmr 6, 4
+; CHECK-NEXT:  .LBB3_2: # %entry
+; CHECK-NEXT:fcmpu 0, 6, 2
+; CHECK-NEXT:bc 12, 20, .LBB3_4
+; CHECK-NEXT:  # %bb.3: # %entry
+; CHECK-NEXT:fmr 5, 3
+; CHECK-NEXT:  .LBB3_4: # %entry
+; CHECK-NEXT:fcmpu 1, 5, 1
+; CHECK-NEXT:crand 20, 6, 0
+; CHECK-NEXT:cror 20, 4, 20
+; CHECK-NEXT:bc 12, 20, .LBB3_6
+; CHECK-NEXT:  # %bb.5: # %entry
+; CHECK-NEXT:fmr 6, 2
+; CHECK-NEXT:  .LBB3_6: # %entry
+; CHECK-NEXT:fcmpu 0, 6, 8
+; CHECK-NEXT:bc 12, 20, .LBB3_8
+; CHECK-NEXT:  # %bb.7: # %entry
+; CHECK-NEXT:fmr 5, 1
+; CHECK-NEXT:  .LBB3_8: # %entry
+; CHECK-NEXT:fcmpu 1, 5, 7
+; CHECK-NEXT:crand 20, 6, 0
+; CHECK-NEXT:cror 20, 4, 20
+; CHECK-NEXT:bc 12, 20, .LBB3_10
+; CHECK-NEXT:  # %bb.

[PATCH] D122460: [clang] fixed bug #54406

2022-03-27 Thread Randy via Phabricator via cfe-commits
randyli planned changes to this revision.
randyli added inline comments.



Comment at: clang/lib/Sema/SemaExprMember.cpp:690
+// int n = a.B::m;
+if (BaseExpr && isa(DC) && isa(RDecl)) {
+  CXXRecordDecl *SRecord = cast(DC)->getCanonicalDecl();

rjmccall wrote:
> We don't generally cite bug numbers in the source code; we just cite the 
> language rule.  You can reference the bug number in your test, though.
> 
> The standard says that this is an error even when the member access is 
> implicit, so the check for `BaseExpr` is incorrect.
> 
> Conversely, the standard says this is not an error when the declaration 
> referenced is not a non-static data member or member function, so you cannot 
> do this before the lookup; in fact, you cannot do it until we've fully 
> resolved the lookup, which may require contextual information.
> 
> All of the code paths that build a non-static member eventually funnel into 
> `BuildMemberExpr`, so maybe that's the right place for the check?  But note 
> that you have to check explicitly for a non-static member, because 
> `MemberExpr` is used for all of them.
> 
> Technically, this rule wasn't in C++98, but since it does appear in C++03, I 
> agree we should just enforce it unconditionally, as we usually treat C++03 as 
> an errata release rather than its own language mode.
ok,  thank you for the suggestion,  I'll look into BuildMemeberExpr and try 
again 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122460

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


[PATCH] D120129: [NVPTX] Enhance vectorization of ld.param & st.param

2022-03-27 Thread Daniil Kovalev via Phabricator via cfe-commits
kovdan01 added a comment.

In D120129#3410479 , @jdoerfert wrote:

> Please revert this commit. It breaks any code using the cuda.11.0.2 
> libdevice.bc file, the source of the `null` `nvvm.annotations` and the 
> annotations with 5 arguments. See below.
> Once a fix is in, and a test is added, we can reapply this.
>
>   $ opt -S .../cuda-11.0.2/nvvm/libdevice/libdevice.10.bc | tail
>   !nvvm.annotations = !{!1, !2, !1, !3, !3, !3, !3, !4, !4, !3}
>   
>   !0 = !{i32 1, i32 4}
>   !1 = !{null, !"align", i32 8}
>   !2 = !{null, !"align", i32 8, !"align", i32 65544, !"align", i32 131080}
>   !3 = !{null, !"align", i32 16}
>   !4 = !{null, !"align", i32 16, !"align", i32 65552, !"align", i32 131088}
>   !5 = distinct !{!5, !6}

Got it, will revert the patch shortly. Could you please describe what do you 
mean by "break" in a bit more detail? Is that only about poorly designed and 
failing assertions in `getFunctionParamOptimizedAlign` or there are some other 
(maybe even functional) issues? If that's only about assertions, won't using 
`isKernelFunction` (as suggested in D122550 ) 
help?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120129

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


[PATCH] D120129: [NVPTX] Enhance vectorization of ld.param & st.param

2022-03-27 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D120129#3410493 , @kovdan01 wrote:

> In D120129#3410479 , @jdoerfert 
> wrote:
>
>> Please revert this commit. It breaks any code using the cuda.11.0.2 
>> libdevice.bc file, the source of the `null` `nvvm.annotations` and the 
>> annotations with 5 arguments. See below.
>> Once a fix is in, and a test is added, we can reapply this.
>>
>>   $ opt -S .../cuda-11.0.2/nvvm/libdevice/libdevice.10.bc | tail
>>   !nvvm.annotations = !{!1, !2, !1, !3, !3, !3, !3, !4, !4, !3}
>>   
>>   !0 = !{i32 1, i32 4}
>>   !1 = !{null, !"align", i32 8}
>>   !2 = !{null, !"align", i32 8, !"align", i32 65544, !"align", i32 131080}
>>   !3 = !{null, !"align", i32 16}
>>   !4 = !{null, !"align", i32 16, !"align", i32 65552, !"align", i32 131088}
>>   !5 = distinct !{!5, !6}
>
> Got it, will revert the patch shortly. Could you please describe what do you 
> mean by "break" in a bit more detail? Is that only about poorly designed and 
> failing assertions in `getFunctionParamOptimizedAlign` or there are some 
> other (maybe even functional) issues? If that's only about assertions, won't 
> using `isKernelFunction` (as suggested in D122550 
> ) help?

The two assertions introduced here do not hold for the libdevice.bc above. So 
whenever we link the above we will cause the assertions to fail. That's what I 
mean with break. isKernelFunction is probably going to fix all that. For a 
test, copy annotations like the above into one of the .ll files and make sure 
it contains a private/internal function w/ arguments as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120129

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


[PATCH] D120129: [NVPTX] Enhance vectorization of ld.param & st.param

2022-03-27 Thread Daniil Kovalev via Phabricator via cfe-commits
kovdan01 added a comment.

In D120129#3410510 , @jdoerfert wrote:

> The two assertions introduced here do not hold for the libdevice.bc above. So 
> whenever we link the above we will cause the assertions to fail. That's what 
> I mean with break. isKernelFunction is probably going to fix all that. For a 
> test, copy annotations like the above into one of the .ll files and make sure 
> it contains a private/internal function w/ arguments as well.

OK, thanks for the explanation! Can we just submit a new patch with a fix (like 
D122550 ) instead of reverting this one? The 
problem with revert is that we should also revert D122381 
 which depends on this patch. Also, adding 
tests for `null` `nvvm.annotations` and the annotations with 5 arguments IMHO 
will look better when submitted as a separate patch. So, it revert crucial for 
you or can we just submit a fix separately?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120129

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


[PATCH] D120129: [NVPTX] Enhance vectorization of ld.param & st.param

2022-03-27 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D120129#3410512 , @kovdan01 wrote:

> In D120129#3410510 , @jdoerfert 
> wrote:
>
>> The two assertions introduced here do not hold for the libdevice.bc above. 
>> So whenever we link the above we will cause the assertions to fail. That's 
>> what I mean with break. isKernelFunction is probably going to fix all that. 
>> For a test, copy annotations like the above into one of the .ll files and 
>> make sure it contains a private/internal function w/ arguments as well.
>
> OK, thanks for the explanation! Can we just submit a new patch with a fix 
> (like D122550 ) instead of reverting this 
> one? The problem with revert is that we should also revert D122381 
>  which depends on this patch. Also, adding 
> tests for `null` `nvvm.annotations` and the annotations with 5 arguments IMHO 
> will look better when submitted as a separate patch. So, is revert crucial 
> for you or can we just submit a fix separately?

Our internal build bots and CI for some projects are broken for 3 days. I wish 
to unbreak them so we get actual meaningful results, e.g., see if something 
else is breaking our build. I'm fine with a separate patch on top but I would 
prefer it now so people can run code on Monday.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120129

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


[PATCH] D120129: [NVPTX] Enhance vectorization of ld.param & st.param

2022-03-27 Thread Daniil Kovalev via Phabricator via cfe-commits
kovdan01 added a comment.

In D120129#3410514 , @jdoerfert wrote:

> Our internal build bots and CI for some projects are broken for 3 days. I 
> wish to unbreak them so we get actual meaningful results, e.g., see if 
> something else is breaking our build. I'm fine with a separate patch on top 
> but I would prefer it now so people can run code on Monday.

OK, I'll submit a separate patch within an hour, and if it looks good to you - 
will merge it immediately. The fix looks simple enough so there is no need to 
wait for additional approvals.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120129

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


[PATCH] D122469: OpenMP 5.1 - Support 'seq_cst' clause on 'flush' directive

2022-03-27 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

I think this contains two distinct changes. Please split.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122469

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


[PATCH] D122553: [Driver][AVR] Fix warn_drv_avr_stdlib_not_linked condition

2022-03-27 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: aykevl, benshi001.
Herald added subscribers: StephenFan, Jim, dylanmckay.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Many options (-fsyntax-only, -E, -S, etc) skip the link action phase which the
existing condition does not account for.

Since the code no longer specifies OPT_c, I think a single RUN line about -c
not leading to a warning is sufficient. Adding one for all of -E,
-fsyntax-only, -S would be excessive.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122553

Files:
  clang/lib/Driver/ToolChains/AVR.cpp
  clang/lib/Driver/ToolChains/AVR.h
  clang/test/Driver/avr-link-no-mcu-specified.c
  clang/test/Driver/avr-toolchain.c

Index: clang/test/Driver/avr-toolchain.c
===
--- clang/test/Driver/avr-toolchain.c
+++ clang/test/Driver/avr-toolchain.c
@@ -35,3 +35,11 @@
 // RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 -nostdinc | FileCheck --check-prefix=NOSTDINC %s
 // RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 -nostdlibinc | FileCheck --check-prefix=NOSTDINC %s
 // NOSTDINC-NOT: "-internal-isystem" {{".*avr/include"}}
+
+// RUN: %clang -### --target=avr %s 2>&1 | FileCheck --check-prefix=WARN_STDLIB %s
+// RUN: %clang -### --target=avr -mmcu=atmega328 %s 2>&1 | FileCheck --check-prefix=NOWARN_STDLIB %s
+// RUN: %clang -### --target=avr -c %s 2>&1 | FileCheck --check-prefix=NOWARN_STDLIB %s
+
+// WARN_STDLIB: warning: no target microcontroller specified on command line, cannot link standard libraries, please pass -mmcu=
+// WARN_STDLIB: warning: standard library not linked and so no interrupt vector table or compiler runtime routines will be linked
+// NOWARN_STDLIB-NOT: warning:
Index: clang/test/Driver/avr-link-no-mcu-specified.c
===
--- clang/test/Driver/avr-link-no-mcu-specified.c
+++ /dev/null
@@ -1,10 +0,0 @@
-// RUN: %clang -### -target avr -no-canonical-prefixes -save-temps %s 2>&1 | FileCheck --check-prefix=WARN %s
-// RUN: %clang -### -target avr -no-canonical-prefixes -save-temps -mmcu=atmega328 %s 2>&1 | FileCheck --check-prefix=NOWARN %s
-
-// WARN: warning: no target microcontroller specified on command line, cannot link standard libraries, please pass -mmcu=
-// WARN: warning: standard library not linked and so no interrupt vector table or compiler runtime routines will be linked
-
-// NOWARN: main
-
-int main() { return 0; }
-
Index: clang/lib/Driver/ToolChains/AVR.h
===
--- clang/lib/Driver/ToolChains/AVR.h
+++ clang/lib/Driver/ToolChains/AVR.h
@@ -31,17 +31,14 @@
 llvm::opt::ArgStringList &CC1Args,
 Action::OffloadKind DeviceOffloadKind) const override;
 
+  llvm::Optional findAVRLibcInstallation() const;
+  StringRef getGCCInstallPath() const { return GCCInstallPath; }
+
 protected:
   Tool *buildLinker() const override;
 
 private:
-  /// Whether libgcc, libct, and friends should be linked.
-  ///
-  /// This is not done if the user does not specify a
-  /// microcontroller on the command line.
-  bool LinkStdlib;
-
-  llvm::Optional findAVRLibcInstallation() const;
+  StringRef GCCInstallPath;
 };
 
 } // end namespace toolchains
@@ -50,9 +47,8 @@
 namespace AVR {
 class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
 public:
-  Linker(const llvm::Triple &Triple, const ToolChain &TC, bool LinkStdlib)
-  : Tool("AVR::Linker", "avr-ld", TC), Triple(Triple),
-LinkStdlib(LinkStdlib) {}
+  Linker(const llvm::Triple &Triple, const ToolChain &TC)
+  : Tool("AVR::Linker", "avr-ld", TC), Triple(Triple) {}
 
   bool hasIntegratedCPP() const override { return false; }
   bool isLinkJob() const override { return true; }
@@ -63,7 +59,6 @@
 
 protected:
   const llvm::Triple &Triple;
-  bool LinkStdlib;
 };
 } // end namespace AVR
 } // end namespace tools
Index: clang/lib/Driver/ToolChains/AVR.cpp
===
--- clang/lib/Driver/ToolChains/AVR.cpp
+++ clang/lib/Driver/ToolChains/AVR.cpp
@@ -1,4 +1,4 @@
-//===--- AVR.cpp - AVR ToolChain Implementations *- C++ -*-===//
+//===--- avr.cpp - AVR ToolChain Implementations *- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -366,49 +366,19 @@
 /// AVR Toolchain
 AVRToolChain::AVRToolChain(const Driver &D, const llvm::Triple &Triple,
const ArgList &Args)
-: Generic_ELF(D, Triple, Args), LinkStdlib(false) {
+: Generic_ELF(D, Triple, Args) {
   GCCInstallation.init(Triple, Args);
 
   // Only add default libraries if the user hasn't explicitly

[PATCH] D122524: [clang][AVR] Generate link warnings properly

2022-03-27 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

I think it is excessive to add so many RUN lines. I do not understand much 
about AVR -mcpu. That said, I created D122553 
 for what I think should be done for the 
`-c/-S/-fsyntax-only` condition. More tests would just be excessive.


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

https://reviews.llvm.org/D122524

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


[PATCH] D122553: [Driver][AVR] Fix warn_drv_avr_stdlib_not_linked condition

2022-03-27 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 418493.
MaskRay added a comment.

fix file header


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122553

Files:
  clang/lib/Driver/ToolChains/AVR.cpp
  clang/lib/Driver/ToolChains/AVR.h
  clang/test/Driver/avr-link-no-mcu-specified.c
  clang/test/Driver/avr-toolchain.c

Index: clang/test/Driver/avr-toolchain.c
===
--- clang/test/Driver/avr-toolchain.c
+++ clang/test/Driver/avr-toolchain.c
@@ -35,3 +35,11 @@
 // RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 -nostdinc | FileCheck --check-prefix=NOSTDINC %s
 // RUN: %clang %s -### -target avr --sysroot %S/Inputs/basic_avr_tree 2>&1 -nostdlibinc | FileCheck --check-prefix=NOSTDINC %s
 // NOSTDINC-NOT: "-internal-isystem" {{".*avr/include"}}
+
+// RUN: %clang -### --target=avr %s 2>&1 | FileCheck --check-prefix=WARN_STDLIB %s
+// RUN: %clang -### --target=avr -mmcu=atmega328 %s 2>&1 | FileCheck --check-prefix=NOWARN_STDLIB %s
+// RUN: %clang -### --target=avr -c %s 2>&1 | FileCheck --check-prefix=NOWARN_STDLIB %s
+
+// WARN_STDLIB: warning: no target microcontroller specified on command line, cannot link standard libraries, please pass -mmcu=
+// WARN_STDLIB: warning: standard library not linked and so no interrupt vector table or compiler runtime routines will be linked
+// NOWARN_STDLIB-NOT: warning:
Index: clang/test/Driver/avr-link-no-mcu-specified.c
===
--- clang/test/Driver/avr-link-no-mcu-specified.c
+++ /dev/null
@@ -1,10 +0,0 @@
-// RUN: %clang -### -target avr -no-canonical-prefixes -save-temps %s 2>&1 | FileCheck --check-prefix=WARN %s
-// RUN: %clang -### -target avr -no-canonical-prefixes -save-temps -mmcu=atmega328 %s 2>&1 | FileCheck --check-prefix=NOWARN %s
-
-// WARN: warning: no target microcontroller specified on command line, cannot link standard libraries, please pass -mmcu=
-// WARN: warning: standard library not linked and so no interrupt vector table or compiler runtime routines will be linked
-
-// NOWARN: main
-
-int main() { return 0; }
-
Index: clang/lib/Driver/ToolChains/AVR.h
===
--- clang/lib/Driver/ToolChains/AVR.h
+++ clang/lib/Driver/ToolChains/AVR.h
@@ -31,17 +31,14 @@
 llvm::opt::ArgStringList &CC1Args,
 Action::OffloadKind DeviceOffloadKind) const override;
 
+  llvm::Optional findAVRLibcInstallation() const;
+  StringRef getGCCInstallPath() const { return GCCInstallPath; }
+
 protected:
   Tool *buildLinker() const override;
 
 private:
-  /// Whether libgcc, libct, and friends should be linked.
-  ///
-  /// This is not done if the user does not specify a
-  /// microcontroller on the command line.
-  bool LinkStdlib;
-
-  llvm::Optional findAVRLibcInstallation() const;
+  StringRef GCCInstallPath;
 };
 
 } // end namespace toolchains
@@ -50,9 +47,8 @@
 namespace AVR {
 class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
 public:
-  Linker(const llvm::Triple &Triple, const ToolChain &TC, bool LinkStdlib)
-  : Tool("AVR::Linker", "avr-ld", TC), Triple(Triple),
-LinkStdlib(LinkStdlib) {}
+  Linker(const llvm::Triple &Triple, const ToolChain &TC)
+  : Tool("AVR::Linker", "avr-ld", TC), Triple(Triple) {}
 
   bool hasIntegratedCPP() const override { return false; }
   bool isLinkJob() const override { return true; }
@@ -63,7 +59,6 @@
 
 protected:
   const llvm::Triple &Triple;
-  bool LinkStdlib;
 };
 } // end namespace AVR
 } // end namespace tools
Index: clang/lib/Driver/ToolChains/AVR.cpp
===
--- clang/lib/Driver/ToolChains/AVR.cpp
+++ clang/lib/Driver/ToolChains/AVR.cpp
@@ -366,49 +366,19 @@
 /// AVR Toolchain
 AVRToolChain::AVRToolChain(const Driver &D, const llvm::Triple &Triple,
const ArgList &Args)
-: Generic_ELF(D, Triple, Args), LinkStdlib(false) {
+: Generic_ELF(D, Triple, Args) {
   GCCInstallation.init(Triple, Args);
 
   // Only add default libraries if the user hasn't explicitly opted out.
   if (!Args.hasArg(options::OPT_nostdlib) &&
-  !Args.hasArg(options::OPT_nodefaultlibs) &&
-  !Args.hasArg(options::OPT_c /* does not apply when not linking */)) {
-std::string CPU = getCPUName(D, Args, Triple);
-
-if (CPU.empty()) {
-  // We cannot link any standard libraries without an MCU specified.
-  D.Diag(diag::warn_drv_avr_mcu_not_specified);
+  !Args.hasArg(options::OPT_nodefaultlibs)) {
+if (GCCInstallation.isValid()) {
+  GCCInstallPath = GCCInstallation.getInstallPath();
+  std::string GCCParentPath(GCCInstallation.getParentLibPath());
+  getProgramPaths().push_back(GCCParentPath + "/../bin");
 } else {
-  Optional FamilyName = GetMCUFamilyName(CPU);
-  Optio

[PATCH] D122533: [AVR] Remove AVRRelaxMemOperations

2022-03-27 Thread Patryk Wychowaniec via Phabricator via cfe-commits
Patryk27 added a comment.

In D122533#3410428 , @benshi001 wrote:

> In D122533#3410259 , @Patryk27 
> wrote:
>
>> Ok, I have added the switch; I think a separate patch that adds that switch 
>> to all of the AVR tests could come handy - what do you think?
>
> No. `-verify-machineinstrs` might be default in the future, which is still 
> under discuss, since it costs longer time. Currently we just make highly 
> risky case with explicit `-verify-machineinstrs`, such as yours. ^_^

Okie, understood - thanks :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122533

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


[PATCH] D122542: [flang][driver] Make --version and -version consistent with clang

2022-03-27 Thread Pete Steinfeld via Phabricator via cfe-commits
PeteSteinfeld accepted this revision.
PeteSteinfeld added a comment.
This revision is now accepted and ready to land.

Looks good.

Thanks for doing this, Emil!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122542

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


[clang] ad57e10 - [RISCV][NFC] Moving RVV intrinsic type related util to llvm/Support

2022-03-27 Thread Kito Cheng via cfe-commits

Author: Kito Cheng
Date: 2022-03-28T14:35:28+08:00
New Revision: ad57e10dbca2fdeff1448afc0aa1cf23d6df8736

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

LOG: [RISCV][NFC] Moving RVV intrinsic type related util to llvm/Support

This patch is split from https://reviews.llvm.org/D111617, we need those
stuffs on clang, so must moving those stuff to llvm/Support.

Reviewed By: khchen

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

Added: 
llvm/include/llvm/Support/RISCVVIntrinsicUtils.h
llvm/lib/Support/RISCVVIntrinsicUtils.cpp

Modified: 
clang/utils/TableGen/RISCVVEmitter.cpp
llvm/lib/Support/CMakeLists.txt

Removed: 




diff  --git a/clang/utils/TableGen/RISCVVEmitter.cpp 
b/clang/utils/TableGen/RISCVVEmitter.cpp
index f26b1189c1e97..accced0292f0e 100644
--- a/clang/utils/TableGen/RISCVVEmitter.cpp
+++ b/clang/utils/TableGen/RISCVVEmitter.cpp
@@ -20,211 +20,15 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/ADT/Twine.h"
+#include "llvm/Support/RISCVVIntrinsicUtils.h"
 #include "llvm/TableGen/Error.h"
 #include "llvm/TableGen/Record.h"
 #include 
 
 using namespace llvm;
-using BasicType = char;
-using VScaleVal = Optional;
+using namespace llvm::RISCV;
 
 namespace {
-
-// Exponential LMUL
-struct LMULType {
-  int Log2LMUL;
-  LMULType(int Log2LMUL);
-  // Return the C/C++ string representation of LMUL
-  std::string str() const;
-  Optional getScale(unsigned ElementBitwidth) const;
-  void MulLog2LMUL(int Log2LMUL);
-  LMULType &operator*=(uint32_t RHS);
-};
-
-// This class is compact representation of a valid and invalid RVVType.
-class RVVType {
-  enum ScalarTypeKind : uint32_t {
-Void,
-Size_t,
-Ptr
diff _t,
-UnsignedLong,
-SignedLong,
-Boolean,
-SignedInteger,
-UnsignedInteger,
-Float,
-Invalid,
-  };
-  BasicType BT;
-  ScalarTypeKind ScalarType = Invalid;
-  LMULType LMUL;
-  bool IsPointer = false;
-  // IsConstant indices are "int", but have the constant expression.
-  bool IsImmediate = false;
-  // Const qualifier for pointer to const object or object of const type.
-  bool IsConstant = false;
-  unsigned ElementBitwidth = 0;
-  VScaleVal Scale = 0;
-  bool Valid;
-
-  std::string BuiltinStr;
-  std::string ClangBuiltinStr;
-  std::string Str;
-  std::string ShortStr;
-
-public:
-  RVVType() : RVVType(BasicType(), 0, StringRef()) {}
-  RVVType(BasicType BT, int Log2LMUL, StringRef prototype);
-
-  // Return the string representation of a type, which is an encoded string for
-  // passing to the BUILTIN() macro in Builtins.def.
-  const std::string &getBuiltinStr() const { return BuiltinStr; }
-
-  // Return the clang builtin type for RVV vector type which are used in the
-  // riscv_vector.h header file.
-  const std::string &getClangBuiltinStr() const { return ClangBuiltinStr; }
-
-  // Return the C/C++ string representation of a type for use in the
-  // riscv_vector.h header file.
-  const std::string &getTypeStr() const { return Str; }
-
-  // Return the short name of a type for C/C++ name suffix.
-  const std::string &getShortStr() {
-// Not all types are used in short name, so compute the short name by
-// demanded.
-if (ShortStr.empty())
-  initShortStr();
-return ShortStr;
-  }
-
-  bool isValid() const { return Valid; }
-  bool isScalar() const { return Scale.hasValue() && Scale.getValue() == 0; }
-  bool isVector() const { return Scale.hasValue() && Scale.getValue() != 0; }
-  bool isVector(unsigned Width) const {
-return isVector() && ElementBitwidth == Width;
-  }
-  bool isFloat() const { return ScalarType == ScalarTypeKind::Float; }
-  bool isSignedInteger() const {
-return ScalarType == ScalarTypeKind::SignedInteger;
-  }
-  bool isFloatVector(unsigned Width) const {
-return isVector() && isFloat() && ElementBitwidth == Width;
-  }
-  bool isFloat(unsigned Width) const {
-return isFloat() && ElementBitwidth == Width;
-  }
-
-private:
-  // Verify RVV vector type and set Valid.
-  bool verifyType() const;
-
-  // Creates a type based on basic types of TypeRange
-  void applyBasicType();
-
-  // Applies a prototype modifier to the current type. The result maybe an
-  // invalid type.
-  void applyModifier(StringRef prototype);
-
-  // Compute and record a string for legal type.
-  void initBuiltinStr();
-  // Compute and record a builtin RVV vector type string.
-  void initClangBuiltinStr();
-  // Compute and record a type string for used in the header.
-  void initTypeStr();
-  // Compute and record a short name of a type for C/C++ name suffix.
-  void initShortStr();
-};
-
-using RVVTypePtr = RVVType *;
-using RVVTypes = std::vector;
-using RISCVPredefinedMacroT = uint8_t;
-
-enum RISCVPredefinedMacro : RISCVPredefined

[PATCH] D121984: [RISCV][NFC] Moving RVV intrinsic type related util to llvm/Support

2022-03-27 Thread Kito Cheng 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 rGad57e10dbca2: [RISCV][NFC] Moving RVV intrinsic type related 
util to llvm/Support (authored by kito-cheng).

Changed prior to commit:
  https://reviews.llvm.org/D121984?vs=416414&id=418496#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121984

Files:
  clang/utils/TableGen/RISCVVEmitter.cpp
  llvm/include/llvm/Support/RISCVVIntrinsicUtils.h
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/RISCVVIntrinsicUtils.cpp

Index: llvm/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- /dev/null
+++ llvm/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -0,0 +1,668 @@
+//===- RISCVVIntrinsicUtils.cpp - RISC-V Vector Intrinsic Utils -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "llvm/Support/RISCVVIntrinsicUtils.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/SmallSet.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringSet.h"
+#include "llvm/ADT/Twine.h"
+#include "llvm/TableGen/Error.h"
+#include "llvm/TableGen/Record.h"
+#include 
+
+namespace llvm {
+namespace RISCV {
+
+//===--===//
+// Type implementation
+//===--===//
+
+LMULType::LMULType(int NewLog2LMUL) {
+  // Check Log2LMUL is -3, -2, -1, 0, 1, 2, 3
+  assert(NewLog2LMUL <= 3 && NewLog2LMUL >= -3 && "Bad LMUL number!");
+  Log2LMUL = NewLog2LMUL;
+}
+
+std::string LMULType::str() const {
+  if (Log2LMUL < 0)
+return "mf" + utostr(1ULL << (-Log2LMUL));
+  return "m" + utostr(1ULL << Log2LMUL);
+}
+
+VScaleVal LMULType::getScale(unsigned ElementBitwidth) const {
+  int Log2ScaleResult = 0;
+  switch (ElementBitwidth) {
+  default:
+break;
+  case 8:
+Log2ScaleResult = Log2LMUL + 3;
+break;
+  case 16:
+Log2ScaleResult = Log2LMUL + 2;
+break;
+  case 32:
+Log2ScaleResult = Log2LMUL + 1;
+break;
+  case 64:
+Log2ScaleResult = Log2LMUL;
+break;
+  }
+  // Illegal vscale result would be less than 1
+  if (Log2ScaleResult < 0)
+return llvm::None;
+  return 1 << Log2ScaleResult;
+}
+
+void LMULType::MulLog2LMUL(int log2LMUL) { Log2LMUL += log2LMUL; }
+
+LMULType &LMULType::operator*=(uint32_t RHS) {
+  assert(isPowerOf2_32(RHS));
+  this->Log2LMUL = this->Log2LMUL + Log2_32(RHS);
+  return *this;
+}
+
+RVVType::RVVType(BasicType BT, int Log2LMUL, StringRef prototype)
+: BT(BT), LMUL(LMULType(Log2LMUL)) {
+  applyBasicType();
+  applyModifier(prototype);
+  Valid = verifyType();
+  if (Valid) {
+initBuiltinStr();
+initTypeStr();
+if (isVector()) {
+  initClangBuiltinStr();
+}
+  }
+}
+
+// clang-format off
+// boolean type are encoded the ratio of n (SEW/LMUL)
+// SEW/LMUL | 1 | 2 | 4 | 8| 16| 32| 64
+// c type   | vbool64_t | vbool32_t | vbool16_t | vbool8_t | vbool4_t  | vbool2_t  | vbool1_t
+// IR type  | nxv1i1| nxv2i1| nxv4i1| nxv8i1   | nxv16i1   | nxv32i1   | nxv64i1
+
+// type\lmul | 1/8| 1/4  | 1/2 | 1   | 2| 4| 8
+//   |--  |  | --- | --- |  |  | 
+// i64   | N/A| N/A  | N/A | nxv1i64 | nxv2i64  | nxv4i64  | nxv8i64
+// i32   | N/A| N/A  | nxv1i32 | nxv2i32 | nxv4i32  | nxv8i32  | nxv16i32
+// i16   | N/A| nxv1i16  | nxv2i16 | nxv4i16 | nxv8i16  | nxv16i16 | nxv32i16
+// i8| nxv1i8 | nxv2i8   | nxv4i8  | nxv8i8  | nxv16i8  | nxv32i8  | nxv64i8
+// double| N/A| N/A  | N/A | nxv1f64 | nxv2f64  | nxv4f64  | nxv8f64
+// float | N/A| N/A  | nxv1f32 | nxv2f32 | nxv4f32  | nxv8f32  | nxv16f32
+// half  | N/A| nxv1f16  | nxv2f16 | nxv4f16 | nxv8f16  | nxv16f16 | nxv32f16
+// clang-format on
+
+bool RVVType::verifyType() const {
+  if (ScalarType == Invalid)
+return false;
+  if (isScalar())
+return true;
+  if (!Scale.hasValue())
+return false;
+  if (isFloat() && ElementBitwidth == 8)
+return false;
+  unsigned V = Scale.getValue();
+  switch (ElementBitwidth) {
+  case 1:
+  case 8:
+// Check Scale is 1,2,4,8,16,32,64
+return (V <= 64 && isPowerOf2_32(V));
+  case 16:
+// Check Scale is 1,2,4,8,16,32
+return (V <= 32 && isPowerOf2_32(V));
+  case 32:
+// Check Scale is 1,2,4,8,16
+return (V <= 16 && isPowerOf2_32(V));
+  case 64:
+// Check Scale is 1,2,4,8
+return (V <= 8 && isPowerOf

[PATCH] D122554: [clangd] Handle tabs in getIncrementalChangesAfterNewline()

2022-03-27 Thread Nathan Ridge via Phabricator via cfe-commits
nridge created this revision.
nridge added a reviewer: sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman.
Herald added a project: All.
nridge requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Tabs are not handled by columnWidthUTF8() (they are considered
non-printable) so require additional logic to handle.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122554

Files:
  clang-tools-extra/clangd/Format.cpp
  clang-tools-extra/clangd/unittests/FormatTests.cpp

Index: clang-tools-extra/clangd/unittests/FormatTests.cpp
===
--- clang-tools-extra/clangd/unittests/FormatTests.cpp
+++ clang-tools-extra/clangd/unittests/FormatTests.cpp
@@ -20,13 +20,11 @@
 namespace clangd {
 namespace {
 
-std::string afterTyped(llvm::StringRef CodeWithCursor,
-   llvm::StringRef Typed) {
+std::string afterTyped(llvm::StringRef CodeWithCursor, llvm::StringRef Typed,
+   clang::format::FormatStyle Style) {
   Annotations Code(CodeWithCursor);
   unsigned Cursor = llvm::cantFail(positionToOffset(Code.code(), Code.point()));
-  auto Changes =
-  formatIncremental(Code.code(), Cursor, Typed,
-format::getGoogleStyle(format::FormatStyle::LK_Cpp));
+  auto Changes = formatIncremental(Code.code(), Cursor, Typed, Style);
   tooling::Replacements Merged;
   for (const auto& R : Changes)
 if (llvm::Error E = Merged.add(R))
@@ -39,11 +37,15 @@
 }
 
 // We can't pass raw strings directly to EXPECT_EQ because of gcc bugs.
-void expectAfterNewline(const char *Before, const char *After) {
-  EXPECT_EQ(After, afterTyped(Before, "\n")) << Before;
+void expectAfterNewline(const char *Before, const char *After,
+format::FormatStyle Style = format::getGoogleStyle(
+format::FormatStyle::LK_Cpp)) {
+  EXPECT_EQ(After, afterTyped(Before, "\n", Style)) << Before;
 }
-void expectAfter(const char *Typed, const char *Before, const char *After) {
-  EXPECT_EQ(After, afterTyped(Before, Typed)) << Before;
+void expectAfter(const char *Typed, const char *Before, const char *After,
+ format::FormatStyle Style =
+ format::getGoogleStyle(format::FormatStyle::LK_Cpp)) {
+  EXPECT_EQ(After, afterTyped(Before, Typed, Style)) << Before;
 }
 
 TEST(FormatIncremental, SplitComment) {
@@ -132,7 +134,7 @@
 ^
 }
 )cpp",
-   R"cpp(
+ R"cpp(
 void foo() {
   if (x)
 return;  // All spelled tokens are accounted for.
@@ -140,6 +142,17 @@
   ^
 }
 )cpp");
+
+  // Handle tab character in leading indentation
+  format::FormatStyle TabStyle =
+  format::getGoogleStyle(format::FormatStyle::LK_Cpp);
+  TabStyle.UseTab = format::FormatStyle::UT_Always;
+  TabStyle.TabWidth = 4;
+  TabStyle.IndentWidth = 4;
+  // Do not use raw strings, otherwise '\t' will be interpreted literally.
+  expectAfterNewline("void foo() {\n\t// this comment was\n^split\n}\n",
+ "void foo() {\n\t// this comment was\n\t// ^split\n}\n",
+ TabStyle);
 }
 
 TEST(FormatIncremental, Indentation) {
Index: clang-tools-extra/clangd/Format.cpp
===
--- clang-tools-extra/clangd/Format.cpp
+++ clang-tools-extra/clangd/Format.cpp
@@ -117,12 +117,41 @@
   std::string CursorPlaceholder;
 };
 
+// The two functions below, columnWidth() and columnWidthWithTabs(), were
+// adapted from similar functions in clang/lib/Format/Encoding.h.
+// FIXME: Move those functions to clang/include/clang/Format.h and reuse them?
+
+// Helper function for columnWidthWithTabs().
+inline unsigned columnWidth(StringRef Text) {
+  int ContentWidth = llvm::sys::unicode::columnWidthUTF8(Text);
+  if (ContentWidth >= 0)
+return ContentWidth;
+  return Text.size();
+}
+
+// Returns the number of columns required to display the \p Text on a terminal
+// with the \p TabWidth.
+inline unsigned columnWidthWithTabs(StringRef Text, unsigned TabWidth) {
+  unsigned TotalWidth = 0;
+  StringRef Tail = Text;
+  for (;;) {
+StringRef::size_type TabPos = Tail.find('\t');
+if (TabPos == StringRef::npos)
+  return TotalWidth + columnWidth(Tail);
+TotalWidth += columnWidth(Tail.substr(0, TabPos));
+if (TabWidth)
+  TotalWidth += TabWidth - TotalWidth % TabWidth;
+Tail = Tail.substr(TabPos + 1);
+  }
+}
+
 // After a newline:
 //  - we continue any line-comment that was split
 //  - we format the old line in addition to the cursor
 //  - we represent the cursor with a line comment to preserve the newline
 IncrementalChanges getIncrementalChangesAfterNewline(llvm::StringRef Code,
- unsigned Cursor) {
+ unsigned Cursor,
+  

[clang] 85b1354 - [C++20][Modules][HU 5/5] Add fdirectives-only mode for preprocessing output.

2022-03-27 Thread Iain Sandoe via cfe-commits

Author: Iain Sandoe
Date: 2022-03-28T07:38:22+01:00
New Revision: 85b1354098ba0a665fdd47204d0e53e63d09d9ab

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

LOG: [C++20][Modules][HU 5/5] Add fdirectives-only mode for preprocessing 
output.

When the -fdirectives-only option is used together with -E, the preprocessor
output reflects evaluation of if/then/else directives.

As such, it preserves defines and undefs of macros that are still live after
such processing.  The intent is that this output could be consumed as input
to generate considered a C++20 header unit.

We strip out any (unused) defines that come from built-in, built-in-file or
command line; these are re-added when the preprocessed source is consumed.

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

Added: 
clang/test/Modules/cxx20-hu-06.cpp

Modified: 
clang/include/clang/Driver/Options.td
clang/include/clang/Frontend/PreprocessorOutputOptions.h
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Frontend/PrintPreprocessedOutput.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 488692e16145f..ac2f479f159eb 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1873,6 +1873,8 @@ defm rewrite_includes : BoolFOption<"rewrite-includes",
   PreprocessorOutputOpts<"RewriteIncludes">, DefaultFalse,
   PosFlag, NegFlag>;
 
+defm directives_only : OptInCC1FFlag<"directives-only", "">;
+
 defm delete_null_pointer_checks : BoolFOption<"delete-null-pointer-checks",
   CodeGenOpts<"NullPointerIsValid">, DefaultFalse,
   NegFlag,

diff  --git a/clang/include/clang/Frontend/PreprocessorOutputOptions.h 
b/clang/include/clang/Frontend/PreprocessorOutputOptions.h
index 257538ee06065..d542032431b14 100644
--- a/clang/include/clang/Frontend/PreprocessorOutputOptions.h
+++ b/clang/include/clang/Frontend/PreprocessorOutputOptions.h
@@ -25,6 +25,7 @@ class PreprocessorOutputOptions {
   unsigned RewriteIncludes : 1;///< Preprocess include directives only.
   unsigned RewriteImports  : 1;///< Include contents of 
transitively-imported modules.
   unsigned MinimizeWhitespace : 1; ///< Ignore whitespace from input.
+  unsigned DirectivesOnly : 1; ///< Process directives but do not expand 
macros.
 
 public:
   PreprocessorOutputOptions() {
@@ -38,6 +39,7 @@ class PreprocessorOutputOptions {
 RewriteIncludes = 0;
 RewriteImports = 0;
 MinimizeWhitespace = 0;
+DirectivesOnly = 0;
   }
 };
 

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 5bb480a599713..b222119889522 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -4413,6 +4413,8 @@ static void GeneratePreprocessorOutputArgs(
 GenerateArg(Args, OPT_dM, SA);
   if (!Generate_dM && Opts.ShowMacros)
 GenerateArg(Args, OPT_dD, SA);
+  if (Opts.DirectivesOnly)
+GenerateArg(Args, OPT_fdirectives_only, SA);
 }
 
 static bool ParsePreprocessorOutputArgs(PreprocessorOutputOptions &Opts,
@@ -4435,6 +4437,7 @@ static bool 
ParsePreprocessorOutputArgs(PreprocessorOutputOptions &Opts,
 
   Opts.ShowCPP = isStrictlyPreprocessorAction(Action) && !Args.hasArg(OPT_dM);
   Opts.ShowMacros = Args.hasArg(OPT_dM) || Args.hasArg(OPT_dD);
+  Opts.DirectivesOnly = Args.hasArg(OPT_fdirectives_only);
 
   return Diags.getNumErrors() == NumErrorsBefore;
 }

diff  --git a/clang/lib/Frontend/PrintPreprocessedOutput.cpp 
b/clang/lib/Frontend/PrintPreprocessedOutput.cpp
index e2fc862849ad1..7737d043043d5 100644
--- a/clang/lib/Frontend/PrintPreprocessedOutput.cpp
+++ b/clang/lib/Frontend/PrintPreprocessedOutput.cpp
@@ -96,6 +96,7 @@ class PrintPPOutputPPCallbacks : public PPCallbacks {
   bool UseLineDirectives;
   bool IsFirstFileEntered;
   bool MinimizeWhitespace;
+  bool DirectivesOnly;
 
   Token PrevTok;
   Token PrevPrevTok;
@@ -103,12 +104,13 @@ class PrintPPOutputPPCallbacks : public PPCallbacks {
 public:
   PrintPPOutputPPCallbacks(Preprocessor &pp, raw_ostream &os, bool lineMarkers,
bool defines, bool DumpIncludeDirectives,
-   bool UseLineDirectives, bool MinimizeWhitespace)
+   bool UseLineDirectives, bool MinimizeWhitespace,
+   bool DirectivesOnly)
   : PP(pp), SM(PP.getSourceManager()), ConcatInfo(PP), OS(os),
 DisableLineMarkers(lineMarkers), DumpDefines(defines),
 DumpIncludeDirectives(DumpIncludeDirectives),
 UseLineDirectives(UseLineDirectives),
-MinimizeWhitespace(MinimizeWhitespace) {
+MinimizeWhitespace(MinimizeWhitespace), DirectivesOnly(DirectivesOnly) 
{
 CurLine = 0;
  

[PATCH] D121099: [C++20][Modules][HU 5/5] Add fdirectives-only mode for preprocessing output.

2022-03-27 Thread Iain Sandoe via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG85b1354098ba: [C++20][Modules][HU 5/5] Add fdirectives-only 
mode for preprocessing output. (authored by iains).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121099

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/PreprocessorOutputOptions.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/PrintPreprocessedOutput.cpp
  clang/test/Modules/cxx20-hu-06.cpp

Index: clang/test/Modules/cxx20-hu-06.cpp
===
--- /dev/null
+++ clang/test/Modules/cxx20-hu-06.cpp
@@ -0,0 +1,68 @@
+// Test check that consuming -E -fdirectives-only output produces the expected
+// header unit.
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+// RUN: cd %t
+
+// RUN: %clang_cc1 -std=c++20 -E -fdirectives-only -xc++-user-header hu-01.h \
+// RUN: -o hu-01.iih
+
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit \
+// RUN: -xc++-user-header-cpp-output hu-01.iih -o hu-01.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header hu-02.h \
+// RUN: -DFOO -fmodule-file=hu-01.pcm -o hu-02.pcm -Rmodule-import 2>&1 | \
+// RUN: FileCheck --check-prefix=CHECK-IMP %s -DTDIR=%t
+
+//--- hu-01.h
+#ifndef __GUARD
+#define __GUARD
+
+int baz(int);
+#define FORTYTWO 42
+
+#define SHOULD_NOT_BE_DEFINED -1
+#undef SHOULD_NOT_BE_DEFINED
+
+#endif // __GUARD
+// expected-no-diagnostics
+
+//--- hu-02.h
+export import "hu-01.h";
+#if !defined(FORTYTWO) || FORTYTWO != 42
+#error FORTYTWO missing in hu-02
+#endif
+
+#ifndef __GUARD
+#error __GUARD missing in hu-02
+#endif
+
+#ifdef SHOULD_NOT_BE_DEFINED
+#error SHOULD_NOT_BE_DEFINED is visible
+#endif
+
+// Make sure that we have not discarded macros from the builtin file.
+#ifndef __cplusplus
+#error we dropped a defined macro
+#endif
+
+#define KAP 6174
+
+#ifdef FOO
+#define FOO_BRANCH(X) (X) + 1
+inline int foo(int x) {
+  if (x == FORTYTWO)
+return FOO_BRANCH(x);
+  return FORTYTWO;
+}
+#else
+#define BAR_BRANCH(X) (X) + 2
+inline int bar(int x) {
+  if (x == FORTYTWO)
+return BAR_BRANCH(x);
+  return FORTYTWO;
+}
+#endif
+// CHECK-IMP: remark: importing module './hu-01.h' from 'hu-01.pcm'
Index: clang/lib/Frontend/PrintPreprocessedOutput.cpp
===
--- clang/lib/Frontend/PrintPreprocessedOutput.cpp
+++ clang/lib/Frontend/PrintPreprocessedOutput.cpp
@@ -96,6 +96,7 @@
   bool UseLineDirectives;
   bool IsFirstFileEntered;
   bool MinimizeWhitespace;
+  bool DirectivesOnly;
 
   Token PrevTok;
   Token PrevPrevTok;
@@ -103,12 +104,13 @@
 public:
   PrintPPOutputPPCallbacks(Preprocessor &pp, raw_ostream &os, bool lineMarkers,
bool defines, bool DumpIncludeDirectives,
-   bool UseLineDirectives, bool MinimizeWhitespace)
+   bool UseLineDirectives, bool MinimizeWhitespace,
+   bool DirectivesOnly)
   : PP(pp), SM(PP.getSourceManager()), ConcatInfo(PP), OS(os),
 DisableLineMarkers(lineMarkers), DumpDefines(defines),
 DumpIncludeDirectives(DumpIncludeDirectives),
 UseLineDirectives(UseLineDirectives),
-MinimizeWhitespace(MinimizeWhitespace) {
+MinimizeWhitespace(MinimizeWhitespace), DirectivesOnly(DirectivesOnly) {
 CurLine = 0;
 CurFilename += "";
 EmittedTokensOnThisLine = false;
@@ -467,12 +469,21 @@
 void PrintPPOutputPPCallbacks::MacroDefined(const Token &MacroNameTok,
 const MacroDirective *MD) {
   const MacroInfo *MI = MD->getMacroInfo();
-  // Only print out macro definitions in -dD mode.
-  if (!DumpDefines ||
+  // Print out macro definitions in -dD mode and when we have -fdirectives-only
+  // for C++20 header units.
+  if ((!DumpDefines && !DirectivesOnly) ||
   // Ignore __FILE__ etc.
-  MI->isBuiltinMacro()) return;
+  MI->isBuiltinMacro())
+return;
 
-  MoveToLine(MI->getDefinitionLoc(), /*RequireStartOfLine=*/true);
+  SourceLocation DefLoc = MI->getDefinitionLoc();
+  if (DirectivesOnly && !MI->isUsed()) {
+SourceManager &SM = PP.getSourceManager();
+if (SM.isWrittenInBuiltinFile(DefLoc) ||
+SM.isWrittenInCommandLineFile(DefLoc))
+  return;
+  }
+  MoveToLine(DefLoc, /*RequireStartOfLine=*/true);
   PrintMacroDefinition(*MacroNameTok.getIdentifierInfo(), *MI, PP, OS);
   setEmittedDirectiveOnThisLine();
 }
@@ -480,8 +491,10 @@
 void PrintPPOutputPPCallbacks::MacroUndefined(const Token &MacroNameTok,
   const MacroDefinition &MD,
   const MacroDirective *Undef) {
-  // Only print out macro definitions in -dD mode.
-  if (!DumpDefines) return;
+  // Print out macro definitions in -dD mode and 

[PATCH] D122556: [RISCV] Add definitions for Xiangshan processors.

2022-03-27 Thread Zircon Liu via Phabricator via cfe-commits
SForeKeeper created this revision.
Herald added subscribers: s, VincentWu, luke957, vkmr, frasercrmck, evandro, 
luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, 
PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, 
kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya, 
arichardson.
Herald added a project: All.
SForeKeeper requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, pcwang-thead, eopXD, 
MaskRay.
Herald added projects: clang, LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122556

Files:
  clang/test/CodeGen/RISCV/riscv-metadata.c
  clang/test/Driver/riscv-cpus.c
  clang/test/Misc/target-invalid-cpu-note.c
  llvm/include/llvm/Support/RISCVTargetParser.def
  llvm/lib/Target/RISCV/RISCV.td

Index: llvm/lib/Target/RISCV/RISCV.td
===
--- llvm/lib/Target/RISCV/RISCV.td
+++ llvm/lib/Target/RISCV/RISCV.td
@@ -536,6 +536,27 @@
   FeatureStdExtC],
  [TuneSiFive7]>;
 
+def : ProcessorModel<"xiangshan-yanqihu", NoSchedModel, [Feature64Bit,
+ FeatureStdExtM,
+ FeatureStdExtA,
+ FeatureStdExtF,
+ FeatureStdExtD,
+ FeatureStdExtC]>;
+
+def : ProcessorModel<"xiangshan-nanhu", NoSchedModel, [Feature64Bit,
+   FeatureStdExtM,
+   FeatureStdExtA,
+   FeatureStdExtF,
+   FeatureStdExtD,
+   FeatureStdExtC,
+   FeatureStdExtZba,
+   FeatureStdExtZbb,
+   FeatureStdExtZbc,
+   FeatureStdExtZbs,
+   FeatureStdExtZkn,
+   FeatureStdExtZksed,
+   FeatureStdExtZksh]>;
+
 //===--===//
 // Define the RISC-V target.
 //===--===//
Index: llvm/include/llvm/Support/RISCVTargetParser.def
===
--- llvm/include/llvm/Support/RISCVTargetParser.def
+++ llvm/include/llvm/Support/RISCVTargetParser.def
@@ -31,5 +31,7 @@
 PROC(SIFIVE_S76, {"sifive-s76"}, FK_64BIT, {"rv64gc"})
 PROC(SIFIVE_U54, {"sifive-u54"}, FK_64BIT, {"rv64gc"})
 PROC(SIFIVE_U74, {"sifive-u74"}, FK_64BIT, {"rv64gc"})
+PROC(XIANGSHAN_YANQIHU,{"xiangshan-yanqihu"},FK_64BIT,{"rv64gc"})
+PROC(XIANGSHAN_NANHU,{"xiangshan-nanhu"},FK_64BIT,{"rv64imafdc_zba_zbb_zbc_zbs_zbkb_zbkc_zbkx_zknd_zkne_zknh_zksed_zksh"})
 
 #undef PROC
Index: clang/test/Misc/target-invalid-cpu-note.c
===
--- clang/test/Misc/target-invalid-cpu-note.c
+++ clang/test/Misc/target-invalid-cpu-note.c
@@ -85,7 +85,7 @@
 
 // RUN: not %clang_cc1 -triple riscv64 -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix RISCV64
 // RISCV64: error: unknown target CPU 'not-a-cpu'
-// RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, sifive-7-rv64, sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, sifive-u74{{$}}
+// RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, sifive-7-rv64, sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, sifive-u74, xiangshan-yanqihu, xiangshan-nanhu{{$}}
 
 // RUN: not %clang_cc1 -triple riscv32 -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE-RISCV32
 // TUNE-RISCV32: error: unknown target CPU 'not-a-cpu'
@@ -93,4 +93,4 @@
 
 // RUN: not %clang_cc1 -triple riscv64 -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE-RISCV64
 // TUNE-RISCV64: error: unknown target CPU 'not-a-cpu'
-// TUNE-RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, sifive-7-rv64, sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, sifive-u74, generic, rocket, sifive-7-series{{$}}
+// TUNE-RISCV64-NEXT: note: valid target CPU values are: generic-rv64, rocket-rv64, sifive-7-rv64, sifive-s21, sifive-s51, sifive-s54, sifive-s76, sifive-u54, sifive-u74, generic, rocket, sifive-7-series, xiangshan-yanqihu, xiangshan-nanhu{{$}}
Index: clang/test/