[PATCH] D150843: [clang][Diagnostics] Refactor printableTextForNextCharacter

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



Comment at: clang/lib/Frontend/TextDiagnostic.cpp:120
-  begin = reinterpret_cast(&*(SourceLine.begin() + *i));
-  end = begin + (SourceLine.size() - *i);
-

I don't know what this computation of `end` means, but from the debug output I 
added, it meant that a call to this function always converted the entire line. 
I think.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150843

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


[PATCH] D150843: [clang][Diagnostics] Refactor printableTextForNextCharacter

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

Rename parameters and local variables to start with an uppercase characters.

This is not 100% NFC, since it adds an easy/fast path for 1 byte printable 
characters and changes how much text is converted to UTF32.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150843

Files:
  clang/lib/Frontend/TextDiagnostic.cpp

Index: clang/lib/Frontend/TextDiagnostic.cpp
===
--- clang/lib/Frontend/TextDiagnostic.cpp
+++ clang/lib/Frontend/TextDiagnostic.cpp
@@ -96,68 +96,76 @@
 /// \return pair(printable text, 'true' iff original text was printable)
 ///
 static std::pair, bool>
-printableTextForNextCharacter(StringRef SourceLine, size_t *i,
+printableTextForNextCharacter(StringRef SourceLine, size_t *I,
   unsigned TabStop) {
-  assert(i && "i must not be null");
-  assert(*i expandedTab;
-expandedTab.assign(NumSpaces, ' ');
-return std::make_pair(expandedTab, true);
+SmallString<16> ExpandedTab;
+ExpandedTab.assign(NumSpaces, ' ');
+return std::make_pair(ExpandedTab, true);
   }
 
-  unsigned char const *begin, *end;
-  begin = reinterpret_cast(&*(SourceLine.begin() + *i));
-  end = begin + (SourceLine.size() - *i);
-
-  if (llvm::isLegalUTF8Sequence(begin, end)) {
-llvm::UTF32 c;
-llvm::UTF32 *cptr = 
-unsigned char const *original_begin = begin;
-unsigned char const *cp_end =
-begin + llvm::getNumBytesForUTF8(SourceLine[*i]);
-
-llvm::ConversionResult res = llvm::ConvertUTF8toUTF32(
-, cp_end, , cptr + 1, llvm::strictConversion);
-(void)res;
-assert(llvm::conversionOK == res);
-assert(0 < begin-original_begin
-   && "we must be further along in the string now");
-*i += begin-original_begin;
-
-if (!llvm::sys::locale::isPrint(c)) {
-  // If next character is valid UTF-8, but not printable
-  SmallString<16> expandedCP("");
-  while (c) {
-expandedCP.insert(expandedCP.begin()+3, llvm::hexdigit(c%16));
-c/=16;
-  }
-  while (expandedCP.size() < 8)
-expandedCP.insert(expandedCP.begin()+3, llvm::hexdigit(0));
-  return std::make_pair(expandedCP, false);
-}
+  const unsigned char *Begin =
+  reinterpret_cast(&*(SourceLine.begin())) + (*I);
+  unsigned CharSize = llvm::getNumBytesForUTF8(*Begin);
+  const unsigned char *End = Begin + CharSize;
 
-// If next character is valid UTF-8, and printable
-return std::make_pair(SmallString<16>(original_begin, cp_end), true);
+  // Fast path for the common ASCII case.
+  if (CharSize == 1 && llvm::isLegalUTF8Sequence(Begin, End) &&
+  llvm::sys::locale::isPrint(*Begin)) {
+++(*I);
+return std::make_pair(SmallString<16>(Begin, End), true);
+  }
 
+  // We now know that the next character is a multi-byte character.
+  // Convert it to UTF32 and check if it's printable.
+  if (llvm::isLegalUTF8Sequence(Begin, End)) {
+llvm::UTF32 C;
+llvm::UTF32 *CPtr = 
+
+// Begin and end before conversion.
+unsigned char const *OriginalBegin = Begin;
+llvm::ConversionResult Res = llvm::ConvertUTF8toUTF32(
+, End, , CPtr + 1, llvm::strictConversion);
+(void)Res;
+assert(Res == llvm::conversionOK);
+assert(OriginalBegin < Begin);
+assert((Begin - OriginalBegin) == CharSize);
+
+(*I) += (Begin - OriginalBegin);
+
+// Valid, multi-byte, printable UTF8 character.
+if (llvm::sys::locale::isPrint(C))
+  return std::make_pair(SmallString<16>(OriginalBegin, End), true);
+
+// Valid but not printable.
+SmallString<16> Str("");
+while (C) {
+  Str.insert(Str.begin() + 3, llvm::hexdigit(C % 16));
+  C /= 16;
+}
+while (Str.size() < 8)
+  Str.insert(Str.begin() + 3, llvm::hexdigit(0));
+return std::make_pair(Str, false);
   }
 
-  // If next byte is not valid UTF-8 (and therefore not printable)
-  SmallString<16> expandedByte("");
-  unsigned char byte = SourceLine[*i];
-  expandedByte[1] = llvm::hexdigit(byte / 16);
-  expandedByte[2] = llvm::hexdigit(byte % 16);
-  ++(*i);
-  return std::make_pair(expandedByte, false);
+  // Otherwise, not printable since it's not valid UTF8.
+  SmallString<16> ExpandedByte("");
+  unsigned char Byte = SourceLine[*I];
+  ExpandedByte[1] = llvm::hexdigit(Byte / 16);
+  ExpandedByte[2] = llvm::hexdigit(Byte % 16);
+  ++(*I);
+  return std::make_pair(ExpandedByte, false);
 }
 
 static void expandTabs(std::string , unsigned TabStop) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150841: [IR] Make stack protector symbol dso_local according to -f[no-]direct-access-external-data

2023-05-17 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: ardb, nickdesaulniers, pengfei, xiangzhangllvm.
Herald added subscribers: bd1976llvm, hiraditya, krytarowski, arichardson, 
nemanjai, emaste.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

There are two motivations.

`-fno-pic -fstack-protector -mstack-protector-guard=global` created
`__stack_chk_guard` is referenced directly on all ELF OSes except FreeBSD.
This patch allows referencing the symbol indirectly with
-fno-direct-access-external-data.

Some Linux kernel folks want
`-fno-pic -fstack-protector -mstack-protector-guard-reg=gs 
-mstack-protector-guard-symbol=__stack_chk_guard`
created `__stack_chk_guard` to be referenced directly, avoiding
R_X86_64_REX_GOTPCRELX (even if the relocation may be optimized out by the 
linker).
https://github.com/llvm/llvm-project/issues/60116
Why they need this isn't so clear to me.

---

Add module flag "direct-access-external-data" and set the dso_local property of
the stack protector symbol. The module flag can benefit other LLVMCodeGen
synthesized symbols that are not represented in LLVM IR.

Nowadays, with `-fno-pic` being uncommon, ideally we should set
"direct-access-external-data" when it is true. However, doing so would require
~90 clang/test tests to be updated, which are too much.

As a compromise, we set "direct-access-external-data" only when it's different
from the implied default value.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150841

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/dso-local-executable.c
  llvm/include/llvm/IR/Module.h
  llvm/lib/CodeGen/TargetLoweringBase.cpp
  llvm/lib/IR/Module.cpp
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/test/CodeGen/AArch64/arm64_32.ll
  llvm/test/CodeGen/AArch64/stack-guard-sve.ll
  llvm/test/CodeGen/AArch64/stack-guard-vaarg.ll
  llvm/test/CodeGen/AArch64/stack_guard_remat.ll
  llvm/test/CodeGen/ARM/expand-pseudos.ll
  llvm/test/CodeGen/ARM/stack-guard-rwpi.ll
  llvm/test/CodeGen/ARM/stack_guard_remat.ll
  llvm/test/CodeGen/Inputs/stack-guard-reassign.ll
  llvm/test/CodeGen/PowerPC/stack-guard-oob.ll
  llvm/test/CodeGen/Thumb/stack_guard_remat.ll
  llvm/test/CodeGen/Thumb2/stack_guard_remat.ll
  llvm/test/CodeGen/X86/2009-04-14-IllegalRegs.ll
  llvm/test/CodeGen/X86/2010-09-17-SideEffectsInChain.ll
  llvm/test/CodeGen/X86/stack-protector-3.ll

Index: llvm/test/CodeGen/X86/stack-protector-3.ll
===
--- llvm/test/CodeGen/X86/stack-protector-3.ll
+++ llvm/test/CodeGen/X86/stack-protector-3.ll
@@ -7,7 +7,8 @@
 ; RUN: cat %t/main.ll %t/f.ll > %t/f2.ll
 ; RUN: cat %t/main.ll %t/g.ll > %t/g2.ll
 ; RUN: cat %t/main.ll %t/h.ll > %t/h2.ll
-; RUN: cat %t/existedGV.ll %t/main.ll %t/h.ll > %t/i2.ll
+; RUN: cat %t/existedGV.ll %t/main.ll %t/h.ll > %t/h3.ll
+; RUN: cat %t/main.ll %t/i.ll > %t/i2.ll
 ; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/a2.ll | FileCheck --check-prefix=CHECK-TLS-FS-40 %s
 ; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/b2.ll | FileCheck --check-prefix=CHECK-TLS-FS-40 %s
 ; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/c2.ll | FileCheck --check-prefix=CHECK-GLOBAL %s
@@ -16,7 +17,8 @@
 ; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/f2.ll | FileCheck --check-prefix=CHECK-OFFSET %s
 ; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/g2.ll | FileCheck --check-prefix=CHECK-NEGATIVE-OFFSET %s
 ; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/h2.ll | FileCheck --check-prefix=CHECK-SYM %s
-; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/i2.ll | FileCheck --check-prefix=CHECK-SYMGV %s
+; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/h3.ll | FileCheck --check-prefix=CHECK-SYMGV %s
+; RUN: llc -mtriple=x86_64-pc-linux-gnu -o - < %t/i2.ll | FileCheck --check-prefix=CHECK-SYM2 %s
 
 ; CHECK-TLS-FS-40:   movq%fs:40, %rax
 ; CHECK-TLS-FS-40:   movq%fs:40, %rax
@@ -77,6 +79,15 @@
 ; CHECK-SYMGV-NEXT:  .cfi_def_cfa_offset 32
 ; CHECK-SYMGV-NEXT:  callq   __stack_chk_fail
 
+; CHECK-SYM2: movq%fs:__woof(%rip), %rax
+; CHECK-SYM2-NEXT:movq%rax, 16(%rsp)
+; CHECK-SYM2: movq%fs:__woof(%rip), %rax
+; CHECK-SYM2-NEXT:cmpq16(%rsp), %rax
+; CHECK-SYM2-NEXT:jne .LBB0_2
+; CHECK-SYM2: .LBB0_2:
+; CHECK-SYM2-NEXT:.cfi_def_cfa_offset 32
+; CHECK-SYM2-NEXT:callq   __stack_chk_fai
+
 ; ModuleID = 't.c'
 ;--- existedGV.ll
 
@@ -116,7 +127,8 @@
 !llvm.module.flags = !{!1}
 !1 = !{i32 2, !"stack-protector-guard", !"tls"}
 ;--- c.ll
-!llvm.module.flags = !{!1}
+!llvm.module.flags = !{!0,!1}
+!0 = !{i32 7, !"direct-access-external-data", i32 1}
 !1 = !{i32 2, !"stack-protector-guard", !"global"}
 ;--- d.ll
 !llvm.module.flags = !{!1}
@@ -131,5 +143,10 @@
 !llvm.module.flags = !{!1}
 !1 = !{i32 2, !"stack-protector-guard-offset", i32 -20}
 ;--- h.ll

[clang] 7bbe512 - [RISCV] Remove unneedded comment. NFC

2023-05-17 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2023-05-17T22:49:28-07:00
New Revision: 7bbe512362edd1dbd3947ff71212f3ae815a0836

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

LOG: [RISCV] Remove unneedded comment. NFC

This was copied from SVE, but is currently not applicable to RISC-V.

Added: 


Modified: 
clang/lib/AST/ASTContext.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 3d44f1c33cc80..d5611f8f953f6 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -9594,8 +9594,6 @@ bool ASTContext::areCompatibleRVVTypes(QualType FirstType,
   auto IsValidCast = [this](QualType FirstType, QualType SecondType) {
 if (const auto *BT = FirstType->getAs()) {
   if (const auto *VT = SecondType->getAs()) {
-// Predicates have the same representation as uint8 so we also have to
-// check the kind to make these types incompatible.
 if (VT->getVectorKind() == VectorType::RVVFixedLengthDataVector)
   return FirstType->isRVVVLSBuiltinType() &&
  VT->getElementType().getCanonicalType() ==



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


[clang] 4acee5b - Revert "[clang][X86] Add __cpuidex function to cpuid.h"

2023-05-17 Thread Aiden Grossman via cfe-commits

Author: Aiden Grossman
Date: 2023-05-18T05:37:48Z
New Revision: 4acee5b5cfa462af66225acda7d3d9efe1036aa9

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

LOG: Revert "[clang][X86] Add __cpuidex function to cpuid.h"

This reverts commit 286cefcf35d0f55c57184c4219b95e82c96f1420.

Patch caused build failures for downstream projects on Windows due to
the fact that __cpuidex was added as a built in on Windows in D121653.
Reverting for now so that others aren't blocked and I can figure out a
proper solution.

Added: 


Modified: 
clang/lib/Headers/cpuid.h
clang/test/Headers/cpuid.c

Removed: 




diff  --git a/clang/lib/Headers/cpuid.h b/clang/lib/Headers/cpuid.h
index 22260c48c0c42..1ad6853a97c9d 100644
--- a/clang/lib/Headers/cpuid.h
+++ b/clang/lib/Headers/cpuid.h
@@ -328,10 +328,4 @@ static __inline int __get_cpuid_count (unsigned int __leaf,
 return 1;
 }
 
-static __inline void __cpuidex (int __cpu_info[4], int __leaf, int __subleaf)
-{
-  __cpuid_count(__leaf, __subleaf, __cpu_info[0], __cpu_info[1], __cpu_info[2],
-__cpu_info[3]);
-}
-
 #endif /* __CPUID_H */

diff  --git a/clang/test/Headers/cpuid.c b/clang/test/Headers/cpuid.c
index 6ed12eca7a61d..7e485495c1066 100644
--- a/clang/test/Headers/cpuid.c
+++ b/clang/test/Headers/cpuid.c
@@ -6,19 +6,14 @@
 
 // CHECK-64: {{.*}} call { i32, i32, i32, i32 } asm "  xchgq  %rbx,${1:q}\0A 
cpuid\0A xchgq %rbx,${1:q}", 
"={ax},=r,={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}})
 // CHECK-64: {{.*}} call { i32, i32, i32, i32 } asm "  xchgq  %rbx,${1:q}\0A  
cpuid\0A  xchgq  %rbx,${1:q}", 
"={ax},=r,={cx},={dx},0,2,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}}, i32 
%{{[a-z0-9]+}})
-// CHECK-64: {{.*}} call { i32, i32, i32, i32 } asm "  xchgq  %rbx,${1:q}\0A  
cpuid\0A  xchgq  %rbx,${1:q}", 
"={ax},=r,={cx},={dx},0,2,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}}, i32 
%{{[a-z0-9]+}})
 
 // CHECK-32: {{.*}} call { i32, i32, i32, i32 } asm "cpuid", 
"={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}})
 // CHECK-32: {{.*}} call { i32, i32, i32, i32 } asm "cpuid", 
"={ax},={bx},={cx},={dx},0,2,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}}, 
i32 %{{[a-z0-9]+}})
-// CHECK-32: {{.*}} call { i32, i32, i32, i32 } asm "cpuid", 
"={ax},={bx},={cx},={dx},0,2,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}}, 
i32 %{{[a-z0-9]+}})
 
 unsigned eax0, ebx0, ecx0, edx0;
 unsigned eax1, ebx1, ecx1, edx1;
 
-int cpuid_info[4];
-
 void test_cpuid(unsigned level, unsigned count) {
   __cpuid(level, eax1, ebx1, ecx1, edx1);
   __cpuid_count(level, count, eax0, ebx0, ecx0, edx0);
-  __cpuidex(cpuid_info, level, count);
 }



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


[PATCH] D150840: [clang][NFC] Refactor emitSnippet()

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

Rename parameters and local variables and reorder things a bit to be closer to 
their first point of use.
This doesn't change anything else.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150840

Files:
  clang/lib/Frontend/TextDiagnostic.cpp


Index: clang/lib/Frontend/TextDiagnostic.cpp
===
--- clang/lib/Frontend/TextDiagnostic.cpp
+++ clang/lib/Frontend/TextDiagnostic.cpp
@@ -1298,16 +1298,12 @@
   emitParseableFixits(Hints, SM);
 }
 
-void TextDiagnostic::emitSnippet(StringRef line, unsigned 
MaxLineNoDisplayWidth,
+void TextDiagnostic::emitSnippet(StringRef SourceLine,
+ unsigned MaxLineNoDisplayWidth,
  unsigned LineNo) {
-  if (line.empty())
+  if (SourceLine.empty())
 return;
 
-  size_t i = 0;
-
-  std::string to_print;
-  bool print_reversed = false;
-
   // Emit line number.
   if (MaxLineNoDisplayWidth > 0) {
 unsigned LineNoDisplayWidth = getNumDisplayWidth(LineNo);
@@ -1318,28 +1314,30 @@
 OS << " | ";
   }
 
-  while (i,bool> res
-= printableTextForNextCharacter(line, , DiagOpts->TabStop);
-bool was_printable = res.second;
+  bool PrintReversed = false;
+  std::string ToPrint;
+  size_t I = 0;
+  while (I < SourceLine.size()) {
+auto [Str, WasPrintable] =
+printableTextForNextCharacter(SourceLine, , DiagOpts->TabStop);
 
-if (DiagOpts->ShowColors && was_printable == print_reversed) {
-  if (print_reversed)
+if (DiagOpts->ShowColors && WasPrintable == PrintReversed) {
+  if (PrintReversed)
 OS.reverseColor();
-  OS << to_print;
-  to_print.clear();
+  OS << ToPrint;
+  ToPrint.clear();
   if (DiagOpts->ShowColors)
 OS.resetColor();
 }
 
-print_reversed = !was_printable;
-to_print += res.first.str();
+PrintReversed = !WasPrintable;
+ToPrint += Str;
   }
 
-  if (print_reversed && DiagOpts->ShowColors)
+  if (PrintReversed && DiagOpts->ShowColors)
 OS.reverseColor();
-  OS << to_print;
-  if (print_reversed && DiagOpts->ShowColors)
+  OS << ToPrint;
+  if (PrintReversed && DiagOpts->ShowColors)
 OS.resetColor();
 
   OS << '\n';


Index: clang/lib/Frontend/TextDiagnostic.cpp
===
--- clang/lib/Frontend/TextDiagnostic.cpp
+++ clang/lib/Frontend/TextDiagnostic.cpp
@@ -1298,16 +1298,12 @@
   emitParseableFixits(Hints, SM);
 }
 
-void TextDiagnostic::emitSnippet(StringRef line, unsigned MaxLineNoDisplayWidth,
+void TextDiagnostic::emitSnippet(StringRef SourceLine,
+ unsigned MaxLineNoDisplayWidth,
  unsigned LineNo) {
-  if (line.empty())
+  if (SourceLine.empty())
 return;
 
-  size_t i = 0;
-
-  std::string to_print;
-  bool print_reversed = false;
-
   // Emit line number.
   if (MaxLineNoDisplayWidth > 0) {
 unsigned LineNoDisplayWidth = getNumDisplayWidth(LineNo);
@@ -1318,28 +1314,30 @@
 OS << " | ";
   }
 
-  while (i,bool> res
-= printableTextForNextCharacter(line, , DiagOpts->TabStop);
-bool was_printable = res.second;
+  bool PrintReversed = false;
+  std::string ToPrint;
+  size_t I = 0;
+  while (I < SourceLine.size()) {
+auto [Str, WasPrintable] =
+printableTextForNextCharacter(SourceLine, , DiagOpts->TabStop);
 
-if (DiagOpts->ShowColors && was_printable == print_reversed) {
-  if (print_reversed)
+if (DiagOpts->ShowColors && WasPrintable == PrintReversed) {
+  if (PrintReversed)
 OS.reverseColor();
-  OS << to_print;
-  to_print.clear();
+  OS << ToPrint;
+  ToPrint.clear();
   if (DiagOpts->ShowColors)
 OS.resetColor();
 }
 
-print_reversed = !was_printable;
-to_print += res.first.str();
+PrintReversed = !WasPrintable;
+ToPrint += Str;
   }
 
-  if (print_reversed && DiagOpts->ShowColors)
+  if (PrintReversed && DiagOpts->ShowColors)
 OS.reverseColor();
-  OS << to_print;
-  if (print_reversed && DiagOpts->ShowColors)
+  OS << ToPrint;
+  if (PrintReversed && DiagOpts->ShowColors)
 OS.resetColor();
 
   OS << '\n';
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150758: [AIX] make integrated-as as default on AIX.

2023-05-17 Thread ChenZheng via Phabricator via cfe-commits
shchenz added inline comments.



Comment at: llvm/lib/MC/MCAsmInfoXCOFF.cpp:55
   HasDotTypeDotSizeDirective = false;
-  UseIntegratedAssembler = false;
+  UseIntegratedAssembler = true;
   ParseInlineAsmUsingAsmParser = true;

brad wrote:
> Instead of setting the value to true you can just remove the line all 
> together.
+1

And maybe this default value change can be put into another patch, as this is 
for backend?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150758

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


[PATCH] D150645: [Driver] Support multi /guard: options

2023-05-17 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei updated this revision to Diff 523256.
pengfei added a comment.

Sorry for the noise, I guess I missed a `A->claim()` here. Updated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150645

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/MSVC.cpp
  clang/test/Driver/cl-options.c


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -647,6 +647,10 @@
 // RUN: %clang_cl /guard:ehcont -### -- %s 2>&1 | FileCheck 
-check-prefix=EHCONTGUARD %s
 // EHCONTGUARD: -ehcontguard
 
+// RUN: %clang_cl /guard:cf /guard:ehcont -### -- %s 2>&1 | FileCheck 
-check-prefix=BOTHGUARD %s
+// BOTHGUARD: -cfguard
+// BOTHGUARD-SAME: -ehcontguard
+
 // RUN: %clang_cl /guard:foo -### -- %s 2>&1 | FileCheck 
-check-prefix=CFGUARDINVALID %s
 // CFGUARDINVALID: invalid value 'foo' in '/guard:'
 
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -227,7 +227,7 @@
   Args.AddAllArgValues(CmdArgs, options::OPT__SLASH_link);
 
   // Control Flow Guard checks
-  if (Arg *A = Args.getLastArg(options::OPT__SLASH_guard)) {
+  for (const Arg *A : Args.filtered(options::OPT__SLASH_guard)) {
 StringRef GuardArgs = A->getValue();
 if (GuardArgs.equals_insensitive("cf") ||
 GuardArgs.equals_insensitive("cf,nochecks")) {
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -7868,7 +7868,7 @@
   if (Args.hasArg(options::OPT__SLASH_kernel))
 CmdArgs.push_back("-fms-kernel");
 
-  if (Arg *A = Args.getLastArg(options::OPT__SLASH_guard)) {
+  for (const Arg *A : Args.filtered(options::OPT__SLASH_guard)) {
 StringRef GuardArgs = A->getValue();
 // The only valid options are "cf", "cf,nochecks", "cf-", "ehcont" and
 // "ehcont-".
@@ -7887,6 +7887,7 @@
 } else {
   D.Diag(diag::err_drv_invalid_value) << A->getSpelling() << GuardArgs;
 }
+A->claim();
   }
 }
 


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -647,6 +647,10 @@
 // RUN: %clang_cl /guard:ehcont -### -- %s 2>&1 | FileCheck -check-prefix=EHCONTGUARD %s
 // EHCONTGUARD: -ehcontguard
 
+// RUN: %clang_cl /guard:cf /guard:ehcont -### -- %s 2>&1 | FileCheck -check-prefix=BOTHGUARD %s
+// BOTHGUARD: -cfguard
+// BOTHGUARD-SAME: -ehcontguard
+
 // RUN: %clang_cl /guard:foo -### -- %s 2>&1 | FileCheck -check-prefix=CFGUARDINVALID %s
 // CFGUARDINVALID: invalid value 'foo' in '/guard:'
 
Index: clang/lib/Driver/ToolChains/MSVC.cpp
===
--- clang/lib/Driver/ToolChains/MSVC.cpp
+++ clang/lib/Driver/ToolChains/MSVC.cpp
@@ -227,7 +227,7 @@
   Args.AddAllArgValues(CmdArgs, options::OPT__SLASH_link);
 
   // Control Flow Guard checks
-  if (Arg *A = Args.getLastArg(options::OPT__SLASH_guard)) {
+  for (const Arg *A : Args.filtered(options::OPT__SLASH_guard)) {
 StringRef GuardArgs = A->getValue();
 if (GuardArgs.equals_insensitive("cf") ||
 GuardArgs.equals_insensitive("cf,nochecks")) {
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -7868,7 +7868,7 @@
   if (Args.hasArg(options::OPT__SLASH_kernel))
 CmdArgs.push_back("-fms-kernel");
 
-  if (Arg *A = Args.getLastArg(options::OPT__SLASH_guard)) {
+  for (const Arg *A : Args.filtered(options::OPT__SLASH_guard)) {
 StringRef GuardArgs = A->getValue();
 // The only valid options are "cf", "cf,nochecks", "cf-", "ehcont" and
 // "ehcont-".
@@ -7887,6 +7887,7 @@
 } else {
   D.Diag(diag::err_drv_invalid_value) << A->getSpelling() << GuardArgs;
 }
+A->claim();
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150690: [RISCV] Use IRBuilder::CreateInsertVector/CreateExtractVector to simplify code. NFC

2023-05-17 Thread Craig Topper 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 rG77f38e1325a2: [RISCV] Use 
IRBuilder::CreateInsertVector/CreateExtractVector to simplify code. (authored 
by craig.topper).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150690

Files:
  clang/include/clang/Basic/riscv_vector.td

Index: clang/include/clang/Basic/riscv_vector.td
===
--- clang/include/clang/Basic/riscv_vector.td
+++ clang/include/clang/Basic/riscv_vector.td
@@ -2045,28 +2045,18 @@
 // --(bitcast)> 
 // --(vector_extract)-> 
 llvm::Value *BitCast = Builder.CreateBitCast(Ops[0], Boolean64Ty);
-
-ID = Intrinsic::vector_extract;
-llvm::Value *Operands[2];
-Operands[0] = BitCast;
-Operands[1] = ConstantInt::get(Int64Ty, 0);
-IntrinsicTypes = {ResultType, Boolean64Ty};
-
-return Builder.CreateCall(CGM.getIntrinsic(ID, IntrinsicTypes), Operands, "");
+return Builder.CreateExtractVector(ResultType, BitCast,
+   ConstantInt::get(Int64Ty, 0));
   } else {
 // Casting from vector boolean -> m1 vector integer
 // Ex: 
 //   --(vector_insert)-> 
 //   --(bitcast)---> 
-ID = Intrinsic::vector_insert;
-llvm::Value *Operands[3];
-Operands[0] = llvm::PoisonValue::get(Boolean64Ty);
-Operands[1] = Ops[0];
-Operands[2] = ConstantInt::get(Int64Ty, 0);
-IntrinsicTypes = {Boolean64Ty, Ops[0]->getType()};
 llvm::Value *Boolean64Val =
-  Builder.CreateCall(CGM.getIntrinsic(ID, IntrinsicTypes), Operands, "");
-
+  Builder.CreateInsertVector(Boolean64Ty,
+ llvm::PoisonValue::get(Boolean64Ty),
+ Ops[0],
+ ConstantInt::get(Int64Ty, 0));
 return Builder.CreateBitCast(Boolean64Val, ResultType);
   }
 }
@@ -2151,10 +2141,8 @@
   let Name = "vlmul_trunc_v", OverloadedName = "vlmul_trunc",
   MaskedPolicyScheme = NonePolicy,
   ManualCodegen = [{ {
-ID = Intrinsic::vector_extract;
-IntrinsicTypes = {ResultType, Ops[0]->getType()};
-Ops.push_back(ConstantInt::get(Int64Ty, 0));
-return Builder.CreateCall(CGM.getIntrinsic(ID, IntrinsicTypes), Ops, "");
+return Builder.CreateExtractVector(ResultType, Ops[0],
+   ConstantInt::get(Int64Ty, 0));
   } }] in {
 foreach dst_lmul = ["(SFixedLog2LMUL:-3)", "(SFixedLog2LMUL:-2)", "(SFixedLog2LMUL:-1)",
 "(SFixedLog2LMUL:0)", "(SFixedLog2LMUL:1)", "(SFixedLog2LMUL:2)"] in {
@@ -2170,12 +2158,9 @@
   let Name = "vlmul_ext_v", OverloadedName = "vlmul_ext",
   MaskedPolicyScheme = NonePolicy,
   ManualCodegen = [{
-ID = Intrinsic::vector_insert;
-IntrinsicTypes = {ResultType, Ops[0]->getType()};
-Ops.push_back(llvm::PoisonValue::get(ResultType));
-std::swap(Ops[0], Ops[1]);
-Ops.push_back(ConstantInt::get(Int64Ty, 0));
-return Builder.CreateCall(CGM.getIntrinsic(ID, IntrinsicTypes), Ops, "");
+return Builder.CreateInsertVector(ResultType,
+  llvm::PoisonValue::get(ResultType),
+  Ops[0], ConstantInt::get(Int64Ty, 0));
   }] in {
 foreach dst_lmul = ["(LFixedLog2LMUL:-2)", "(LFixedLog2LMUL:-1)", "(LFixedLog2LMUL:-0)",
 "(LFixedLog2LMUL:1)", "(LFixedLog2LMUL:2)", "(LFixedLog2LMUL:3)"] in {
@@ -2189,7 +2174,6 @@
   let Name = "vget_v", MaskedPolicyScheme = NonePolicy,
   ManualCodegen = [{
   {
-ID = Intrinsic::vector_extract;
 auto *VecTy = cast(ResultType);
 auto *OpVecTy = cast(Ops[0]->getType());
 // Mask to only valid indices.
@@ -2200,8 +2184,7 @@
 Ops[1] = Builder.CreateMul(Ops[1],
ConstantInt::get(Ops[1]->getType(),
 VecTy->getMinNumElements()));
-IntrinsicTypes = {ResultType, Ops[0]->getType()};
-return Builder.CreateCall(CGM.getIntrinsic(ID, IntrinsicTypes), Ops, "");
+return Builder.CreateExtractVector(ResultType, Ops[0], Ops[1]);
   }
   }] in {
 foreach dst_lmul = ["(SFixedLog2LMUL:0)", "(SFixedLog2LMUL:1)", "(SFixedLog2LMUL:2)"] in {
@@ -2213,8 +2196,6 @@
   let Name = "vset_v", Log2LMUL = [0, 1, 2], MaskedPolicyScheme = NonePolicy,
   ManualCodegen = [{
   {
-ID = Intrinsic::vector_insert;
-IntrinsicTypes = 

[clang] 77f38e1 - [RISCV] Use IRBuilder::CreateInsertVector/CreateExtractVector to simplify code. NFC

2023-05-17 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2023-05-17T21:31:51-07:00
New Revision: 77f38e1325a251623ec39a0d9ffa718e80436f94

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

LOG: [RISCV] Use IRBuilder::CreateInsertVector/CreateExtractVector to simplify 
code. NFC

Reviewed By: eopXD

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

Added: 


Modified: 
clang/include/clang/Basic/riscv_vector.td

Removed: 




diff  --git a/clang/include/clang/Basic/riscv_vector.td 
b/clang/include/clang/Basic/riscv_vector.td
index b56ee074c20c..4fd769e0680d 100644
--- a/clang/include/clang/Basic/riscv_vector.td
+++ b/clang/include/clang/Basic/riscv_vector.td
@@ -2045,28 +2045,18 @@ let HasMasked = false, HasVL = false, IRName = "" in {
 // --(bitcast)> 
 // --(vector_extract)-> 
 llvm::Value *BitCast = Builder.CreateBitCast(Ops[0], Boolean64Ty);
-
-ID = Intrinsic::vector_extract;
-llvm::Value *Operands[2];
-Operands[0] = BitCast;
-Operands[1] = ConstantInt::get(Int64Ty, 0);
-IntrinsicTypes = {ResultType, Boolean64Ty};
-
-return Builder.CreateCall(CGM.getIntrinsic(ID, IntrinsicTypes), 
Operands, "");
+return Builder.CreateExtractVector(ResultType, BitCast,
+   ConstantInt::get(Int64Ty, 0));
   } else {
 // Casting from vector boolean -> m1 vector integer
 // Ex: 
 //   --(vector_insert)-> 
 //   --(bitcast)---> 
-ID = Intrinsic::vector_insert;
-llvm::Value *Operands[3];
-Operands[0] = llvm::PoisonValue::get(Boolean64Ty);
-Operands[1] = Ops[0];
-Operands[2] = ConstantInt::get(Int64Ty, 0);
-IntrinsicTypes = {Boolean64Ty, Ops[0]->getType()};
 llvm::Value *Boolean64Val =
-  Builder.CreateCall(CGM.getIntrinsic(ID, IntrinsicTypes), 
Operands, "");
-
+  Builder.CreateInsertVector(Boolean64Ty,
+ llvm::PoisonValue::get(Boolean64Ty),
+ Ops[0],
+ ConstantInt::get(Int64Ty, 0));
 return Builder.CreateBitCast(Boolean64Val, ResultType);
   }
 }
@@ -2151,10 +2141,8 @@ let HasMasked = false, HasVL = false, IRName = "" in {
   let Name = "vlmul_trunc_v", OverloadedName = "vlmul_trunc",
   MaskedPolicyScheme = NonePolicy,
   ManualCodegen = [{ {
-ID = Intrinsic::vector_extract;
-IntrinsicTypes = {ResultType, Ops[0]->getType()};
-Ops.push_back(ConstantInt::get(Int64Ty, 0));
-return Builder.CreateCall(CGM.getIntrinsic(ID, IntrinsicTypes), Ops, 
"");
+return Builder.CreateExtractVector(ResultType, Ops[0],
+   ConstantInt::get(Int64Ty, 0));
   } }] in {
 foreach dst_lmul = ["(SFixedLog2LMUL:-3)", "(SFixedLog2LMUL:-2)", 
"(SFixedLog2LMUL:-1)",
 "(SFixedLog2LMUL:0)", "(SFixedLog2LMUL:1)", 
"(SFixedLog2LMUL:2)"] in {
@@ -2170,12 +2158,9 @@ let HasMasked = false, HasVL = false, IRName = "" in {
   let Name = "vlmul_ext_v", OverloadedName = "vlmul_ext",
   MaskedPolicyScheme = NonePolicy,
   ManualCodegen = [{
-ID = Intrinsic::vector_insert;
-IntrinsicTypes = {ResultType, Ops[0]->getType()};
-Ops.push_back(llvm::PoisonValue::get(ResultType));
-std::swap(Ops[0], Ops[1]);
-Ops.push_back(ConstantInt::get(Int64Ty, 0));
-return Builder.CreateCall(CGM.getIntrinsic(ID, IntrinsicTypes), Ops, 
"");
+return Builder.CreateInsertVector(ResultType,
+  llvm::PoisonValue::get(ResultType),
+  Ops[0], ConstantInt::get(Int64Ty, 
0));
   }] in {
 foreach dst_lmul = ["(LFixedLog2LMUL:-2)", "(LFixedLog2LMUL:-1)", 
"(LFixedLog2LMUL:-0)",
 "(LFixedLog2LMUL:1)", "(LFixedLog2LMUL:2)", 
"(LFixedLog2LMUL:3)"] in {
@@ -2189,7 +2174,6 @@ let HasMasked = false, HasVL = false, IRName = "" in {
   let Name = "vget_v", MaskedPolicyScheme = NonePolicy,
   ManualCodegen = [{
   {
-ID = Intrinsic::vector_extract;
 auto *VecTy = cast(ResultType);
 auto *OpVecTy = cast(Ops[0]->getType());
 // Mask to only valid indices.
@@ -2200,8 +2184,7 @@ let HasMasked = false, HasVL = false, IRName = "" in {
 Ops[1] = Builder.CreateMul(Ops[1],
ConstantInt::get(Ops[1]->getType(),
 
VecTy->getMinNumElements()));
-IntrinsicTypes = {ResultType, 

[PATCH] D144829: [WIP][BPF] Add a few new insns under cpu=v4

2023-05-17 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song updated this revision to Diff 523253.
yonghong-song added a comment.

- Fixed issues reported by Eduard
- llvm-objdump issue (as stated in 'Summary') is not resolved yet.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144829

Files:
  clang/lib/Basic/Targets/BPF.cpp
  clang/lib/Basic/Targets/BPF.h
  clang/test/Misc/target-invalid-cpu-note.c
  llvm/lib/Target/BPF/BPF.td
  llvm/lib/Target/BPF/BPFISelDAGToDAG.cpp
  llvm/lib/Target/BPF/BPFISelLowering.cpp
  llvm/lib/Target/BPF/BPFInstrFormats.td
  llvm/lib/Target/BPF/BPFInstrInfo.cpp
  llvm/lib/Target/BPF/BPFInstrInfo.td
  llvm/lib/Target/BPF/BPFMIPeephole.cpp
  llvm/lib/Target/BPF/BPFSubtarget.cpp
  llvm/lib/Target/BPF/BPFSubtarget.h
  llvm/lib/Target/BPF/Disassembler/BPFDisassembler.cpp
  llvm/lib/Target/BPF/MCTargetDesc/BPFAsmBackend.cpp
  llvm/lib/Target/BPF/MCTargetDesc/BPFInstPrinter.cpp
  llvm/lib/Target/BPF/MCTargetDesc/BPFMCCodeEmitter.cpp
  llvm/lib/Target/BPF/MCTargetDesc/BPFMCFixups.h
  llvm/test/CodeGen/BPF/bswap.ll
  llvm/test/CodeGen/BPF/sdiv_smod.ll
  llvm/test/CodeGen/BPF/sext_ld.ll
  llvm/test/CodeGen/BPF/sext_mov.ll

Index: llvm/test/CodeGen/BPF/sext_mov.ll
===
--- /dev/null
+++ llvm/test/CodeGen/BPF/sext_mov.ll
@@ -0,0 +1,109 @@
+; RUN: llc -march=bpfel -mcpu=v4 -verify-machineinstrs -show-mc-encoding < %s | FileCheck %s
+; Source:
+;  short f1(int a) {
+;return (char)a;
+;  }
+;  int f2(int a) {
+;return (char)a;
+;  }
+;  long f3(int a) {
+;return (char)a;
+;  }
+;  int f4(int a) {
+;return (short)a;
+;  }
+;  long f5(int a) {
+;return (short)a;
+;  }
+;  long f6(long a) {
+;return (int)a;
+;  }
+; Compilation flags:
+;   clang -target bpf -O2 -S -emit-llvm -Xclang -disable-llvm-passes t.c
+
+; Function Attrs: nounwind
+define dso_local i16 @f1(i32 noundef %a) #0 {
+entry:
+  %a.addr = alloca i32, align 4
+  store i32 %a, ptr %a.addr, align 4, !tbaa !3
+  %0 = load i32, ptr %a.addr, align 4, !tbaa !3
+  %conv = trunc i32 %0 to i8
+  %conv1 = sext i8 %conv to i16
+  ret i16 %conv1
+}
+; CHECK: w0 = (s8)w1  # encoding: [0xbc,0x10,0x08,0x00,0x00,0x00,0x00,0x00]
+
+; Function Attrs: nounwind
+define dso_local i32 @f2(i32 noundef %a) #0 {
+entry:
+  %a.addr = alloca i32, align 4
+  store i32 %a, ptr %a.addr, align 4, !tbaa !3
+  %0 = load i32, ptr %a.addr, align 4, !tbaa !3
+  %conv = trunc i32 %0 to i8
+  %conv1 = sext i8 %conv to i32
+  ret i32 %conv1
+}
+; CHECK: w0 = (s8)w1  # encoding: [0xbc,0x10,0x08,0x00,0x00,0x00,0x00,0x00]
+
+; Function Attrs: nounwind
+define dso_local i64 @f3(i32 noundef %a) #0 {
+entry:
+  %a.addr = alloca i32, align 4
+  store i32 %a, ptr %a.addr, align 4, !tbaa !3
+  %0 = load i32, ptr %a.addr, align 4, !tbaa !3
+  %conv = trunc i32 %0 to i8
+  %conv1 = sext i8 %conv to i64
+  ret i64 %conv1
+}
+; CHECK: r0 = (s8)r1  # encoding: [0xbf,0x10,0x08,0x00,0x00,0x00,0x00,0x00]
+
+; Function Attrs: nounwind
+define dso_local i32 @f4(i32 noundef %a) #0 {
+entry:
+  %a.addr = alloca i32, align 4
+  store i32 %a, ptr %a.addr, align 4, !tbaa !3
+  %0 = load i32, ptr %a.addr, align 4, !tbaa !3
+  %conv = trunc i32 %0 to i16
+  %conv1 = sext i16 %conv to i32
+  ret i32 %conv1
+}
+; CHECK: w0 = (s16)w1  # encoding: [0xbc,0x10,0x10,0x00,0x00,0x00,0x00,0x00]
+
+; Function Attrs: nounwind
+define dso_local i64 @f5(i32 noundef %a) #0 {
+entry:
+  %a.addr = alloca i32, align 4
+  store i32 %a, ptr %a.addr, align 4, !tbaa !3
+  %0 = load i32, ptr %a.addr, align 4, !tbaa !3
+  %conv = trunc i32 %0 to i16
+  %conv1 = sext i16 %conv to i64
+  ret i64 %conv1
+}
+; CHECK: r0 = (s16)r1  # encoding: [0xbf,0x10,0x10,0x00,0x00,0x00,0x00,0x00]
+
+; Function Attrs: nounwind
+define dso_local i64 @f6(i64 noundef %a) #0 {
+entry:
+  %a.addr = alloca i64, align 8
+  store i64 %a, ptr %a.addr, align 8, !tbaa !7
+  %0 = load i64, ptr %a.addr, align 8, !tbaa !7
+  %conv = trunc i64 %0 to i32
+  %conv1 = sext i32 %conv to i64
+  ret i64 %conv1
+}
+; CHECK: r0 = (s32)r1  # encoding: [0xbf,0x10,0x20,0x00,0x00,0x00,0x00,0x00]
+
+attributes #0 = { nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
+
+!llvm.module.flags = !{!0, !1}
+!llvm.ident = !{!2}
+
+!0 = !{i32 1, !"wchar_size", i32 4}
+!1 = !{i32 7, !"frame-pointer", i32 2}
+!2 = !{!"clang version 17.0.0 (https://github.com/llvm/llvm-project.git 569bd3b841e3167ddd7c6ceeddb282d3c280e761)"}
+!3 = !{!4, !4, i64 0}
+!4 = !{!"int", !5, i64 0}
+!5 = !{!"omnipotent char", !6, i64 0}
+!6 = !{!"Simple C/C++ TBAA"}
+!7 = !{!8, !8, i64 0}
+!8 = !{!"long", !5, i64 0}
Index: llvm/test/CodeGen/BPF/sext_ld.ll
===
--- /dev/null
+++ llvm/test/CodeGen/BPF/sext_ld.ll
@@ -0,0 +1,104 @@
+; RUN: llc -march=bpfel -mcpu=v4 -verify-machineinstrs -show-mc-encoding < %s | FileCheck %s
+; Source:
+;  int f1(char *p) {
+;return *p;
+; 

[PATCH] D150646: [clang][X86] Add __cpuidex function to cpuid.h

2023-05-17 Thread Mike Hommey via Phabricator via cfe-commits
glandium added a comment.

Repro:

  $ echo '#include "cpuid.h"' | ./clang/bin/clang-cl  -Tp -
  clang-cl: warning: unable to find a Visual Studio installation; try running 
Clang from a developer command prompt [-Wmsvc-not-found]
  In file included from :1:
  /tmp/ct/clang/lib/clang/17/include/cpuid.h(331,22): error: definition of 
builtin function '__cpuidex'
  static __inline void __cpuidex (int __cpu_info[4], int __leaf, int __subleaf)
   ^
  1 error generated.

(interestingly doesn't happen in C mode (with `-Tc` instead of `-Tp`))


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150646

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


[PATCH] D150730: [Clang][Sema] Substitute constraints only for declarations with different lexical contexts

2023-05-17 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/lib/Sema/SemaConcept.cpp:783
 return true;
-  if (Old && New && Old != New) {
+  if (Old && New && Old != New &&
+  Old->getLexicalDeclContext() != New->getLexicalDeclContext()) {

shafik wrote:
> erichkeane wrote:
> > Please put the standards quote that supports this here, it'll be really 
> > useful in the future.(temp.constr.decl p4)
> Yes, the change makes a lot more sense with the quote. 
> 
> 
I noticed you landed this w/ the citation but w/o quoting the text. Usually it 
is helpful to quote it b/c it explains the code that follows w/o the reader 
having to open the standard and read it and then go back to the code. 

In this case I think quoting up to the "outside the class body" may be 
sufficient.

Worth also noting that paragraphs often move around and so years later the 
reader may have a hard time matching up. At least w/ the quoted text they have 
material to start an investigation with if the wording has moved and or 
changed. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150730

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


[PATCH] D150646: [clang][X86] Add __cpuidex function to cpuid.h

2023-05-17 Thread Mike Hommey via Phabricator via cfe-commits
glandium added a comment.

This causes errors like:

  /builds/worker/fetches/clang/lib/clang/17/include/cpuid.h(331,22): error: 
definition of builtin function '__cpuidex'
   static __inline void __cpuidex (int __cpu_info[4], int __leaf, int __subleaf)
^
   1 error generated.

when building Firefox.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150646

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


[PATCH] D150690: [RISCV] Use IRBuilder::CreateInsertVector/CreateExtractVector to simplify code. NFC

2023-05-17 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD accepted this revision.
eopXD added a comment.
This revision is now accepted and ready to land.

Looks good to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150690

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


[PATCH] D146358: [clang][AST] Print name instead of type when diagnosing uninitialized subobject in constexpr variables

2023-05-17 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet added a comment.

In D146358#4350810 , @erichkeane 
wrote:

> Our downstream discovered that this causes a regression when compiling 
> `utility` with `ast-dump`.  I've put up a minimal reproducer: 
> https://godbolt.org/z/oaezas7Ws
>
> @hazohelet : Will you be able to look into this soon?

Thanks for the report and the reproducer.
I cannot take sufficient time for about 36 hours, but I'll be able to 
investigate it after that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146358

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


[PATCH] D129824: [RISCV] Set triple based on -march flag which can be deduced in more generic way

2023-05-17 Thread Zixuan Wu via Phabricator via cfe-commits
zixuan-wu abandoned this revision.
zixuan-wu added a comment.
Herald added subscribers: jobnoorman, luke.

As this issue is solved at https://reviews.llvm.org/D148124, abandon this 
revision.


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

https://reviews.llvm.org/D129824

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


[PATCH] D148124: [RISCV][Driver] Allow the use of CPUs with a different XLEN than the triple.

2023-05-17 Thread Zixuan Wu via Phabricator via cfe-commits
zixuan-wu added a comment.

Thx. It has solved the issue D129824 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148124

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


[PATCH] D150614: [clang-format] Ignore first token when finding MustBreak

2023-05-17 Thread Emilia Kond via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG06763ea5d8f9: [clang-format] Ignore first token when finding 
MustBreak (authored by rymiel).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150614

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -13832,6 +13832,20 @@
 "}",
 format("A()\n:b(0)\n{\n}", NoColumnLimit));
 
+  FormatStyle NoColumnLimitWrapAfterFunction = NoColumnLimit;
+  NoColumnLimitWrapAfterFunction.BreakBeforeBraces = FormatStyle::BS_Custom;
+  NoColumnLimitWrapAfterFunction.BraceWrapping.AfterFunction = true;
+  verifyFormat("class C {\n"
+   "#pragma foo\n"
+   "  int foo { return 0; }\n"
+   "};",
+   NoColumnLimitWrapAfterFunction);
+  verifyFormat("class C {\n"
+   "#pragma foo\n"
+   "  void foo {}\n"
+   "};",
+   NoColumnLimitWrapAfterFunction);
+
   FormatStyle DoNotMergeNoColumnLimit = NoColumnLimit;
   DoNotMergeNoColumnLimit.AllowShortFunctionsOnASingleLine =
   FormatStyle::SFS_None;
@@ -20120,9 +20134,7 @@
"  int i = 5;\n"
"  }\n"
"#ifdef _DEBUG\n"
-   "void bar()\n"
-   "  {\n"
-   "  }\n"
+   "void bar() {}\n"
"#else\n"
"void bar()\n"
"  {\n"
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -888,7 +888,10 @@
   }
 
   bool containsMustBreak(const AnnotatedLine *Line) {
-for (const FormatToken *Tok = Line->First; Tok; Tok = Tok->Next)
+assert(Line->First);
+// Ignore the first token, because in this situation, it applies more to 
the
+// last token of the previous line.
+for (const FormatToken *Tok = Line->First->Next; Tok; Tok = Tok->Next)
   if (Tok->MustBreakBefore)
 return true;
 return false;


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -13832,6 +13832,20 @@
 "}",
 format("A()\n:b(0)\n{\n}", NoColumnLimit));
 
+  FormatStyle NoColumnLimitWrapAfterFunction = NoColumnLimit;
+  NoColumnLimitWrapAfterFunction.BreakBeforeBraces = FormatStyle::BS_Custom;
+  NoColumnLimitWrapAfterFunction.BraceWrapping.AfterFunction = true;
+  verifyFormat("class C {\n"
+   "#pragma foo\n"
+   "  int foo { return 0; }\n"
+   "};",
+   NoColumnLimitWrapAfterFunction);
+  verifyFormat("class C {\n"
+   "#pragma foo\n"
+   "  void foo {}\n"
+   "};",
+   NoColumnLimitWrapAfterFunction);
+
   FormatStyle DoNotMergeNoColumnLimit = NoColumnLimit;
   DoNotMergeNoColumnLimit.AllowShortFunctionsOnASingleLine =
   FormatStyle::SFS_None;
@@ -20120,9 +20134,7 @@
"  int i = 5;\n"
"  }\n"
"#ifdef _DEBUG\n"
-   "void bar()\n"
-   "  {\n"
-   "  }\n"
+   "void bar() {}\n"
"#else\n"
"void bar()\n"
"  {\n"
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -888,7 +888,10 @@
   }
 
   bool containsMustBreak(const AnnotatedLine *Line) {
-for (const FormatToken *Tok = Line->First; Tok; Tok = Tok->Next)
+assert(Line->First);
+// Ignore the first token, because in this situation, it applies more to the
+// last token of the previous line.
+for (const FormatToken *Tok = Line->First->Next; Tok; Tok = Tok->Next)
   if (Tok->MustBreakBefore)
 return true;
 return false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 06763ea - [clang-format] Ignore first token when finding MustBreak

2023-05-17 Thread Emilia Kond via cfe-commits

Author: Emilia Kond
Date: 2023-05-18T05:50:26+03:00
New Revision: 06763ea5d8f96625545bb2c2445363aca9922bf1

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

LOG: [clang-format] Ignore first token when finding MustBreak

When in ColumnLimit 0, the formatter looks for MustBreakBefore in the
line in order to check if a line is allowed to be merged onto one line.

However, since MustBreakBefore is really a property of the gap between
the token and the one previously, I belive the check is erroneous in
checking all the tokens in a line, since whether the previous line ended
with a forced line break should have no effect on whether the current
line is allowed to merge with the next one.

This patch changes the check to skip the first token in
`LineJoiner.containsMustBreak`.

This patch also changes a test, which is not ideal, but I believe the
test also suffered from this bug. The test case in question sets
AllowShortFunctionsOnASingleLine to "Empty", but the empty function in
said test case isn't merged to a single line, because of the very same
bug this patch fixes.

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

Reviewed By: HazardyKnusperkeks, owenpan, MyDeveloperDay

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineFormatter.cpp 
b/clang/lib/Format/UnwrappedLineFormatter.cpp
index ee0de2c8e20da..33be74dfe1b9f 100644
--- a/clang/lib/Format/UnwrappedLineFormatter.cpp
+++ b/clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -888,7 +888,10 @@ class LineJoiner {
   }
 
   bool containsMustBreak(const AnnotatedLine *Line) {
-for (const FormatToken *Tok = Line->First; Tok; Tok = Tok->Next)
+assert(Line->First);
+// Ignore the first token, because in this situation, it applies more to 
the
+// last token of the previous line.
+for (const FormatToken *Tok = Line->First->Next; Tok; Tok = Tok->Next)
   if (Tok->MustBreakBefore)
 return true;
 return false;

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index dec0ea72b58ab..942c6259015e9 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -13832,6 +13832,20 @@ TEST_F(FormatTest, 
PullTrivialFunctionDefinitionsIntoSingleLine) {
 "}",
 format("A()\n:b(0)\n{\n}", NoColumnLimit));
 
+  FormatStyle NoColumnLimitWrapAfterFunction = NoColumnLimit;
+  NoColumnLimitWrapAfterFunction.BreakBeforeBraces = FormatStyle::BS_Custom;
+  NoColumnLimitWrapAfterFunction.BraceWrapping.AfterFunction = true;
+  verifyFormat("class C {\n"
+   "#pragma foo\n"
+   "  int foo { return 0; }\n"
+   "};",
+   NoColumnLimitWrapAfterFunction);
+  verifyFormat("class C {\n"
+   "#pragma foo\n"
+   "  void foo {}\n"
+   "};",
+   NoColumnLimitWrapAfterFunction);
+
   FormatStyle DoNotMergeNoColumnLimit = NoColumnLimit;
   DoNotMergeNoColumnLimit.AllowShortFunctionsOnASingleLine =
   FormatStyle::SFS_None;
@@ -20120,9 +20134,7 @@ TEST_F(FormatTest, WhitesmithsBraceBreaking) {
"  int i = 5;\n"
"  }\n"
"#ifdef _DEBUG\n"
-   "void bar()\n"
-   "  {\n"
-   "  }\n"
+   "void bar() {}\n"
"#else\n"
"void bar()\n"
"  {\n"



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


[PATCH] D143675: Discussion: Darwin Sanitizers Stable ABI

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



Comment at: compiler-rt/docs/ASanABI.rst:29
+
+  Following are some examples of reasonable responses to such changes:
+

How does the 2-space indentation render in the built HTML? It may look good, I 
ask just in case.



Comment at: compiler-rt/lib/asan_abi/asan_abi.h:18
+// Functions concerning instrumented global variables:
+void __asan_abi_register_image_globals(void);
+void __asan_abi_unregister_image_globals(void);

`asan_abi.h` is C++ only (`extern "C"` isn't allowed in C). `(void)` should be 
replaced with `()`.



Comment at: compiler-rt/lib/asan_abi/asan_abi_shim.cpp:14
+extern "C" {
+// Functions concerning instrumented global variables:
+void __asan_register_image_globals(uptr *flag) {

Below there is no `:`. You may omit this `:` as well.



Comment at: compiler-rt/lib/asan_abi/asan_abi_shim.cpp:345
+// Functions concerning fake stacks
+void *__asan_get_current_fake_stack(void) {
+  // TBD: Fail here





Comment at: compiler-rt/test/asan_abi/lit.cfg.py:13
+lit_config.fatal(
+  "No attribute %r in test configuration! You may need to run "
+  "tests from your build directory or add this attribute "

This file mixes single quotes and double quotes (the file it copied from does 
so as well). Pick one and be consistent!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143675

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


[PATCH] D148094: [clang][CodeGen] Break up TargetInfo.cpp [8/8]

2023-05-17 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 updated this revision to Diff 523240.
barannikov88 added a comment.

Undo remaining unintended formatting changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148094

Files:
  clang/docs/UsersManual.rst
  clang/docs/tools/clang-formatted-files.txt
  clang/lib/CodeGen/ABIInfo.cpp
  clang/lib/CodeGen/ABIInfo.h
  clang/lib/CodeGen/ABIInfoImpl.cpp
  clang/lib/CodeGen/ABIInfoImpl.h
  clang/lib/CodeGen/CMakeLists.txt
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/Targets/AArch64.cpp
  clang/lib/CodeGen/Targets/AMDGPU.cpp
  clang/lib/CodeGen/Targets/ARC.cpp
  clang/lib/CodeGen/Targets/ARM.cpp
  clang/lib/CodeGen/Targets/AVR.cpp
  clang/lib/CodeGen/Targets/BPF.cpp
  clang/lib/CodeGen/Targets/CSKY.cpp
  clang/lib/CodeGen/Targets/Hexagon.cpp
  clang/lib/CodeGen/Targets/Lanai.cpp
  clang/lib/CodeGen/Targets/LoongArch.cpp
  clang/lib/CodeGen/Targets/M68k.cpp
  clang/lib/CodeGen/Targets/MSP430.cpp
  clang/lib/CodeGen/Targets/Mips.cpp
  clang/lib/CodeGen/Targets/NVPTX.cpp
  clang/lib/CodeGen/Targets/PNaCl.cpp
  clang/lib/CodeGen/Targets/PPC.cpp
  clang/lib/CodeGen/Targets/RISCV.cpp
  clang/lib/CodeGen/Targets/SPIR.cpp
  clang/lib/CodeGen/Targets/Sparc.cpp
  clang/lib/CodeGen/Targets/SystemZ.cpp
  clang/lib/CodeGen/Targets/TCE.cpp
  clang/lib/CodeGen/Targets/VE.cpp
  clang/lib/CodeGen/Targets/WebAssembly.cpp
  clang/lib/CodeGen/Targets/X86.cpp
  clang/lib/CodeGen/Targets/XCore.cpp
  clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp
  llvm/utils/gn/secondary/clang/lib/CodeGen/BUILD.gn

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


[PATCH] D150411: [NFC][Clang][Coverity] Fix Static Code Analysis Concerns with copy without assign

2023-05-17 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:1790
 SemaDiagnosticBuilder(const SemaDiagnosticBuilder &) = default;
+SemaDiagnosticBuilder =(const SemaDiagnosticBuilder &) = delete;
 ~SemaDiagnosticBuilder();

aaronpuchert wrote:
> tahonermann wrote:
> > 
> Being explicit is certainly a good thing, but the C++ committee wants to go 
> into the direction of "copy/move operations are implicitly deleted if any of 
> them or the destructor is user-declared." See 
> [depr.impldec](https://eel.is/c++draft/depr.impldec). It is already partially 
> the case, for example here. So why do need to spell something out explicitly 
> when the language goes into the direction of being even more implicit?
I have low expectations of that deprecation ever being acted on. In fact, there 
have been discussions about un-deprecating it because of the lack of such 
intent.

The motivation for deprecation is not based on a judgement of whether implicit 
or explicit is better, but rather based on a safety argument; if a copy 
constructor or destructor is user-declared, that is probably because some form 
of resource management is needed that won't be performed by the defaulted copy 
assignment operator. Thus, defining the implicit copy assignment operator as 
deleted would avoid the possibility of the compiler injecting bugs in the 
program.

The rules for when the copy vs assignment operators are implicitly defined as 
deleted can be hard to remember. I think being explicit is useful if only to 
indicate that the author thought about whether such operations should be 
provided. Since we don't have a principled reason for defining these operations 
as deleted, it might not be a bad idea to add a comment that states something 
like "The copy/move assignment operator is defined as deleted pending further 
motivation".


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

https://reviews.llvm.org/D150411

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


[PATCH] D150758: [AIX] make integrated-as as default on AIX.

2023-05-17 Thread Brad Smith via Phabricator via cfe-commits
brad added inline comments.



Comment at: llvm/lib/MC/MCAsmInfoXCOFF.cpp:55
   HasDotTypeDotSizeDirective = false;
-  UseIntegratedAssembler = false;
+  UseIntegratedAssembler = true;
   ParseInlineAsmUsingAsmParser = true;

Instead of setting the value to true you can just remove the line all together.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150758

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


[PATCH] D143675: Discussion: Darwin Sanitizers Stable ABI

2023-05-17 Thread Roy Sundahl via Phabricator via cfe-commits
rsundahl added a comment.

Ping @kcc , @yln and @kubamracek


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143675

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


[PATCH] D143675: Discussion: Darwin Sanitizers Stable ABI

2023-05-17 Thread Roy Sundahl via Phabricator via cfe-commits
rsundahl added a comment.

@MaskRay, thank you for your approval. @eugenis, you were added as a blocking 
reviewer by @vitalybuka. If you are still without objection, can we get your 
approval and merge? Thank you all for your input.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143675

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


[PATCH] D148785: -fsanitize=function: use type hashes instead of RTTI objects

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



Comment at: llvm/test/CodeGen/AArch64/patchable-function-entry-bti.ll:92
 ; CHECK-NEXT: .Ltmp{{.*}}:
 ; CHECK-NEXT:   nop
 ; CHECK-NEXT:   .word   3238382334  // 0xc105cafe

MaskRay wrote:
> peter.smith wrote:
> > samitolvanen wrote:
> > > peter.smith wrote:
> > > > Assuming the test is the equivalent of `-fpatchable-function-entry=1,1` 
> > > > I think this is the wrong place for the nop, I think it needs to be 
> > > > after the signature and the loads adjusted. For example with 
> > > > -fsanitize=kcfi -fpatchable-function-entries=1,1
> > > > ```
> > > > typedef int Fptr(void);
> > > > 
> > > > int function(void) {
> > > >   return 0;
> > > > }
> > > > 
> > > > int call(Fptr* fp) {
> > > >   return fp();
> > > > }
> > > > ```
> > > > Results in code like:
> > > > ```
> > > > .word   1670944012  // @call
> > > > // 0x6398950c
> > > > .Ltmp1:
> > > > nop
> > > > call:
> > > > .Lfunc_begin1:
> > > > .cfi_startproc
> > > > // %bb.0:   // %entry
> > > > ldurw16, [x0, #-8]
> > > > movkw17, #50598
> > > > movkw17, #14001, lsl #16
> > > > cmp w16, w17
> > > > b.eq.Ltmp2
> > > > brk #0x8220
> > > > .Ltmp2:
> > > > br  x0
> > > > .Lfunc_end1:
> > > > ```
> > > > Note the NOP is after the signature, with the `ldur` having an offset 
> > > > of -8 and not the usual -4. I think you would need to make sure the 
> > > > signature is a branch instruction for each target for this scheme to 
> > > > work.
> > > No, this looks correct to me. Note that in AsmPrinter the type hash is 
> > > emitted after the patchable-function-prefix nops, while the KCFI type 
> > > hash is emitted before them.
> > My concern is more along the lines of how would this function be patched if 
> > the code doing the patching were unaware of the signature. I'm not familiar 
> > with how the kernel uses the nops so it could be that this is won't be a 
> > problem in practice.
> > 
> > With -fsanitize=kcfi it looks like there is no difference to the code doing 
> > the patching as the nops are in the same place with respect to the function 
> > entry point and there is no fall through into the signature.
> > 
> > With -fsanitize=function anything patching the first nop as an instruction 
> > would need to branch over the signature (unless the first entry of the 
> > signature was a branch instruction, but that would mean a target specific 
> > signature), obviously if the nop is patched with data and isn't the entry 
> > point then this doesn't matter. The code doing the patching would also need 
> > to know how to locate the nop ahead of the signature.
> The responsibility is on the user side to ensure that when M>0, they code 
> patches one of the M NOPs to a branch over the signature (0xc105cafe). 
> 
> ```
> // -fsanitize=function -fpatchable-function-entry=3,3
> .Ltmp0:
> nop
> nop
> nop# ensure there is a branch over the signature
> .long   3238382334  # 0xc105cafe
> .long   2772461324  # 0xa540670c
> foo:
> ```
> 
> In addition, `-fpatchable-function-entry=N,M` where M>0 is uncommon. 
> `-fpatchable-function-entry=` didn't work with `-fsanitize=function` before 
> my changes.
> 
> My concern is more along the lines of how would this function be patched if 
> the code doing the patching were unaware of the signature. I'm not familiar 
> with how the kernel uses the nops so it could be that this is won't be a 
> problem in practice.

I think the patching code must be aware if the user decides to use 
`-fpatchable-function-entry=N,M` where `M>0`, otherwise it's the pilot error to 
use the option with `-fsanitize=function`.

`-fsanitize=function` is designed to be compatible with uninstrumented 
functions (used as indirect call callees) and compatible with object files,  
`-fpatchable-function-entry=N,M` functions, and regular functions. The call 
site must use the fixed offset unaffected by `-fpatchable-function-entry=N,M`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148785

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


[PATCH] D148094: [clang][CodeGen] Break up TargetInfo.cpp [8/8]

2023-05-17 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 updated this revision to Diff 523236.
barannikov88 added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148094

Files:
  clang/docs/UsersManual.rst
  clang/docs/tools/clang-formatted-files.txt
  clang/lib/CodeGen/ABIInfo.cpp
  clang/lib/CodeGen/ABIInfo.h
  clang/lib/CodeGen/ABIInfoImpl.cpp
  clang/lib/CodeGen/ABIInfoImpl.h
  clang/lib/CodeGen/CMakeLists.txt
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/Targets/AArch64.cpp
  clang/lib/CodeGen/Targets/AMDGPU.cpp
  clang/lib/CodeGen/Targets/ARC.cpp
  clang/lib/CodeGen/Targets/ARM.cpp
  clang/lib/CodeGen/Targets/AVR.cpp
  clang/lib/CodeGen/Targets/BPF.cpp
  clang/lib/CodeGen/Targets/CSKY.cpp
  clang/lib/CodeGen/Targets/Hexagon.cpp
  clang/lib/CodeGen/Targets/Lanai.cpp
  clang/lib/CodeGen/Targets/LoongArch.cpp
  clang/lib/CodeGen/Targets/M68k.cpp
  clang/lib/CodeGen/Targets/MSP430.cpp
  clang/lib/CodeGen/Targets/Mips.cpp
  clang/lib/CodeGen/Targets/NVPTX.cpp
  clang/lib/CodeGen/Targets/PNaCl.cpp
  clang/lib/CodeGen/Targets/PPC.cpp
  clang/lib/CodeGen/Targets/RISCV.cpp
  clang/lib/CodeGen/Targets/SPIR.cpp
  clang/lib/CodeGen/Targets/Sparc.cpp
  clang/lib/CodeGen/Targets/SystemZ.cpp
  clang/lib/CodeGen/Targets/TCE.cpp
  clang/lib/CodeGen/Targets/VE.cpp
  clang/lib/CodeGen/Targets/WebAssembly.cpp
  clang/lib/CodeGen/Targets/X86.cpp
  clang/lib/CodeGen/Targets/XCore.cpp
  clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp
  llvm/utils/gn/secondary/clang/lib/CodeGen/BUILD.gn

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


[PATCH] D148093: [clang][CodeGen] Break up TargetInfo.cpp [5/8]

2023-05-17 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 updated this revision to Diff 523235.
barannikov88 added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148093

Files:
  clang/lib/CodeGen/ABIInfo.h
  clang/lib/CodeGen/TargetInfo.cpp


Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -125,7 +125,7 @@
 /// registers when expanded?
 ///
 /// This is intended to be the basis of a reasonable basic implementation
-/// of should{Pass,Return}IndirectlyForSwift.
+/// of should{Pass,Return}Indirectly.
 ///
 /// For most targets, a limit of four total registers is reasonable; this
 /// limits the amount of code required in order to move around the value
@@ -134,15 +134,14 @@
 /// immediately within the callee.  But some targets may need to further
 /// limit the register count due to an inability to support that many
 /// return registers.
-static bool occupiesMoreThan(CodeGenTypes ,
- ArrayRef scalarTypes,
- unsigned maxAllRegisters) {
+bool SwiftABIInfo::occupiesMoreThan(ArrayRef scalarTypes,
+unsigned maxAllRegisters) const {
   unsigned intCount = 0, fpCount = 0;
   for (llvm::Type *type : scalarTypes) {
 if (type->isPointerTy()) {
   intCount++;
 } else if (auto intTy = dyn_cast(type)) {
-  auto ptrWidth = cgt.getTarget().getPointerWidth(LangAS::Default);
+  auto ptrWidth = CGT.getTarget().getPointerWidth(LangAS::Default);
   intCount += (intTy->getBitWidth() + ptrWidth - 1) / ptrWidth;
 } else {
   assert(type->isVectorTy() || type->isFloatingPointTy());
@@ -155,7 +154,7 @@
 
 bool SwiftABIInfo::shouldPassIndirectly(ArrayRef ComponentTys,
 bool AsReturnValue) const {
-  return occupiesMoreThan(CGT, ComponentTys, /*total=*/4);
+  return occupiesMoreThan(ComponentTys, /*total=*/4);
 }
 
 bool SwiftABIInfo::isLegalVectorType(CharUnits VectorSize, llvm::Type *EltTy,
@@ -1248,7 +1247,7 @@
 // integer registers and three fp registers.  Oddly, it'll use up to
 // four vector registers for vectors, but those can overlap with the
 // scalar registers.
-return occupiesMoreThan(CGT, ComponentTys, /*total=*/3);
+return occupiesMoreThan(ComponentTys, /*total=*/3);
   }
 };
 
Index: clang/lib/CodeGen/ABIInfo.h
===
--- clang/lib/CodeGen/ABIInfo.h
+++ clang/lib/CodeGen/ABIInfo.h
@@ -117,6 +117,9 @@
   CodeGenTypes 
   bool SwiftErrorInRegister;
 
+  bool occupiesMoreThan(ArrayRef scalarTypes,
+unsigned maxAllRegisters) const;
+
 public:
   SwiftABIInfo(CodeGen::CodeGenTypes , bool SwiftErrorInRegister)
   : CGT(CGT), SwiftErrorInRegister(SwiftErrorInRegister) {}


Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -125,7 +125,7 @@
 /// registers when expanded?
 ///
 /// This is intended to be the basis of a reasonable basic implementation
-/// of should{Pass,Return}IndirectlyForSwift.
+/// of should{Pass,Return}Indirectly.
 ///
 /// For most targets, a limit of four total registers is reasonable; this
 /// limits the amount of code required in order to move around the value
@@ -134,15 +134,14 @@
 /// immediately within the callee.  But some targets may need to further
 /// limit the register count due to an inability to support that many
 /// return registers.
-static bool occupiesMoreThan(CodeGenTypes ,
- ArrayRef scalarTypes,
- unsigned maxAllRegisters) {
+bool SwiftABIInfo::occupiesMoreThan(ArrayRef scalarTypes,
+unsigned maxAllRegisters) const {
   unsigned intCount = 0, fpCount = 0;
   for (llvm::Type *type : scalarTypes) {
 if (type->isPointerTy()) {
   intCount++;
 } else if (auto intTy = dyn_cast(type)) {
-  auto ptrWidth = cgt.getTarget().getPointerWidth(LangAS::Default);
+  auto ptrWidth = CGT.getTarget().getPointerWidth(LangAS::Default);
   intCount += (intTy->getBitWidth() + ptrWidth - 1) / ptrWidth;
 } else {
   assert(type->isVectorTy() || type->isFloatingPointTy());
@@ -155,7 +154,7 @@
 
 bool SwiftABIInfo::shouldPassIndirectly(ArrayRef ComponentTys,
 bool AsReturnValue) const {
-  return occupiesMoreThan(CGT, ComponentTys, /*total=*/4);
+  return occupiesMoreThan(ComponentTys, /*total=*/4);
 }
 
 bool SwiftABIInfo::isLegalVectorType(CharUnits VectorSize, llvm::Type *EltTy,
@@ -1248,7 +1247,7 @@
 // integer registers and three fp registers.  Oddly, it'll use up to
 // four vector registers for vectors, but those can overlap with the
 

[PATCH] D148785: -fsanitize=function: use type hashes instead of RTTI objects

2023-05-17 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay marked 2 inline comments as done.
MaskRay added inline comments.



Comment at: clang/test/CodeGenCXX/catch-undef-behavior.cpp:408
 
   // RTTI pointer check
+  // CHECK: [[CalleeTypeHashPtr:%.+]] = getelementptr <{ i32, i32 }>, <{ i32, 
i32 }>* [[PTR]], i32 -1, i32 1

peter.smith wrote:
> CalleeTypeHash check?
`CalleeTypeHashPtr` seems clear. Do you mean to change `HashCmp` below to 
`CalleeTypeHashMatch`?




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148785

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


[clang] 7971d91 - [clang][CodeGen] Reformat ABIInfo.h (NFC)

2023-05-17 Thread Sergei Barannikov via cfe-commits

Author: Sergei Barannikov
Date: 2023-05-18T04:29:16+03:00
New Revision: 7971d91bbf903b894936e663e67e03ffc0c29004

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

LOG: [clang][CodeGen] Reformat ABIInfo.h (NFC)

Preparatory change for D148094.

Added: 


Modified: 
clang/lib/CodeGen/ABIInfo.h

Removed: 




diff  --git a/clang/lib/CodeGen/ABIInfo.h b/clang/lib/CodeGen/ABIInfo.h
index 1dffa41c57c5..5ce9eab7fc87 100644
--- a/clang/lib/CodeGen/ABIInfo.h
+++ b/clang/lib/CodeGen/ABIInfo.h
@@ -15,131 +15,128 @@
 #include "llvm/IR/Type.h"
 
 namespace llvm {
-  class Value;
-  class LLVMContext;
-  class DataLayout;
-  class Type;
-}
+class Value;
+class LLVMContext;
+class DataLayout;
+class Type;
+} // namespace llvm
 
 namespace clang {
-  class ASTContext;
-  class CodeGenOptions;
-  class TargetInfo;
+class ASTContext;
+class CodeGenOptions;
+class TargetInfo;
 
 namespace CodeGen {
-  class ABIArgInfo;
-  class Address;
-  class CGCXXABI;
-  class CGFunctionInfo;
-  class CodeGenFunction;
-  class CodeGenTypes;
-
-  // FIXME: All of this stuff should be part of the target interface
-  // somehow. It is currently here because it is not clear how to factor
-  // the targets to support this, since the Targets currently live in a
-  // layer below types n'stuff.
-
-
-  /// ABIInfo - Target specific hooks for defining how a type should be
-  /// passed or returned from functions.
-  class ABIInfo {
-  protected:
-CodeGen::CodeGenTypes 
-llvm::CallingConv::ID RuntimeCC;
-  public:
-ABIInfo(CodeGen::CodeGenTypes )
-: CGT(cgt), RuntimeCC(llvm::CallingConv::C) {}
-
-virtual ~ABIInfo();
-
-virtual bool allowBFloatArgsAndRet() const { return false; }
-
-CodeGen::CGCXXABI () const;
-ASTContext () const;
-llvm::LLVMContext () const;
-const llvm::DataLayout () const;
-const TargetInfo () const;
-const CodeGenOptions () const;
-
-/// Return the calling convention to use for system runtime
-/// functions.
-llvm::CallingConv::ID getRuntimeCC() const {
-  return RuntimeCC;
-}
-
-virtual void computeInfo(CodeGen::CGFunctionInfo ) const = 0;
-
-/// EmitVAArg - Emit the target dependent code to load a value of
-/// \arg Ty from the va_list pointed to by \arg VAListAddr.
-
-// FIXME: This is a gaping layering violation if we wanted to drop
-// the ABI information any lower than CodeGen. Of course, for
-// VAArg handling it has to be at this level; there is no way to
-// abstract this out.
-virtual CodeGen::Address EmitVAArg(CodeGen::CodeGenFunction ,
+class ABIArgInfo;
+class Address;
+class CGCXXABI;
+class CGFunctionInfo;
+class CodeGenFunction;
+class CodeGenTypes;
+
+// FIXME: All of this stuff should be part of the target interface
+// somehow. It is currently here because it is not clear how to factor
+// the targets to support this, since the Targets currently live in a
+// layer below types n'stuff.
+
+/// ABIInfo - Target specific hooks for defining how a type should be
+/// passed or returned from functions.
+class ABIInfo {
+protected:
+  CodeGen::CodeGenTypes 
+  llvm::CallingConv::ID RuntimeCC;
+
+public:
+  ABIInfo(CodeGen::CodeGenTypes )
+  : CGT(cgt), RuntimeCC(llvm::CallingConv::C) {}
+
+  virtual ~ABIInfo();
+
+  virtual bool allowBFloatArgsAndRet() const { return false; }
+
+  CodeGen::CGCXXABI () const;
+  ASTContext () const;
+  llvm::LLVMContext () const;
+  const llvm::DataLayout () const;
+  const TargetInfo () const;
+  const CodeGenOptions () const;
+
+  /// Return the calling convention to use for system runtime
+  /// functions.
+  llvm::CallingConv::ID getRuntimeCC() const { return RuntimeCC; }
+
+  virtual void computeInfo(CodeGen::CGFunctionInfo ) const = 0;
+
+  /// EmitVAArg - Emit the target dependent code to load a value of
+  /// \arg Ty from the va_list pointed to by \arg VAListAddr.
+
+  // FIXME: This is a gaping layering violation if we wanted to drop
+  // the ABI information any lower than CodeGen. Of course, for
+  // VAArg handling it has to be at this level; there is no way to
+  // abstract this out.
+  virtual CodeGen::Address EmitVAArg(CodeGen::CodeGenFunction ,
+ CodeGen::Address VAListAddr,
+ QualType Ty) const = 0;
+
+  bool isAndroid() const;
+  bool isOHOSFamily() const;
+
+  /// Emit the target dependent code to load a value of
+  /// \arg Ty from the \c __builtin_ms_va_list pointed to by \arg VAListAddr.
+  virtual CodeGen::Address EmitMSVAArg(CodeGen::CodeGenFunction ,
CodeGen::Address VAListAddr,
-   QualType Ty) const = 0;
-
-bool isAndroid() const;
-bool isOHOSFamily() const;
-
-

[PATCH] D148785: -fsanitize=function: use type hashes instead of RTTI objects

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



Comment at: llvm/test/CodeGen/AArch64/patchable-function-entry-bti.ll:92
 ; CHECK-NEXT: .Ltmp{{.*}}:
 ; CHECK-NEXT:   nop
 ; CHECK-NEXT:   .word   3238382334  // 0xc105cafe

peter.smith wrote:
> samitolvanen wrote:
> > peter.smith wrote:
> > > Assuming the test is the equivalent of `-fpatchable-function-entry=1,1` I 
> > > think this is the wrong place for the nop, I think it needs to be after 
> > > the signature and the loads adjusted. For example with -fsanitize=kcfi 
> > > -fpatchable-function-entries=1,1
> > > ```
> > > typedef int Fptr(void);
> > > 
> > > int function(void) {
> > >   return 0;
> > > }
> > > 
> > > int call(Fptr* fp) {
> > >   return fp();
> > > }
> > > ```
> > > Results in code like:
> > > ```
> > > .word   1670944012  // @call
> > > // 0x6398950c
> > > .Ltmp1:
> > > nop
> > > call:
> > > .Lfunc_begin1:
> > > .cfi_startproc
> > > // %bb.0:   // %entry
> > > ldurw16, [x0, #-8]
> > > movkw17, #50598
> > > movkw17, #14001, lsl #16
> > > cmp w16, w17
> > > b.eq.Ltmp2
> > > brk #0x8220
> > > .Ltmp2:
> > > br  x0
> > > .Lfunc_end1:
> > > ```
> > > Note the NOP is after the signature, with the `ldur` having an offset of 
> > > -8 and not the usual -4. I think you would need to make sure the 
> > > signature is a branch instruction for each target for this scheme to work.
> > No, this looks correct to me. Note that in AsmPrinter the type hash is 
> > emitted after the patchable-function-prefix nops, while the KCFI type hash 
> > is emitted before them.
> My concern is more along the lines of how would this function be patched if 
> the code doing the patching were unaware of the signature. I'm not familiar 
> with how the kernel uses the nops so it could be that this is won't be a 
> problem in practice.
> 
> With -fsanitize=kcfi it looks like there is no difference to the code doing 
> the patching as the nops are in the same place with respect to the function 
> entry point and there is no fall through into the signature.
> 
> With -fsanitize=function anything patching the first nop as an instruction 
> would need to branch over the signature (unless the first entry of the 
> signature was a branch instruction, but that would mean a target specific 
> signature), obviously if the nop is patched with data and isn't the entry 
> point then this doesn't matter. The code doing the patching would also need 
> to know how to locate the nop ahead of the signature.
The responsibility is on the user side to ensure that when M>0, they code 
patches one of the M NOPs to a branch over the signature (0xc105cafe). 

```
// -fsanitize=function -fpatchable-function-entry=3,3
.Ltmp0:
nop
nop
nop# ensure there is a branch over the signature
.long   3238382334  # 0xc105cafe
.long   2772461324  # 0xa540670c
foo:
```

In addition, `-fpatchable-function-entry=N,M` where M>0 is uncommon. 
`-fpatchable-function-entry=` didn't work with `-fsanitize=function` before my 
changes.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148785

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


[PATCH] D143967: [DebugInfo][BPF] Add 'btf:type_tag' annotation in DWARF

2023-05-17 Thread Eduard Zingerman via Phabricator via cfe-commits
eddyz87 updated this revision to Diff 523233.
eddyz87 added a comment.

Fix for case when CVR qualifier is behind type ignored by 
UnwrapTypeForDebugInfo().
E.g. for the following example:

  const int *foo;
  typeof(*foo) __attribute__((btf_type_tag("tag"))) buz;


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143967

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/test/CodeGen/attr-btf_type_tag-circular.c
  clang/test/CodeGen/attr-btf_type_tag-const.c
  clang/test/CodeGen/attr-btf_type_tag-func-ptr.c
  clang/test/CodeGen/attr-btf_type_tag-func.c
  clang/test/CodeGen/attr-btf_type_tag-restrict.c
  clang/test/CodeGen/attr-btf_type_tag-similar-type.c
  clang/test/CodeGen/attr-btf_type_tag-typedef-field.c
  clang/test/CodeGen/attr-btf_type_tag-var.c
  clang/test/CodeGen/attr-btf_type_tag-void.c
  clang/test/CodeGen/attr-btf_type_tag-volatile.c
  llvm/include/llvm/IR/DIBuilder.h
  llvm/lib/IR/DIBuilder.cpp

Index: llvm/lib/IR/DIBuilder.cpp
===
--- llvm/lib/IR/DIBuilder.cpp
+++ llvm/lib/IR/DIBuilder.cpp
@@ -352,6 +352,17 @@
 Annotations);
 }
 
+DIDerivedType *
+DIBuilder::createAnnotationsPlaceholder(DIType *Ty, DINodeArray Annotations) {
+  auto *RetTy =
+  DIDerivedType::getTemporary(
+  VMContext, dwarf::DW_TAG_LLVM_annotation, "", nullptr, 0, nullptr, Ty,
+  0, 0, 0, std::nullopt, DINode::FlagZero, nullptr, Annotations)
+  .release();
+  trackIfUnresolved(RetTy);
+  return RetTy;
+}
+
 DIDerivedType *DIBuilder::createFriend(DIType *Ty, DIType *FriendTy) {
   assert(Ty && "Invalid type!");
   assert(FriendTy && "Invalid friend type!");
Index: llvm/include/llvm/IR/DIBuilder.h
===
--- llvm/include/llvm/IR/DIBuilder.h
+++ llvm/include/llvm/IR/DIBuilder.h
@@ -284,6 +284,9 @@
  DINode::DIFlags Flags = DINode::FlagZero,
  DINodeArray Annotations = nullptr);
 
+DIDerivedType *createAnnotationsPlaceholder(DIType *Ty,
+DINodeArray Annotations);
+
 /// Create debugging information entry for a 'friend'.
 DIDerivedType *createFriend(DIType *Ty, DIType *FriendTy);
 
Index: clang/test/CodeGen/attr-btf_type_tag-volatile.c
===
--- /dev/null
+++ clang/test/CodeGen/attr-btf_type_tag-volatile.c
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 \
+// RUN:   -triple %itanium_abi_triple -debug-info-kind=limited \
+// RUN:   -S -emit-llvm -o - %s | FileCheck %s
+
+// See attr-btf_type_tag-const.c for reasoning behind this test.
+// Alternatively, see the following method:
+//   CGDebugInfo::CreateType(const BTFTagAttributedType, llvm::DIFile)
+
+#define __tag1 __attribute__((btf_type_tag("tag1")))
+
+volatile int foo;
+typeof(foo) __tag1 bar;
+
+// CHECK: ![[#]] = distinct !DIGlobalVariable(name: "bar", {{.*}}, type: ![[L1:[0-9]+]], {{.*}})
+// CHECK: ![[L1]] = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: ![[L2:[0-9]+]])
+// CHECK: ![[L2]] = !DIBasicType(name: "int", size: [[#]], {{.*}}, annotations: ![[L3:[0-9]+]])
+// CHECK: ![[L3]] = !{![[L4:[0-9]+]]}
+// CHECK: ![[L4]] = !{!"btf:type_tag", !"tag1"}
Index: clang/test/CodeGen/attr-btf_type_tag-void.c
===
--- /dev/null
+++ clang/test/CodeGen/attr-btf_type_tag-void.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -debug-info-kind=limited -S -emit-llvm -o - %s | FileCheck %s
+
+#define __tag1 __attribute__((btf_type_tag("tag1")))
+void __tag1 *g;
+
+// CHECK: distinct !DIGlobalVariable(name: "g", scope: ![[#]], file: ![[#]], line: [[#]], type: ![[L1:[0-9]+]], isLocal: false, isDefinition: true)
+// CHECK: ![[L1]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[L2:[0-9]+]], size: [[#]], annotations: ![[L3:[0-9]+]])
+// CHECK: ![[L2]] = !DIBasicType(tag: DW_TAG_unspecified_type, name: "void", annotations: ![[L4:[0-9]+]])
+// CHECK: ![[L4]] = !{![[L5:[0-9]+]]}
+// CHECK: ![[L5]] = !{!"btf:type_tag", !"tag1"}
+// CHECK: ![[L3]] = !{![[L6:[0-9]+]]}
+// CHECK: ![[L6]] = !{!"btf_type_tag", !"tag1"}
Index: clang/test/CodeGen/attr-btf_type_tag-var.c
===
--- clang/test/CodeGen/attr-btf_type_tag-var.c
+++ clang/test/CodeGen/attr-btf_type_tag-var.c
@@ -21,23 +21,30 @@
 const int __tag1 __tag2 volatile * const __tag3  __tag4  volatile * __tag5  __tag6 const volatile * g;
 #endif
 
-// CHECK:  distinct !DIGlobalVariable(name: "g", scope: ![[#]], file: ![[#]], line: [[#]], type: ![[L6:[0-9]+]]
-// CHECK:  ![[L6]] = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: ![[L7:[0-9]+]], size: [[#]], annotations: ![[L22:[0-9]+]]
-// CHECK:  ![[L7]] = !DIDerivedType(tag: 

[PATCH] D148094: [clang][CodeGen] Break up TargetInfo.cpp [8/8]

2023-05-17 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 updated this revision to Diff 523232.
barannikov88 added a comment.

Update BUILD.gn


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148094

Files:
  clang/docs/UsersManual.rst
  clang/docs/tools/clang-formatted-files.txt
  clang/lib/CodeGen/ABIInfo.cpp
  clang/lib/CodeGen/ABIInfo.h
  clang/lib/CodeGen/ABIInfoImpl.cpp
  clang/lib/CodeGen/ABIInfoImpl.h
  clang/lib/CodeGen/CMakeLists.txt
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/Targets/AArch64.cpp
  clang/lib/CodeGen/Targets/AMDGPU.cpp
  clang/lib/CodeGen/Targets/ARC.cpp
  clang/lib/CodeGen/Targets/ARM.cpp
  clang/lib/CodeGen/Targets/AVR.cpp
  clang/lib/CodeGen/Targets/BPF.cpp
  clang/lib/CodeGen/Targets/CSKY.cpp
  clang/lib/CodeGen/Targets/Hexagon.cpp
  clang/lib/CodeGen/Targets/Lanai.cpp
  clang/lib/CodeGen/Targets/LoongArch.cpp
  clang/lib/CodeGen/Targets/M68k.cpp
  clang/lib/CodeGen/Targets/MSP430.cpp
  clang/lib/CodeGen/Targets/Mips.cpp
  clang/lib/CodeGen/Targets/NVPTX.cpp
  clang/lib/CodeGen/Targets/PNaCl.cpp
  clang/lib/CodeGen/Targets/PPC.cpp
  clang/lib/CodeGen/Targets/RISCV.cpp
  clang/lib/CodeGen/Targets/SPIR.cpp
  clang/lib/CodeGen/Targets/Sparc.cpp
  clang/lib/CodeGen/Targets/SystemZ.cpp
  clang/lib/CodeGen/Targets/TCE.cpp
  clang/lib/CodeGen/Targets/VE.cpp
  clang/lib/CodeGen/Targets/WebAssembly.cpp
  clang/lib/CodeGen/Targets/X86.cpp
  clang/lib/CodeGen/Targets/XCore.cpp
  clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp
  llvm/utils/gn/secondary/clang/lib/CodeGen/BUILD.gn

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


[PATCH] D150221: Add option -fkeep-static-variables to emit all static variables

2023-05-17 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

In D150221#4351249 , @rjmccall wrote:

> Force-emitting every `static` in the translation unit can be very expensive; 
> there are a lot of headers that declare all their constants as `static 
> const`.  And removing dead globals is a pretty important optimization, e.g. 
> to eliminate the string literals used by assertions that the compiler was 
> able to fold to `true`.  So I don't think it's unreasonable for us to ask 
> whether we should just be naively adding this option instead of figuring out 
> a more targeted way of satisfying these users.

Seeing as there are application developers paying the cost of--and relying on 
at least some aspects of--this behaviour, I am looking to see how they can move 
to Clang with less migration overhead. It seems to me that more targeted ways 
to solve the issue would require that the application developers apply a 
mechanism to select variables for this treatment. That involves a trade-off for 
them between performance and uptime-friendly serviceability. If they don't have 
an analysis to make those decisions, then having a more complicated tunable 
interface does not help them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150221

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


[PATCH] D148094: [clang][CodeGen] Break up TargetInfo.cpp [8/8]

2023-05-17 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 updated this revision to Diff 523230.
barannikov88 added a comment.

Add a virtual destructor to DefaultABIInfo to pin the vtable to a cpp file


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148094

Files:
  clang/docs/UsersManual.rst
  clang/docs/tools/clang-formatted-files.txt
  clang/lib/CodeGen/ABIInfo.cpp
  clang/lib/CodeGen/ABIInfo.h
  clang/lib/CodeGen/ABIInfoImpl.cpp
  clang/lib/CodeGen/ABIInfoImpl.h
  clang/lib/CodeGen/CMakeLists.txt
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/Targets/AArch64.cpp
  clang/lib/CodeGen/Targets/AMDGPU.cpp
  clang/lib/CodeGen/Targets/ARC.cpp
  clang/lib/CodeGen/Targets/ARM.cpp
  clang/lib/CodeGen/Targets/AVR.cpp
  clang/lib/CodeGen/Targets/BPF.cpp
  clang/lib/CodeGen/Targets/CSKY.cpp
  clang/lib/CodeGen/Targets/Hexagon.cpp
  clang/lib/CodeGen/Targets/Lanai.cpp
  clang/lib/CodeGen/Targets/LoongArch.cpp
  clang/lib/CodeGen/Targets/M68k.cpp
  clang/lib/CodeGen/Targets/MSP430.cpp
  clang/lib/CodeGen/Targets/Mips.cpp
  clang/lib/CodeGen/Targets/NVPTX.cpp
  clang/lib/CodeGen/Targets/PNaCl.cpp
  clang/lib/CodeGen/Targets/PPC.cpp
  clang/lib/CodeGen/Targets/RISCV.cpp
  clang/lib/CodeGen/Targets/SPIR.cpp
  clang/lib/CodeGen/Targets/Sparc.cpp
  clang/lib/CodeGen/Targets/SystemZ.cpp
  clang/lib/CodeGen/Targets/TCE.cpp
  clang/lib/CodeGen/Targets/VE.cpp
  clang/lib/CodeGen/Targets/WebAssembly.cpp
  clang/lib/CodeGen/Targets/X86.cpp
  clang/lib/CodeGen/Targets/XCore.cpp
  clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp
  llvm/utils/gn/secondary/clang/lib/CodeGen/BUILD.gn

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


[PATCH] D150549: Move SubtargetFeature.h from MC to TargetParser

2023-05-17 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.

In D150549#4349531 , @jobnoorman 
wrote:

> In D150549#4347056 , @MaskRay wrote:
>
>> This seems fine, but please consider making `MC/SubtargetFeature.h` a 
>> forwarding header temporarily.
>
> To be clear: do you want me to check-in this forwarding header or should I 
> just do it locally for the tests below? If the former, what exactly is the 
> purpose of adding this header?

The motivation is similar to https://reviews.llvm.org/D137838#3921828

> That way, you don't have to update oodles of include lines in this patch, and 
> it makes it a bit easier to see what's going on. (You can then update all the 
> include lines in a trivial follow-up if this change goes through, and then 
> remove the forwarding headers in Support, to cut the dependency you want to 
> remove.)

(There is a non-zero probability that the patch may miss something and get 
reverted. By creating a forwarding header we don't risk causing too much churn 
to the many files.)
For a large-scaling refactoring

>> Our official build system CMake doesn't do layering checking for headers 
>> (https://llvm.org/docs/CodingStandards.html#library-layering).
>>
>> Our unofficial build system Bazel supports layering checking 
>> . You may edit 
>> `utils/bazel/llvm-project-overlay/llvm/BUILD.bazel` and see whether bazel 
>> reports a circular dependency. I think this patch is fine, but just in case.
>
> I did the following:
>
> - Add the forwarding header
> - Update `BUILD.bazel` (I only had to add the `TargetParser` dependency to 
> `llvm-tblgen` to make this work; should I add this change to this patch?)
> - Run `bazel build '@llvm-project//llvm:all'` (using `clang` from `main`).
>
> This worked fine. Is this what you meant with the circular dependency check? 
> (I'm not familiar with bazel so I might be missing something.)

Thank you for verification. Then I think this is good. `layering_check` is the 
default, so this verifies that we are good.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150549

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


[PATCH] D150833: [WebAssembly] Add wasm_simd128.h intrinsics for relaxed SIMD

2023-05-17 Thread Thomas Lively via Phabricator via cfe-commits
tlively created this revision.
tlively added reviewers: aheejin, dschuff.
Herald added subscribers: pmatos, asb, wingo, ecnelises, sunfish, 
jgravelle-google, sbc100.
Herald added a project: All.
tlively requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Add user-friendly intrinsic functions for all relaxed SIMD instructions
alongside the existing SIMD128 intrinsic functions in wasm_simd128.h. Test that
the new instrinsics lower to the expected instructions in the existing
cross-project-tests test file.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150833

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/Headers/wasm_simd128.h
  cross-project-tests/intrinsic-header-tests/wasm_simd128.c

Index: cross-project-tests/intrinsic-header-tests/wasm_simd128.c
===
--- cross-project-tests/intrinsic-header-tests/wasm_simd128.c
+++ cross-project-tests/intrinsic-header-tests/wasm_simd128.c
@@ -1,7 +1,8 @@
 // REQUIRES: webassembly-registered-target
 // expected-no-diagnostics
 
-// RUN: %clang %s -O2 -S -o - -target wasm32-unknown-unknown -msimd128 -Wcast-qual -Werror | FileCheck %s
+// RUN: %clang %s -O2 -S -o - -target wasm32-unknown-unknown \
+// RUN: -msimd128 -mrelaxed-simd -Wcast-qual -Werror | FileCheck %s
 
 #include 
 
@@ -1264,3 +1265,123 @@
 v128_t test_i16x8_q15mulr_sat(v128_t a, v128_t b) {
   return wasm_i16x8_q15mulr_sat(a, b);
 }
+
+// CHECK-LABEL: test_f32x4_relaxed_madd:
+// CHECK: f32x4.relaxed_madd{{$}}
+v128_t test_f32x4_relaxed_madd(v128_t a, v128_t b, v128_t c) {
+  return wasm_f32x4_relaxed_madd(a, b, c);
+}
+
+// CHECK-LABEL: test_f32x4_relaxed_nmadd:
+// CHECK: f32x4.relaxed_nmadd{{$}}
+v128_t test_f32x4_relaxed_nmadd(v128_t a, v128_t b, v128_t c) {
+  return wasm_f32x4_relaxed_nmadd(a, b, c);
+}
+
+// CHECK-LABEL: test_f64x2_relaxed_madd:
+// CHECK: f64x2.relaxed_madd{{$}}
+v128_t test_f64x2_relaxed_madd(v128_t a, v128_t b, v128_t c) {
+  return wasm_f64x2_relaxed_madd(a, b, c);
+}
+
+// CHECK-LABEL: test_f64x2_relaxed_nmadd:
+// CHECK: f64x2.relaxed_nmadd{{$}}
+v128_t test_f64x2_relaxed_nmadd(v128_t a, v128_t b, v128_t c) {
+  return wasm_f64x2_relaxed_nmadd(a, b, c);
+}
+
+// CHECK-LABEL: test_i8x16_relaxed_laneselect:
+// CHECK: i8x16.relaxed_laneselect{{$}}
+v128_t test_i8x16_relaxed_laneselect(v128_t a, v128_t b, v128_t m) {
+  return wasm_i8x16_relaxed_laneselect(a, b, m);
+}
+
+// CHECK-LABEL: test_i16x8_relaxed_laneselect:
+// CHECK: i16x8.relaxed_laneselect{{$}}
+v128_t test_i16x8_relaxed_laneselect(v128_t a, v128_t b, v128_t m) {
+  return wasm_i16x8_relaxed_laneselect(a, b, m);
+}
+
+// CHECK-LABEL: test_i32x4_relaxed_laneselect:
+// CHECK: i32x4.relaxed_laneselect{{$}}
+v128_t test_i32x4_relaxed_laneselect(v128_t a, v128_t b, v128_t m) {
+  return wasm_i32x4_relaxed_laneselect(a, b, m);
+}
+
+// CHECK-LABEL: test_i64x2_relaxed_laneselect:
+// CHECK: i64x2.relaxed_laneselect{{$}}
+v128_t test_i64x2_relaxed_laneselect(v128_t a, v128_t b, v128_t m) {
+  return wasm_i64x2_relaxed_laneselect(a, b, m);
+}
+
+// CHECK-LABEL: test_i8x16_relaxed_swizzle:
+// CHECK: i8x16.relaxed_swizzle{{$}}
+v128_t test_i8x16_relaxed_swizzle(v128_t a, v128_t s) {
+  return wasm_i8x16_relaxed_swizzle(a, s);
+}
+
+// CHECK-LABEL: test_f32x4_relaxed_min:
+// CHECK: f32x4.relaxed_min{{$}}
+v128_t test_f32x4_relaxed_min(v128_t a, v128_t b) {
+  return wasm_f32x4_relaxed_min(a, b);
+}
+
+// CHECK-LABEL: test_f32x4_relaxed_max:
+// CHECK: f32x4.relaxed_max{{$}}
+v128_t test_f32x4_relaxed_max(v128_t a, v128_t b) {
+  return wasm_f32x4_relaxed_max(a, b);
+}
+
+// CHECK-LABEL: test_f64x2_relaxed_min:
+// CHECK: f64x2.relaxed_min{{$}}
+v128_t test_f64x2_relaxed_min(v128_t a, v128_t b) {
+  return wasm_f64x2_relaxed_min(a, b);
+}
+
+// CHECK-LABEL: test_f64x2_relaxed_max:
+// CHECK: f64x2.relaxed_max
+v128_t test_f64x2_relaxed_max(v128_t a, v128_t b) {
+  return wasm_f64x2_relaxed_max(a, b);
+}
+
+// CHECK-LABEL: test_i32x4_relaxed_trunc_f32x4:
+// CHECK: i32x4.relaxed_trunc_f32x4_s{{$}}
+v128_t test_i32x4_relaxed_trunc_f32x4(v128_t a) {
+  return wasm_i32x4_relaxed_trunc_f32x4(a);
+}
+
+// CHECK-LABEL: test_u32x4_relaxed_trunc_f32x4:
+// CHECK: i32x4.relaxed_trunc_f32x4_u{{$}}
+v128_t test_u32x4_relaxed_trunc_f32x4(v128_t a) {
+  return wasm_u32x4_relaxed_trunc_f32x4(a);
+}
+
+// CHECK-LABEL: test_i32x4_relaxed_trunc_f64x2_zero:
+// CHECK: i32x4.relaxed_trunc_f64x2_s_zero{{$}}
+v128_t test_i32x4_relaxed_trunc_f64x2_zero(v128_t a) {
+  return wasm_i32x4_relaxed_trunc_f64x2_zero(a);
+}
+
+// CHECK-LABEL: test_u32x4_relaxed_trunc_f64x2_zero:
+// CHECK: i32x4.relaxed_trunc_f64x2_u_zero{{$}}
+v128_t test_u32x4_relaxed_trunc_f64x2_zero(v128_t a) {
+  return wasm_u32x4_relaxed_trunc_f64x2_zero(a);
+}
+
+// CHECK-LABEL: test_i16x8_relaxed_q15mulr:
+// CHECK: i16x8.relaxed_q15mulr_s{{$}}
+v128_t test_i16x8_relaxed_q15mulr(v128_t a, v128_t b) {
+  return 

[PATCH] D148094: [clang][CodeGen] Break up TargetInfo.cpp [8/8]

2023-05-17 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 updated this revision to Diff 523227.
barannikov88 added a comment.

Move complexTempStructure to its only user (PPC.cpp)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148094

Files:
  clang/docs/UsersManual.rst
  clang/docs/tools/clang-formatted-files.txt
  clang/lib/CodeGen/ABIInfo.cpp
  clang/lib/CodeGen/ABIInfo.h
  clang/lib/CodeGen/ABIInfoImpl.cpp
  clang/lib/CodeGen/ABIInfoImpl.h
  clang/lib/CodeGen/CMakeLists.txt
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/Targets/AArch64.cpp
  clang/lib/CodeGen/Targets/AMDGPU.cpp
  clang/lib/CodeGen/Targets/ARC.cpp
  clang/lib/CodeGen/Targets/ARM.cpp
  clang/lib/CodeGen/Targets/AVR.cpp
  clang/lib/CodeGen/Targets/BPF.cpp
  clang/lib/CodeGen/Targets/CSKY.cpp
  clang/lib/CodeGen/Targets/Hexagon.cpp
  clang/lib/CodeGen/Targets/Lanai.cpp
  clang/lib/CodeGen/Targets/LoongArch.cpp
  clang/lib/CodeGen/Targets/M68k.cpp
  clang/lib/CodeGen/Targets/MSP430.cpp
  clang/lib/CodeGen/Targets/Mips.cpp
  clang/lib/CodeGen/Targets/NVPTX.cpp
  clang/lib/CodeGen/Targets/PNaCl.cpp
  clang/lib/CodeGen/Targets/PPC.cpp
  clang/lib/CodeGen/Targets/RISCV.cpp
  clang/lib/CodeGen/Targets/SPIR.cpp
  clang/lib/CodeGen/Targets/Sparc.cpp
  clang/lib/CodeGen/Targets/SystemZ.cpp
  clang/lib/CodeGen/Targets/TCE.cpp
  clang/lib/CodeGen/Targets/VE.cpp
  clang/lib/CodeGen/Targets/WebAssembly.cpp
  clang/lib/CodeGen/Targets/X86.cpp
  clang/lib/CodeGen/Targets/XCore.cpp
  clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp
  llvm/utils/gn/secondary/clang/lib/CodeGen/BUILD.gn

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


[clang] 3948aed - [clang] NFC: Modernize Decl iteration via IdentifierResolver

2023-05-17 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2023-05-17T16:45:46-07:00
New Revision: 3948aedb7ab9a0626faccbe14624dbafeb2e3931

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

LOG: [clang] NFC: Modernize Decl iteration via IdentifierResolver

Added: 


Modified: 
clang/include/clang/Sema/IdentifierResolver.h
clang/lib/Sema/IdentifierResolver.cpp
clang/lib/Serialization/ASTWriter.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/IdentifierResolver.h 
b/clang/include/clang/Sema/IdentifierResolver.h
index 7c8dc46307d4f..1fbd6c48e5180 100644
--- a/clang/include/clang/Sema/IdentifierResolver.h
+++ b/clang/include/clang/Sema/IdentifierResolver.h
@@ -134,13 +134,14 @@ class IdentifierResolver {
   explicit IdentifierResolver(Preprocessor );
   ~IdentifierResolver();
 
-  /// begin - Returns an iterator for decls with the name 'Name'.
+  /// Returns a range of decls with the name 'Name'.
+  llvm::iterator_range decls(DeclarationName Name);
+
+  /// Returns an iterator over decls with the name 'Name'.
   iterator begin(DeclarationName Name);
 
-  /// end - Returns an iterator that has 'finished'.
-  iterator end() {
-return iterator();
-  }
+  /// Returns the end iterator.
+  iterator end() { return iterator(); }
 
   /// isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true
   /// if 'D' is in Scope 'S', otherwise 'S' is ignored and isDeclInScope 
returns

diff  --git a/clang/lib/Sema/IdentifierResolver.cpp 
b/clang/lib/Sema/IdentifierResolver.cpp
index 607dc3111e9d0..773cef65dcbdf 100644
--- a/clang/lib/Sema/IdentifierResolver.cpp
+++ b/clang/lib/Sema/IdentifierResolver.cpp
@@ -231,9 +231,12 @@ void IdentifierResolver::RemoveDecl(NamedDecl *D) {
   return toIdDeclInfo(Ptr)->RemoveDecl(D);
 }
 
-/// begin - Returns an iterator for decls with name 'Name'.
-IdentifierResolver::iterator
-IdentifierResolver::begin(DeclarationName Name) {
+llvm::iterator_range
+IdentifierResolver::decls(DeclarationName Name) {
+  return {begin(Name), end()};
+}
+
+IdentifierResolver::iterator IdentifierResolver::begin(DeclarationName Name) {
   if (IdentifierInfo *II = Name.getAsIdentifierInfo())
 readingIdentifier(*II);
 

diff  --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index 8816575ba60e7..749aaa4cd6e19 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -3558,12 +3558,8 @@ class ASTIdentifierTableTrait {
   if (MacroOffset)
 DataLen += 4; // MacroDirectives offset.
 
-  if (NeedDecls) {
-for (IdentifierResolver::iterator D = IdResolver.begin(II),
-   DEnd = IdResolver.end();
- D != DEnd; ++D)
-  DataLen += 4;
-  }
+  if (NeedDecls)
+DataLen += std::distance(IdResolver.begin(II), IdResolver.end()) * 4;
 }
 return emitULEBKeyDataLength(KeyLen, DataLen, Out);
   }
@@ -3608,8 +3604,7 @@ class ASTIdentifierTableTrait {
   // "stat"), but the ASTReader adds declarations to the end of the list
   // (so we need to see the struct "stat" before the function "stat").
   // Only emit declarations that aren't from a chained PCH, though.
-  SmallVector Decls(IdResolver.begin(II),
- IdResolver.end());
+  SmallVector Decls(IdResolver.decls(II));
   for (NamedDecl *D : llvm::reverse(Decls))
 LE.write(
 Writer.getDeclID(getDeclForLocalLookup(PP.getLangOpts(), D)));
@@ -4887,13 +4882,9 @@ ASTFileSignature ASTWriter::WriteASTCore(Sema , 
StringRef isysroot,
 }
 // Sort the identifiers to visit based on their name.
 llvm::sort(IIs, llvm::deref>());
-for (const IdentifierInfo *II : IIs) {
-  for (IdentifierResolver::iterator D = SemaRef.IdResolver.begin(II),
- DEnd = SemaRef.IdResolver.end();
-   D != DEnd; ++D) {
-GetDeclRef(*D);
-  }
-}
+for (const IdentifierInfo *II : IIs)
+  for (const Decl *D : SemaRef.IdResolver.decls(II))
+GetDeclRef(D);
   }
 
   // For method pool in the module, if it contains an entry for a selector,



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


[PATCH] D150689: [clang][DependencyScanner] Remove all warning flags when suppressing warnings

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

LGTM, thanks!




Comment at: clang/test/ClangScanDeps/optimize-system-warnings.m:19
+// CHECK:],
+// CHECK-NEXT:   "name": "A"
+// CHECK-NEXT: },

Bigcheese wrote:
> jansvoboda11 wrote:
> > I'd like to see a check line that would fail if the scanner reports another 
> > variant of module `A`. The `CHECK:` lines make it possible for FileCheck to 
> > skip an entire element in the modules array. (Structural matching on JSON 
> > in FileCheck would be a godsend.)
> The way FileCheck works I do not believe this can happen. A `CHECK:` line 
> finds the first line that matches, and `CHECK-NEXT:` follows exactly after 
> that. There's no case where we have a `CHECK:` that can skip over another 
> entire module entry.
You're right, this is good then.



Comment at: clang/test/ClangScanDeps/optimize-system-warnings.m:30
+// CHECK:],
+// CHECK-NEXT:   "name": "B"
+// CHECK-NEXT: }

Bigcheese wrote:
> jansvoboda11 wrote:
> > I'd expect the scanner to still produce two variants of module `B`, since 
> > it's a user module. Is that correct? If so, let's add explicit check for 
> > it, since we intentionally want to preserve the warning flags there.
> Both `A` and `B` are system modules. `A` is found via `-isystem`, and `B` has 
> the `[system]` attribute. The FileCheck lines will only succeed if there are 
> exactly two modules returned.
Thanks for pointing that out. Can you put a comment saying just that at the 
start of the test along with description of the expected behavior?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150689

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


[PATCH] D150829: [clang] Convert several tests to opaque pointers

2023-05-17 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added a comment.

These did require some intellectual work. I've noted changes that might be 
worth noticing.




Comment at: clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp:22
+// CHECK: store i32 0, ptr @arr
+// CHECK: call void @_ZN1AC1EPKc(ptr {{[^,]*}} getelementptr inbounds 
(%struct.S, ptr @arr, i32 0, i32 1), ptr noundef @.str)
+// CHECK: store i32 1, ptr getelementptr inbounds (%struct.S, ptr @arr, i64 1)

This looks suspicious to me. The first gep index has i32 type (used to be i64). 
The two other geps have it i64.




Comment at: clang/test/CodeGenCXX/address-space-cast-coerce.cpp:50
-// CHECK: %[[a:[^ ]+]] = addrspacecast i16 addrspace(5)* %{{[^ ]+}} to i16*
-// CHECK: %[[a:[^ ]+]] = addrspacecast %{{[^ ]+}} addrspace(5)* %{{[^ ]+}} to 
%{{[^ ]+}} 
 

There is only one addrspacecast in this function. The second one matches a line 
in the other function.
I believe this is not intended. [[ 
https://reviews.llvm.org/D53780?vs=172261=172671#toc | The review ]] was 
iterative, I think they just forgot to update the test.




Comment at: clang/test/CodeGenCXX/aix-alignment.cpp:22
+// AIX64: [[PTR:%.+]] = getelementptr inbounds i8, ptr %call, i64 -8
+// AIX:   %{{.+}} = load i{{[0-9]+}}, ptr [[PTR]]
 void bar() { delete[] allocBp(); }

Since bitcasts disappeared, added this load as an anchor.




Comment at: clang/test/CodeGenCXX/attr-musttail.cpp:60
 
-// CHECK: %call = musttail call noundef i32 %8(%class.Foo* noundef nonnull 
align 1 dereferenceable(1) %this.adjusted, i32 noundef %9)
+// CHECK: %call = musttail call noundef i32 %5(ptr noundef nonnull align 1 
dereferenceable(1) %1, i32 noundef %6)
 

This test relies on exact value numbering. I didn't try to go smart about it 
and just updated the numbers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150829

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


[PATCH] D150820: [NVPTX, CUDA] added optional src_size argument to __nvvm_cp_async*

2023-05-17 Thread Artem Belevich via Phabricator via cfe-commits
tra created this revision.
Herald added subscribers: mattd, gchakrabarti, asavonic, bixia, hiraditya.
Herald added a project: All.
tra updated this revision to Diff 523216.
tra added a comment.
tra retitled this revision from "[NVPTX] added src_size argument to 
__nvvm_cp_async* intrinsics." to "[NVPTX, CUDA] added optional src_size 
argument to __nvvm_cp_async*".
tra edited the summary of this revision.
Herald added a subscriber: yaxunl.
tra published this revision for review.
tra added reviewers: jlebar, nyalloc.
Herald added subscribers: llvm-commits, cfe-commits, jdoerfert, jholewinski.
Herald added projects: clang, LLVM.

Updated clang side.


The optional argument is needed for CUDA-11+ headers when we're compiling for  
sm_80+ GPUs.

For the intrinsics, the src_size argument is required now. Old calls w/o the 
src_size argument can be upgraded by using src_size=transfer size of the 
intrinsic.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150820

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-nvptx.c
  llvm/include/llvm/IR/IntrinsicsNVVM.td
  llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
  llvm/test/CodeGen/NVPTX/async-copy.ll

Index: llvm/test/CodeGen/NVPTX/async-copy.ll
===
--- llvm/test/CodeGen/NVPTX/async-copy.ll
+++ llvm/test/CodeGen/NVPTX/async-copy.ll
@@ -1,35 +1,35 @@
-; RUN: llc < %s -march=nvptx -mcpu=sm_80 -mattr=+ptx70 | FileCheck -check-prefixes=ALL,CHECK_PTX32 %s
-; RUN: llc < %s -march=nvptx64 -mcpu=sm_80 -mattr=+ptx70 | FileCheck -check-prefixes=ALL,CHECK_PTX64 %s
+; RUN: llc < %s -march=nvptx -mcpu=sm_80 -mattr=+ptx70 | FileCheck -check-prefixes=CHECK,CHECK_PTX32 %s
+; RUN: llc < %s -march=nvptx64 -mcpu=sm_80 -mattr=+ptx70 | FileCheck -check-prefixes=CHECK,CHECK_PTX64 %s
 ; RUN: %if ptxas-11.0 %{ llc < %s -march=nvptx -mcpu=sm_80 -mattr=+ptx70 | %ptxas-verify -arch=sm_80 %}
 ; RUN: %if ptxas-11.0 %{ llc < %s -march=nvptx64 -mcpu=sm_80 -mattr=+ptx70 | %ptxas-verify -arch=sm_80 %}
 
 declare void @llvm.nvvm.cp.async.wait.group(i32)
 
-; ALL-LABEL: asyncwaitgroup
+; CHECK-LABEL: asyncwaitgroup
 define void @asyncwaitgroup() {
-  ; ALL: cp.async.wait_group 8;
+  ; CHECK: cp.async.wait_group 8;
   tail call void @llvm.nvvm.cp.async.wait.group(i32 8)
-  ; ALL: cp.async.wait_group 0;
+  ; CHECK: cp.async.wait_group 0;
   tail call void @llvm.nvvm.cp.async.wait.group(i32 0)
-  ; ALL: cp.async.wait_group 16;
+  ; CHECK: cp.async.wait_group 16;
   tail call void @llvm.nvvm.cp.async.wait.group(i32 16)
   ret void
 }
 
 declare void @llvm.nvvm.cp.async.wait.all()
 
-; ALL-LABEL: asyncwaitall
+; CHECK-LABEL: asyncwaitall
 define void @asyncwaitall() {
-; ALL: cp.async.wait_all
+; CHECK: cp.async.wait_all
   tail call void @llvm.nvvm.cp.async.wait.all()
   ret void
 }
 
 declare void @llvm.nvvm.cp.async.commit.group()
 
-; ALL-LABEL: asynccommitgroup
+; CHECK-LABEL: asynccommitgroup
 define void @asynccommitgroup() {
-; ALL: cp.async.commit_group
+; CHECK: cp.async.commit_group
   tail call void @llvm.nvvm.cp.async.commit.group()
   ret void
 }
@@ -41,72 +41,75 @@
 
 ; CHECK-LABEL: asyncmbarrier
 define void @asyncmbarrier(ptr %a) {
-; CHECK_PTX32: cp.async.mbarrier.arrive.b64 [%r{{[0-9]+}}];
-; CHECK_PTX64: cp.async.mbarrier.arrive.b64 [%rd{{[0-9]+}}];
+; The distinction between PTX32/PTX64 here is only to capture pointer register type
+; in R to be used in subsequent tests.
+; CHECK_PTX32: cp.async.mbarrier.arrive.b64 [%[[R:r]]{{[0-9]+}}];
+; CHECK_PTX64: cp.async.mbarrier.arrive.b64 [%[[R:rd]]{{[0-9]+}}];
   tail call void @llvm.nvvm.cp.async.mbarrier.arrive(ptr %a)
   ret void
 }
 
 ; CHECK-LABEL: asyncmbarriershared
 define void @asyncmbarriershared(ptr addrspace(3) %a) {
-; CHECK_PTX32: cp.async.mbarrier.arrive.shared.b64 [%r{{[0-9]+}}];
-; CHECK_PTX64: cp.async.mbarrier.arrive.shared.b64 [%rd{{[0-9]+}}];
+; CHECK: cp.async.mbarrier.arrive.shared.b64 [%[[R]]{{[0-9]+}}];
   tail call void @llvm.nvvm.cp.async.mbarrier.arrive.shared(ptr addrspace(3) %a)
   ret void
 }
 
 ; CHECK-LABEL: asyncmbarriernoinc
 define void @asyncmbarriernoinc(ptr %a) {
-; CHECK_PTX32: cp.async.mbarrier.arrive.noinc.b64 [%r{{[0-9]+}}];
-; CHECK_PTX64: cp.async.mbarrier.arrive.noinc.b64 [%rd{{[0-9]+}}];
+; CHECK_PTX64: cp.async.mbarrier.arrive.noinc.b64 [%[[R]]{{[0-9]+}}];
   tail call void @llvm.nvvm.cp.async.mbarrier.arrive.noinc(ptr %a)
   ret void
 }
 
 ; CHECK-LABEL: asyncmbarriernoincshared
 define void @asyncmbarriernoincshared(ptr addrspace(3) %a) {
-; CHECK_PTX32: cp.async.mbarrier.arrive.noinc.shared.b64 [%r{{[0-9]+}}];
-; CHECK_PTX64: cp.async.mbarrier.arrive.noinc.shared.b64 [%rd{{[0-9]+}}];
+; CHECK: cp.async.mbarrier.arrive.noinc.shared.b64 [%[[R]]{{[0-9]+}}];
   tail call void @llvm.nvvm.cp.async.mbarrier.arrive.noinc.shared(ptr addrspace(3) %a)
   ret void
 }
 
-declare void 

[PATCH] D150394: [OpenMP 5.2] Deprecate MINUS (-) operator on reduction clauses

2023-05-17 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:10487-10488
   "a reduction list item with incomplete type %0">;
+def err_omp_reduction_minus_type : Error<
+  "a reduction list item with minus(-) operator is not supported">;
+def warn_omp_minus_in_reduction_deprecated : Warning<

mdfazlay wrote:
> ABataev wrote:
> > We already have message for unsupported reduction identifier. Better to 
> > modify switch in static bool actOnOMPReductionKindClause function and check 
> > if OpenMP > 52, set BOK to BO_Comma, if incoming OOK is OO_Minus. In this 
> > case it will be automatically diagnosed for OpenMP>52 as not allowed 
> > reduction identifier.
> BTW, I think we need to remove minus (-) from the incorrect reduction 
> identifier error message once OpenMP 6.0 becomes official. Please take a look 
> at the following output:
> 
> ```
> $ cat test.c
> void foo() {
>   int a = 0 ;
> #pragma omp parallel reduction(-:a)
>   ;
> }
> ```
> ```
> > clang -fopenmp -fopenmp-version=60 test.c -c
> test.c:3:32: error: incorrect reduction identifier, expected one of '+', '-', 
> '*', '&', '|', '^', '&&', '||', 'min' or 'max' or declare reduction for type 
> 'int'
> #pragma omp parallel reduction(-:a)
>^
> 1 error generated.
> ```
Yes, need to create versioned message:prior 6.0 and after 6.0.


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

https://reviews.llvm.org/D150394

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


[PATCH] D150829: [clang] Convert several tests to opaque pointers

2023-05-17 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 created this revision.
barannikov88 added a reviewer: nikic.
Herald added a subscriber: StephenFan.
Herald added a project: All.
barannikov88 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150829

Files:
  clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp
  clang/test/CodeGenCXX/address-space-cast-coerce.cpp
  clang/test/CodeGenCXX/address-space-cast.cpp
  clang/test/CodeGenCXX/aix-alignment.cpp
  clang/test/CodeGenCXX/alignment.cpp
  clang/test/CodeGenCXX/anonymous-union-member-initializer.cpp
  clang/test/CodeGenCXX/arm-swiftcall.cpp
  clang/test/CodeGenCXX/arm.cpp
  clang/test/CodeGenCXX/arm64.cpp
  clang/test/CodeGenCXX/armv7k.cpp
  clang/test/CodeGenCXX/assign-operator.cpp
  clang/test/CodeGenCXX/attr-musttail.cpp
  clang/test/CodeGenCXX/attr-target-clones.cpp

Index: clang/test/CodeGenCXX/attr-target-clones.cpp
===
--- clang/test/CodeGenCXX/attr-target-clones.cpp
+++ clang/test/CodeGenCXX/attr-target-clones.cpp
@@ -1,20 +1,20 @@
-// RUN: %clang_cc1 -no-opaque-pointers -std=c++11 -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix=LINUX
-// RUN: %clang_cc1 -no-opaque-pointers -std=c++11 -triple x86_64-windows-pc -emit-llvm %s -o - | FileCheck %s --check-prefix=WINDOWS
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix=LINUX
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-windows-pc -emit-llvm %s -o - | FileCheck %s --check-prefix=WINDOWS
 
 // Overloaded ifuncs
-// LINUX: @_Z10overloadedi.ifunc = weak_odr ifunc i32 (i32), i32 (i32)* ()* @_Z10overloadedi.resolver
-// LINUX: @_Z10overloadedPKc.ifunc = weak_odr ifunc i32 (i8*), i32 (i8*)* ()* @_Z10overloadedPKc.resolver
+// LINUX: @_Z10overloadedi.ifunc = weak_odr ifunc i32 (i32), ptr @_Z10overloadedi.resolver
+// LINUX: @_Z10overloadedPKc.ifunc = weak_odr ifunc i32 (ptr), ptr @_Z10overloadedPKc.resolver
 // struct 'C' ifuncs, note the 'float, U' one doesn't get one.
-// LINUX: @_ZN1CIssE3fooEv.ifunc = weak_odr ifunc i32 (%struct.C*), i32 (%struct.C*)* ()* @_ZN1CIssE3fooEv.resolver
-// LINUX: @_ZN1CIisE3fooEv.ifunc = weak_odr ifunc i32 (%struct.C.0*), i32 (%struct.C.0*)* ()* @_ZN1CIisE3fooEv.resolver
-// LINUX: @_ZN1CIdfE3fooEv.ifunc = weak_odr ifunc i32 (%struct.C.2*), i32 (%struct.C.2*)* ()* @_ZN1CIdfE3fooEv.resolver
+// LINUX: @_ZN1CIssE3fooEv.ifunc = weak_odr ifunc i32 (ptr), ptr @_ZN1CIssE3fooEv.resolver
+// LINUX: @_ZN1CIisE3fooEv.ifunc = weak_odr ifunc i32 (ptr), ptr @_ZN1CIisE3fooEv.resolver
+// LINUX: @_ZN1CIdfE3fooEv.ifunc = weak_odr ifunc i32 (ptr), ptr @_ZN1CIdfE3fooEv.resolver
 
 int __attribute__((target_clones("sse4.2", "default"))) overloaded(int) { return 1; }
 // LINUX: define {{.*}}i32 @_Z10overloadedi.sse4.2.0(i32{{.+}})
 // LINUX: define {{.*}}i32 @_Z10overloadedi.default.1(i32{{.+}})
-// LINUX: define weak_odr i32 (i32)* @_Z10overloadedi.resolver() comdat
-// LINUX: ret i32 (i32)* @_Z10overloadedi.sse4.2.0
-// LINUX: ret i32 (i32)* @_Z10overloadedi.default.1
+// LINUX: define weak_odr ptr @_Z10overloadedi.resolver() comdat
+// LINUX: ret ptr @_Z10overloadedi.sse4.2.0
+// LINUX: ret ptr @_Z10overloadedi.default.1
 
 // WINDOWS: define dso_local noundef i32 @"?overloaded@@YAHH@Z.sse4.2.0"(i32{{.+}})
 // WINDOWS: define dso_local noundef i32 @"?overloaded@@YAHH@Z.default.1"(i32{{.+}})
@@ -23,15 +23,15 @@
 // WINDOWS: call i32 @"?overloaded@@YAHH@Z.default.1"
 
 int __attribute__((target_clones("arch=ivybridge", "default"))) overloaded(const char *) { return 2; }
-// LINUX: define {{.*}}i32 @_Z10overloadedPKc.arch_ivybridge.0(i8*{{.+}})
-// LINUX: define {{.*}}i32 @_Z10overloadedPKc.default.1(i8*{{.+}})
-// LINUX: define weak_odr i32 (i8*)* @_Z10overloadedPKc.resolver() comdat
-// LINUX: ret i32 (i8*)* @_Z10overloadedPKc.arch_ivybridge.0
-// LINUX: ret i32 (i8*)* @_Z10overloadedPKc.default.1
-
-// WINDOWS: define dso_local noundef i32 @"?overloaded@@YAHPEBD@Z.arch_ivybridge.0"(i8*{{.+}})
-// WINDOWS: define dso_local noundef i32 @"?overloaded@@YAHPEBD@Z.default.1"(i8*{{.+}})
-// WINDOWS: define weak_odr dso_local i32 @"?overloaded@@YAHPEBD@Z"(i8*{{.+}}) comdat
+// LINUX: define {{.*}}i32 @_Z10overloadedPKc.arch_ivybridge.0(ptr{{.+}})
+// LINUX: define {{.*}}i32 @_Z10overloadedPKc.default.1(ptr{{.+}})
+// LINUX: define weak_odr ptr @_Z10overloadedPKc.resolver() comdat
+// LINUX: ret ptr @_Z10overloadedPKc.arch_ivybridge.0
+// LINUX: ret ptr @_Z10overloadedPKc.default.1
+
+// WINDOWS: define dso_local noundef i32 @"?overloaded@@YAHPEBD@Z.arch_ivybridge.0"(ptr{{.+}})
+// WINDOWS: define dso_local noundef i32 @"?overloaded@@YAHPEBD@Z.default.1"(ptr{{.+}})
+// WINDOWS: define weak_odr dso_local i32 @"?overloaded@@YAHPEBD@Z"(ptr{{.+}}) comdat
 // WINDOWS: call i32 @"?overloaded@@YAHPEBD@Z.arch_ivybridge.0"
 // WINDOWS: call i32 @"?overloaded@@YAHPEBD@Z.default.1"
 
@@ 

[clang] 71a35f7 - [gcov] Simplify cc1 options and remove CodeGenOptions EmitCovNotes/EmitCovArcs

2023-05-17 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-05-17T16:09:12-07:00
New Revision: 71a35f7e3d6c78f8035f2eb7d58beba3b7208f9d

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

LOG: [gcov] Simplify cc1 options and remove CodeGenOptions 
EmitCovNotes/EmitCovArcs

After a07b135ce0c0111bd83450b5dc29ef0381cdbc39, we always pass
-coverage-notes-file/-coverage-data-file for driver options
-ftest-coverage/-fprofile-arcs/--coverage. As a bonus, we can make the following
simplification to cc1 options:

* `-ftest-coverage -coverage-notes-file a.gcno` => `-coverage-notes-file a.gcno`
* `-fprofile-arcs -coverage-data-file a.gcda` => `-coverage-data-file a.gcda`

and remove EmitCovNotes/EmitCovArcs.

Added: 


Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGen/attr-function-return.c
clang/test/CodeGen/code-coverage-tsan.c
clang/test/CodeGen/code-coverage.c
clang/test/CodeGen/no_profile.c
clang/test/Driver/coverage.c
clang/test/Driver/cuda-no-pgo-or-coverage.cu

Removed: 




diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index c026d8e30551f..5752c6e285b98 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -85,8 +85,6 @@ CODEGENOPT(EmitDeclMetadata  , 1, 0) ///< Emit special 
metadata indicating what
  ///< Only useful when running CodeGen as a
  ///< subroutine.
 CODEGENOPT(EmitVersionIdentMetadata , 1, 1) ///< Emit compiler version 
metadata.
-CODEGENOPT(EmitGcovArcs  , 1, 0) ///< Emit coverage data files, aka. GCDA.
-CODEGENOPT(EmitGcovNotes , 1, 0) ///< Emit coverage "notes" files, aka 
GCNO.
 CODEGENOPT(EmitOpenCLArgMetadata , 1, 0) ///< Emit OpenCL kernel arg metadata.
 CODEGENOPT(EmulatedTLS   , 1, 0) ///< Set by default or 
-f[no-]emulated-tls.
 /// Embed Bitcode mode (off/all/bitcode/marker).

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 9d765cc6329b8..f3026693e6d53 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1388,22 +1388,20 @@ def fno_profile_instr_use : Flag<["-"], 
"fno-profile-instr-use">,
 HelpText<"Disable using instrumentation data for profile-guided 
optimization">;
 def fno_profile_use : Flag<["-"], "fno-profile-use">,
 Alias;
-defm profile_arcs : BoolFOption<"profile-arcs",
-  CodeGenOpts<"EmitGcovArcs">, DefaultFalse,
-  PosFlag, NegFlag>;
-defm test_coverage : BoolFOption<"test-coverage",
-  CodeGenOpts<"EmitGcovNotes">, DefaultFalse,
-  PosFlag, NegFlag>;
+def ftest_coverage : Flag<["-"], "ftest-coverage">, Group,
+HelpText<"Produce gcov notes files (*.gcno)">;
+def fno_test_coverage : Flag<["-"], "fno-test-coverage">, Group;
+def fprofile_arcs : Flag<["-"], "fprofile-arcs">, Group,
+HelpText<"Instrument code to produce gcov data files (*.gcda)">;
+def fno_profile_arcs : Flag<["-"], "fno-profile-arcs">, Group;
 def fprofile_filter_files_EQ : Joined<["-"], "fprofile-filter-files=">,
 Group, Flags<[CC1Option, CoreOption]>,
 HelpText<"Instrument only functions from files where names match any regex 
separated by a semi-colon">,
-MarshallingInfoString>,
-ShouldParseIf;
+MarshallingInfoString>;
 def fprofile_exclude_files_EQ : Joined<["-"], "fprofile-exclude-files=">,
 Group, Flags<[CC1Option, CoreOption]>,
 HelpText<"Instrument only functions from files where names don't match all 
the regexes separated by a semi-colon">,
-MarshallingInfoString>,
-ShouldParseIf;
+MarshallingInfoString>;
 def fprofile_update_EQ : Joined<["-"], "fprofile-update=">,
 Group, Flags<[CC1Option, CoreOption]>, 
Values<"atomic,prefer-atomic,single">,
 MetaVarName<"">, HelpText<"Set update method of profile counters">,
@@ -5602,14 +5600,12 @@ def fmerge_functions : Flag<["-"], "fmerge-functions">,
   MarshallingInfoFlag>;
 def coverage_data_file : Separate<["-"], "coverage-data-file">,
   HelpText<"Emit coverage data to this filename.">,
-  MarshallingInfoString>,
-  ShouldParseIf;
+  MarshallingInfoString>;
 def coverage_data_file_EQ : Joined<["-"], "coverage-data-file=">,
   Alias;
 def coverage_notes_file : Separate<["-"], "coverage-notes-file">,
   HelpText<"Emit coverage notes to this filename.">,
-  MarshallingInfoString>,
-  ShouldParseIf;
+  MarshallingInfoString>;
 def coverage_notes_file_EQ : Joined<["-"], "coverage-notes-file=">,
   Alias;
 def 

[PATCH] D150807: [Clang] Remove direct linking of offloading runtimes from the arch tools

2023-05-17 Thread Joseph Huber via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG66da9ec073ff: [Clang] Remove direct linking of offloading 
runtimes from the arch tools (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150807

Files:
  clang/tools/amdgpu-arch/AMDGPUArch.cpp
  clang/tools/amdgpu-arch/CMakeLists.txt
  clang/tools/nvptx-arch/CMakeLists.txt
  clang/tools/nvptx-arch/NVPTXArch.cpp


Index: clang/tools/nvptx-arch/NVPTXArch.cpp
===
--- clang/tools/nvptx-arch/NVPTXArch.cpp
+++ clang/tools/nvptx-arch/NVPTXArch.cpp
@@ -30,7 +30,6 @@
 // and -help) will be hidden.
 static cl::OptionCategory NVPTXArchCategory("nvptx-arch options");
 
-#if DYNAMIC_CUDA
 typedef enum cudaError_enum {
   CUDA_SUCCESS = 0,
   CUDA_ERROR_NO_DEVICE = 100,
@@ -75,12 +74,6 @@
 #undef DYNAMIC_INIT
   return llvm::Error::success();
 }
-#else
-
-#include "cuda.h"
-llvm::Error loadCUDA() { return llvm::Error::success(); }
-
-#endif
 
 static int handleError(CUresult Err) {
   const char *ErrStr = nullptr;
Index: clang/tools/nvptx-arch/CMakeLists.txt
===
--- clang/tools/nvptx-arch/CMakeLists.txt
+++ clang/tools/nvptx-arch/CMakeLists.txt
@@ -9,12 +9,4 @@
 set(LLVM_LINK_COMPONENTS Support)
 add_clang_tool(nvptx-arch NVPTXArch.cpp)
 
-find_package(CUDAToolkit QUIET)
-
-# If we found the CUDA library directly we just dynamically link against it.
-if(CUDAToolkit_FOUND AND NOT (LLVM_BUILD_32_BITS OR CMAKE_SIZEOF_VOID_P EQUAL 
4))
-  target_link_libraries(nvptx-arch PRIVATE CUDA::cuda_driver clangBasic)
-else()
-  target_compile_definitions(nvptx-arch PRIVATE "DYNAMIC_CUDA")
-  target_link_libraries(nvptx-arch PRIVATE clangBasic)
-endif()
+target_link_libraries(nvptx-arch PRIVATE clangBasic)
Index: clang/tools/amdgpu-arch/CMakeLists.txt
===
--- clang/tools/amdgpu-arch/CMakeLists.txt
+++ clang/tools/amdgpu-arch/CMakeLists.txt
@@ -10,12 +10,4 @@
 
 add_clang_tool(amdgpu-arch AMDGPUArch.cpp)
 
-# If we find the HSA runtime we link with it directly.
-find_package(hsa-runtime64 QUIET 1.2.0 HINTS ${CMAKE_INSTALL_PREFIX} PATHS 
/opt/rocm)
-if(hsa-runtime64_FOUND AND NOT (LLVM_BUILD_32_BITS OR CMAKE_SIZEOF_VOID_P 
EQUAL 4))
-  set_target_properties(amdgpu-arch PROPERTIES INSTALL_RPATH_USE_LINK_PATH ON)
-  target_link_libraries(amdgpu-arch PRIVATE hsa-runtime64::hsa-runtime64 
clangBasic)
-else()
-  target_compile_definitions(amdgpu-arch PRIVATE "DYNAMIC_HSA")
-  target_link_libraries(amdgpu-arch PRIVATE clangBasic)
-endif()
+target_link_libraries(amdgpu-arch PRIVATE clangBasic)
Index: clang/tools/amdgpu-arch/AMDGPUArch.cpp
===
--- clang/tools/amdgpu-arch/AMDGPUArch.cpp
+++ clang/tools/amdgpu-arch/AMDGPUArch.cpp
@@ -30,7 +30,6 @@
   OS << clang::getClangToolFullVersion("amdgpu-arch") << '\n';
 }
 
-#if DYNAMIC_HSA
 typedef enum {
   HSA_STATUS_SUCCESS = 0x0,
 } hsa_status_t;
@@ -80,18 +79,6 @@
 #undef DYNAMIC_INIT
   return llvm::Error::success();
 }
-#else
-
-#if defined(__has_include)
-#if __has_include("hsa/hsa.h")
-#include "hsa/hsa.h"
-#elif __has_include("hsa.h")
-#include "hsa.h"
-#endif
-#endif
-
-llvm::Error loadHSA() { return llvm::Error::success(); }
-#endif
 
 static hsa_status_t iterateAgentsCallback(hsa_agent_t Agent, void *Data) {
   hsa_device_type_t DeviceType;


Index: clang/tools/nvptx-arch/NVPTXArch.cpp
===
--- clang/tools/nvptx-arch/NVPTXArch.cpp
+++ clang/tools/nvptx-arch/NVPTXArch.cpp
@@ -30,7 +30,6 @@
 // and -help) will be hidden.
 static cl::OptionCategory NVPTXArchCategory("nvptx-arch options");
 
-#if DYNAMIC_CUDA
 typedef enum cudaError_enum {
   CUDA_SUCCESS = 0,
   CUDA_ERROR_NO_DEVICE = 100,
@@ -75,12 +74,6 @@
 #undef DYNAMIC_INIT
   return llvm::Error::success();
 }
-#else
-
-#include "cuda.h"
-llvm::Error loadCUDA() { return llvm::Error::success(); }
-
-#endif
 
 static int handleError(CUresult Err) {
   const char *ErrStr = nullptr;
Index: clang/tools/nvptx-arch/CMakeLists.txt
===
--- clang/tools/nvptx-arch/CMakeLists.txt
+++ clang/tools/nvptx-arch/CMakeLists.txt
@@ -9,12 +9,4 @@
 set(LLVM_LINK_COMPONENTS Support)
 add_clang_tool(nvptx-arch NVPTXArch.cpp)
 
-find_package(CUDAToolkit QUIET)
-
-# If we found the CUDA library directly we just dynamically link against it.
-if(CUDAToolkit_FOUND AND NOT (LLVM_BUILD_32_BITS OR CMAKE_SIZEOF_VOID_P EQUAL 4))
-  target_link_libraries(nvptx-arch PRIVATE CUDA::cuda_driver clangBasic)
-else()
-  target_compile_definitions(nvptx-arch PRIVATE "DYNAMIC_CUDA")
-  target_link_libraries(nvptx-arch PRIVATE clangBasic)
-endif()

[clang] 66da9ec - [Clang] Remove direct linking of offloading runtimes from the arch tools

2023-05-17 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2023-05-17T17:47:49-05:00
New Revision: 66da9ec073ff8dde54b70adcf3b62914769324bf

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

LOG: [Clang] Remove direct linking of offloading runtimes from the arch tools

The tools `amdgpu-arch` and `nvptx-arch` are used to query the supported
GPUs on a system to implement features like `--offload-arch=native` as
well as generally being useful for setting up tests. However, we
currently directly link these if they are availible. This patch removes
this because it causes many problems on the user not having the libaries
present or misconfigured at build time. Since these are built
unconditionally we shoudl keep the dependencies away from clang.

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

Reviewed By: ye-luo

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

Added: 


Modified: 
clang/tools/amdgpu-arch/AMDGPUArch.cpp
clang/tools/amdgpu-arch/CMakeLists.txt
clang/tools/nvptx-arch/CMakeLists.txt
clang/tools/nvptx-arch/NVPTXArch.cpp

Removed: 




diff  --git a/clang/tools/amdgpu-arch/AMDGPUArch.cpp 
b/clang/tools/amdgpu-arch/AMDGPUArch.cpp
index b63ff5cfe1759..17d188adc3b7d 100644
--- a/clang/tools/amdgpu-arch/AMDGPUArch.cpp
+++ b/clang/tools/amdgpu-arch/AMDGPUArch.cpp
@@ -30,7 +30,6 @@ static void PrintVersion(raw_ostream ) {
   OS << clang::getClangToolFullVersion("amdgpu-arch") << '\n';
 }
 
-#if DYNAMIC_HSA
 typedef enum {
   HSA_STATUS_SUCCESS = 0x0,
 } hsa_status_t;
@@ -80,18 +79,6 @@ llvm::Error loadHSA() {
 #undef DYNAMIC_INIT
   return llvm::Error::success();
 }
-#else
-
-#if defined(__has_include)
-#if __has_include("hsa/hsa.h")
-#include "hsa/hsa.h"
-#elif __has_include("hsa.h")
-#include "hsa.h"
-#endif
-#endif
-
-llvm::Error loadHSA() { return llvm::Error::success(); }
-#endif
 
 static hsa_status_t iterateAgentsCallback(hsa_agent_t Agent, void *Data) {
   hsa_device_type_t DeviceType;

diff  --git a/clang/tools/amdgpu-arch/CMakeLists.txt 
b/clang/tools/amdgpu-arch/CMakeLists.txt
index 4349fb9108a71..6363eda49abe0 100644
--- a/clang/tools/amdgpu-arch/CMakeLists.txt
+++ b/clang/tools/amdgpu-arch/CMakeLists.txt
@@ -10,12 +10,4 @@ set(LLVM_LINK_COMPONENTS Support)
 
 add_clang_tool(amdgpu-arch AMDGPUArch.cpp)
 
-# If we find the HSA runtime we link with it directly.
-find_package(hsa-runtime64 QUIET 1.2.0 HINTS ${CMAKE_INSTALL_PREFIX} PATHS 
/opt/rocm)
-if(hsa-runtime64_FOUND AND NOT (LLVM_BUILD_32_BITS OR CMAKE_SIZEOF_VOID_P 
EQUAL 4))
-  set_target_properties(amdgpu-arch PROPERTIES INSTALL_RPATH_USE_LINK_PATH ON)
-  target_link_libraries(amdgpu-arch PRIVATE hsa-runtime64::hsa-runtime64 
clangBasic)
-else()
-  target_compile_definitions(amdgpu-arch PRIVATE "DYNAMIC_HSA")
-  target_link_libraries(amdgpu-arch PRIVATE clangBasic)
-endif()
+target_link_libraries(amdgpu-arch PRIVATE clangBasic)

diff  --git a/clang/tools/nvptx-arch/CMakeLists.txt 
b/clang/tools/nvptx-arch/CMakeLists.txt
index 3444cf5b70dfd..8f756be2c86d0 100644
--- a/clang/tools/nvptx-arch/CMakeLists.txt
+++ b/clang/tools/nvptx-arch/CMakeLists.txt
@@ -9,12 +9,4 @@
 set(LLVM_LINK_COMPONENTS Support)
 add_clang_tool(nvptx-arch NVPTXArch.cpp)
 
-find_package(CUDAToolkit QUIET)
-
-# If we found the CUDA library directly we just dynamically link against it.
-if(CUDAToolkit_FOUND AND NOT (LLVM_BUILD_32_BITS OR CMAKE_SIZEOF_VOID_P EQUAL 
4))
-  target_link_libraries(nvptx-arch PRIVATE CUDA::cuda_driver clangBasic)
-else()
-  target_compile_definitions(nvptx-arch PRIVATE "DYNAMIC_CUDA")
-  target_link_libraries(nvptx-arch PRIVATE clangBasic)
-endif()
+target_link_libraries(nvptx-arch PRIVATE clangBasic)

diff  --git a/clang/tools/nvptx-arch/NVPTXArch.cpp 
b/clang/tools/nvptx-arch/NVPTXArch.cpp
index b053fcc6e0bdd..71a48657576e4 100644
--- a/clang/tools/nvptx-arch/NVPTXArch.cpp
+++ b/clang/tools/nvptx-arch/NVPTXArch.cpp
@@ -30,7 +30,6 @@ static void PrintVersion(raw_ostream ) {
 // and -help) will be hidden.
 static cl::OptionCategory NVPTXArchCategory("nvptx-arch options");
 
-#if DYNAMIC_CUDA
 typedef enum cudaError_enum {
   CUDA_SUCCESS = 0,
   CUDA_ERROR_NO_DEVICE = 100,
@@ -75,12 +74,6 @@ llvm::Error loadCUDA() {
 #undef DYNAMIC_INIT
   return llvm::Error::success();
 }
-#else
-
-#include "cuda.h"
-llvm::Error loadCUDA() { return llvm::Error::success(); }
-
-#endif
 
 static int handleError(CUresult Err) {
   const char *ErrStr = nullptr;



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


[PATCH] D150043: [InferAddressSpaces] Handle vector of pointers type & Support intrinsic masked gather/scatter

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

44096e6904e10bb313fef2f6aaff25c25d1325f7 



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

https://reviews.llvm.org/D150043

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


[clang] 3d7903f - Revert "[Driver] Support multi /guard: options"

2023-05-17 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2023-05-17T15:34:14-07:00
New Revision: 3d7903f1008febc80cb104eedcbcd31d2690839f

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

LOG: Revert "[Driver] Support multi /guard: options"

This reverts commit 3b6f7e45a20990fdbc2b43dc08457fc79d53bd39.

See comments on D150645.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/MSVC.cpp
clang/test/Driver/cl-options.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index be4fceb793758..cbf12a151ff7a 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -7872,7 +7872,7 @@ void Clang::AddClangCLArgs(const ArgList , types::ID 
InputType,
   if (Args.hasArg(options::OPT__SLASH_kernel))
 CmdArgs.push_back("-fms-kernel");
 
-  for (const Arg *A : Args.filtered(options::OPT__SLASH_guard)) {
+  if (Arg *A = Args.getLastArg(options::OPT__SLASH_guard)) {
 StringRef GuardArgs = A->getValue();
 // The only valid options are "cf", "cf,nochecks", "cf-", "ehcont" and
 // "ehcont-".

diff  --git a/clang/lib/Driver/ToolChains/MSVC.cpp 
b/clang/lib/Driver/ToolChains/MSVC.cpp
index d803ddad504c6..b23d0aa2f1b83 100644
--- a/clang/lib/Driver/ToolChains/MSVC.cpp
+++ b/clang/lib/Driver/ToolChains/MSVC.cpp
@@ -227,7 +227,7 @@ void visualstudio::Linker::ConstructJob(Compilation , 
const JobAction ,
   Args.AddAllArgValues(CmdArgs, options::OPT__SLASH_link);
 
   // Control Flow Guard checks
-  for (const Arg *A : Args.filtered(options::OPT__SLASH_guard)) {
+  if (Arg *A = Args.getLastArg(options::OPT__SLASH_guard)) {
 StringRef GuardArgs = A->getValue();
 if (GuardArgs.equals_insensitive("cf") ||
 GuardArgs.equals_insensitive("cf,nochecks")) {

diff  --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index c7d7fae8426a7..12d7023bd61b1 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -647,10 +647,6 @@
 // RUN: %clang_cl /guard:ehcont -### -- %s 2>&1 | FileCheck 
-check-prefix=EHCONTGUARD %s
 // EHCONTGUARD: -ehcontguard
 
-// RUN: %clang_cl /guard:cf /guard:ehcont -### -- %s 2>&1 | FileCheck 
-check-prefix=BOTHGUARD %s
-// BOTHGUARD: -cfguard
-// BOTHGUARD-SAME: -ehcontguard
-
 // RUN: %clang_cl /guard:foo -### -- %s 2>&1 | FileCheck 
-check-prefix=CFGUARDINVALID %s
 // CFGUARDINVALID: invalid value 'foo' in '/guard:'
 



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


[PATCH] D150645: [Driver] Support multi /guard: options

2023-05-17 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

this causes `./build/rel/bin/clang-cl /c /tmp/a.cc /Fo/tmp/a 
/guard:cf,nochecks` to go from no warnings to

  clang-cl: warning: argument unused during compilation: '/guard:cf,nochecks' 
[-Wunused-command-line-argument]


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150645

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


[PATCH] D150689: [clang][DependencyScanner] Remove all warning flags when suppressing warnings

2023-05-17 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese added inline comments.



Comment at: clang/test/ClangScanDeps/optimize-system-warnings.m:19
+// CHECK:],
+// CHECK-NEXT:   "name": "A"
+// CHECK-NEXT: },

jansvoboda11 wrote:
> I'd like to see a check line that would fail if the scanner reports another 
> variant of module `A`. The `CHECK:` lines make it possible for FileCheck to 
> skip an entire element in the modules array. (Structural matching on JSON in 
> FileCheck would be a godsend.)
The way FileCheck works I do not believe this can happen. A `CHECK:` line finds 
the first line that matches, and `CHECK-NEXT:` follows exactly after that. 
There's no case where we have a `CHECK:` that can skip over another entire 
module entry.



Comment at: clang/test/ClangScanDeps/optimize-system-warnings.m:30
+// CHECK:],
+// CHECK-NEXT:   "name": "B"
+// CHECK-NEXT: }

jansvoboda11 wrote:
> I'd expect the scanner to still produce two variants of module `B`, since 
> it's a user module. Is that correct? If so, let's add explicit check for it, 
> since we intentionally want to preserve the warning flags there.
Both `A` and `B` are system modules. `A` is found via `-isystem`, and `B` has 
the `[system]` attribute. The FileCheck lines will only succeed if there are 
exactly two modules returned.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150689

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


[PATCH] D150221: Add option -fkeep-static-variables to emit all static variables

2023-05-17 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

The hot-patch use case actually shouldn't care if the compiler/linker throws 
away unused things because it can't possibly affect how the patch interoperates 
with existing code.  This does rely on the unanalyzable-use part of the 
semantics, though, to stop the compiler from removing uses that could become 
significant after hot-patching.

Force-emitting every `static` in the translation unit can be very expensive; 
there are a lot of headers that declare all their constants as `static const`.  
And removing dead globals is a pretty important optimization, e.g. to eliminate 
the string literals used by assertions that the compiler was able to fold to 
`true`.  So I don't think it's unreasonable for us to ask whether we should 
just be naively adding this option instead of figuring out a more targeted way 
of satisfying these users.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150221

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


[PATCH] D150340: [SEH]:Fix assertion when try is used inside catch(...) block with /EHa

2023-05-17 Thread Jennifer Yu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG691927c904ed: Fix assertion when try is used inside 
catch(...) block (authored by jyu2).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150340

Files:
  clang/lib/CodeGen/CGException.cpp
  clang/test/CodeGen/windows-seh-EHa-CppCatchDotDotDot.cpp


Index: clang/test/CodeGen/windows-seh-EHa-CppCatchDotDotDot.cpp
===
--- clang/test/CodeGen/windows-seh-EHa-CppCatchDotDotDot.cpp
+++ clang/test/CodeGen/windows-seh-EHa-CppCatchDotDotDot.cpp
@@ -9,11 +9,21 @@
 // CHECK: %[[dst1:[0-9-]+]] = catchpad within %[[dst]] [ptr null, i32 0, ptr 
null]
 // CHECK: "funclet"(token %[[dst1]])
 
+// CHECK: define dso_local void @"?bar@@YAXXZ
+// CHECK: invoke void @llvm.seh.try.begin()
+// CHECK: invoke void @_CxxThrowException
+// CHECK: %[[dst:[0-9-]+]] = catchpad within %0 [ptr null, i32 0, ptr null]
+// CHECK: invoke void @llvm.seh.try.begin() [ "funclet"(token %[[dst]]) ]
+
 // CHECK: invoke void @llvm.seh.try.begin()
 // CHECK: %[[src:[0-9-]+]] = load volatile i32, ptr %i
 // CHECK-NEXT: invoke void @"?crash@@YAXH@Z"(i32 noundef %[[src]])
 // CHECK: invoke void @llvm.seh.try.end()
 
+// CHECK: invoke void @llvm.seh.try.begin()
+// CHECK: invoke void @"?bar@@YAXXZ"()
+// CHECK: invoke void @llvm.seh.try.end()
+
 // 
*
 // Abstract: Test CPP catch(...) under SEH -EHa option
 
@@ -46,6 +56,18 @@
   }
 }
 
+void bar() {
+  try {
+throw 1;
+  } catch(...) {
+try {
+  *NullPtr = 0;
+} catch (...) {
+   throw 1;
+}
+  }
+}
+
 int main() {
   for (int i = 0; i < 2; i++) {
 __try {
@@ -54,5 +76,10 @@
   printf(" Test CPP unwind: in except handler i = %d \n", i);
 }
   }
+  __try {
+   bar();
+  } __except (1) {
+printf("Test CPP unwind: in except handler \n");
+  }
   return 0;
 }
Index: clang/lib/CodeGen/CGException.cpp
===
--- clang/lib/CodeGen/CGException.cpp
+++ clang/lib/CodeGen/CGException.cpp
@@ -646,7 +646,7 @@
   // Under async exceptions, catch(...) need to catch HW exception too
   // Mark scope with SehTryBegin as a SEH __try scope
   if (getLangOpts().EHAsynch)
-EmitRuntimeCallOrInvoke(getSehTryBeginFn(CGM));
+EmitSehTryScopeBegin();
 }
   }
 }


Index: clang/test/CodeGen/windows-seh-EHa-CppCatchDotDotDot.cpp
===
--- clang/test/CodeGen/windows-seh-EHa-CppCatchDotDotDot.cpp
+++ clang/test/CodeGen/windows-seh-EHa-CppCatchDotDotDot.cpp
@@ -9,11 +9,21 @@
 // CHECK: %[[dst1:[0-9-]+]] = catchpad within %[[dst]] [ptr null, i32 0, ptr null]
 // CHECK: "funclet"(token %[[dst1]])
 
+// CHECK: define dso_local void @"?bar@@YAXXZ
+// CHECK: invoke void @llvm.seh.try.begin()
+// CHECK: invoke void @_CxxThrowException
+// CHECK: %[[dst:[0-9-]+]] = catchpad within %0 [ptr null, i32 0, ptr null]
+// CHECK: invoke void @llvm.seh.try.begin() [ "funclet"(token %[[dst]]) ]
+
 // CHECK: invoke void @llvm.seh.try.begin()
 // CHECK: %[[src:[0-9-]+]] = load volatile i32, ptr %i
 // CHECK-NEXT: invoke void @"?crash@@YAXH@Z"(i32 noundef %[[src]])
 // CHECK: invoke void @llvm.seh.try.end()
 
+// CHECK: invoke void @llvm.seh.try.begin()
+// CHECK: invoke void @"?bar@@YAXXZ"()
+// CHECK: invoke void @llvm.seh.try.end()
+
 // *
 // Abstract: Test CPP catch(...) under SEH -EHa option
 
@@ -46,6 +56,18 @@
   }
 }
 
+void bar() {
+  try {
+throw 1;
+  } catch(...) {
+try {
+  *NullPtr = 0;
+} catch (...) {
+   throw 1;
+}
+  }
+}
+
 int main() {
   for (int i = 0; i < 2; i++) {
 __try {
@@ -54,5 +76,10 @@
   printf(" Test CPP unwind: in except handler i = %d \n", i);
 }
   }
+  __try {
+   bar();
+  } __except (1) {
+printf("Test CPP unwind: in except handler \n");
+  }
   return 0;
 }
Index: clang/lib/CodeGen/CGException.cpp
===
--- clang/lib/CodeGen/CGException.cpp
+++ clang/lib/CodeGen/CGException.cpp
@@ -646,7 +646,7 @@
   // Under async exceptions, catch(...) need to catch HW exception too
   // Mark scope with SehTryBegin as a SEH __try scope
   if (getLangOpts().EHAsynch)
-EmitRuntimeCallOrInvoke(getSehTryBeginFn(CGM));
+EmitSehTryScopeBegin();
 }
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 691927c - Fix assertion when try is used inside catch(...) block

2023-05-17 Thread Jennifer Yu via cfe-commits

Author: Jennifer Yu
Date: 2023-05-17T14:42:39-07:00
New Revision: 691927c904ede183461610387402f5c19dbb3de0

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

LOG: Fix assertion when try is used inside catch(...) block

Current assert wiht /EHa:
A single unwind edge may only enter one EH pad
  invoke void @llvm.seh.try.begin()
  to label %invoke.cont1 unwind label %catch.dispatch2

Current IR:
%1 = catchpad within %0 [ptr null, i32 0, ptr null]
   invoke void @llvm.seh.try.begin()
   to label %invoke.cont5 unwind label %catch.dispatch2

The problem is the invoke to llvm.seh.try.begin() missing "funclet"

Accodring: https://llvm.org/docs/LangRef.html#ob-funclet
If any "funclet" EH pads have been entered but not exited (per the
description in the EH doc), it is undefined behavior to execute a
call or invoke.

To fix the problem, when emit seh_try_begin,  call EmitSehTryScopeBegin,
instead of calling EmitRuntimeCallOrInvoke for proper "funclet"
gerenration.

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

Added: 


Modified: 
clang/lib/CodeGen/CGException.cpp
clang/test/CodeGen/windows-seh-EHa-CppCatchDotDotDot.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGException.cpp 
b/clang/lib/CodeGen/CGException.cpp
index 3707c87924916..8b0776b9a52b0 100644
--- a/clang/lib/CodeGen/CGException.cpp
+++ b/clang/lib/CodeGen/CGException.cpp
@@ -646,7 +646,7 @@ void CodeGenFunction::EnterCXXTryStmt(const CXXTryStmt , 
bool IsFnTryBlock) {
   // Under async exceptions, catch(...) need to catch HW exception too
   // Mark scope with SehTryBegin as a SEH __try scope
   if (getLangOpts().EHAsynch)
-EmitRuntimeCallOrInvoke(getSehTryBeginFn(CGM));
+EmitSehTryScopeBegin();
 }
   }
 }

diff  --git a/clang/test/CodeGen/windows-seh-EHa-CppCatchDotDotDot.cpp 
b/clang/test/CodeGen/windows-seh-EHa-CppCatchDotDotDot.cpp
index 047894c395bb4..c9e6c9925edd4 100644
--- a/clang/test/CodeGen/windows-seh-EHa-CppCatchDotDotDot.cpp
+++ b/clang/test/CodeGen/windows-seh-EHa-CppCatchDotDotDot.cpp
@@ -9,11 +9,21 @@
 // CHECK: %[[dst1:[0-9-]+]] = catchpad within %[[dst]] [ptr null, i32 0, ptr 
null]
 // CHECK: "funclet"(token %[[dst1]])
 
+// CHECK: define dso_local void @"?bar@@YAXXZ
+// CHECK: invoke void @llvm.seh.try.begin()
+// CHECK: invoke void @_CxxThrowException
+// CHECK: %[[dst:[0-9-]+]] = catchpad within %0 [ptr null, i32 0, ptr null]
+// CHECK: invoke void @llvm.seh.try.begin() [ "funclet"(token %[[dst]]) ]
+
 // CHECK: invoke void @llvm.seh.try.begin()
 // CHECK: %[[src:[0-9-]+]] = load volatile i32, ptr %i
 // CHECK-NEXT: invoke void @"?crash@@YAXH@Z"(i32 noundef %[[src]])
 // CHECK: invoke void @llvm.seh.try.end()
 
+// CHECK: invoke void @llvm.seh.try.begin()
+// CHECK: invoke void @"?bar@@YAXXZ"()
+// CHECK: invoke void @llvm.seh.try.end()
+
 // 
*
 // Abstract: Test CPP catch(...) under SEH -EHa option
 
@@ -46,6 +56,18 @@ void crash(int i) {
   }
 }
 
+void bar() {
+  try {
+throw 1;
+  } catch(...) {
+try {
+  *NullPtr = 0;
+} catch (...) {
+   throw 1;
+}
+  }
+}
+
 int main() {
   for (int i = 0; i < 2; i++) {
 __try {
@@ -54,5 +76,10 @@ int main() {
   printf(" Test CPP unwind: in except handler i = %d \n", i);
 }
   }
+  __try {
+   bar();
+  } __except (1) {
+printf("Test CPP unwind: in except handler \n");
+  }
   return 0;
 }



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


[PATCH] D147266: [AArch64] Sink operands to allow for bitselect instructions

2023-05-17 Thread Pranav Kant via Phabricator via cfe-commits
pranavk closed this revision.
pranavk added a comment.

> I noticed there was another instance of vbsl being reported recently in 
> https://github.com/llvm/llvm-project/issues/62642. Hopefully it can be 
> addresses via extra optimizations too.

This is another InstCombine problem -- as soon as it sees constant, InstCombine 
runs demanded bits pass/analysis and tries to do clever tricks with sequence of 
and/and/or. We need to teach InstCombine here to not touch the sequence as we 
expect it to be vectorized in instruction lowering. I will try to fix this when 
looking at the other InstCombine problem (https://reviews.llvm.org/D150316) we 
are talking about.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147266

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


[PATCH] D145265: [Pipeline] Remove GlobalCleanupPM

2023-05-17 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added inline comments.



Comment at: llvm/lib/Passes/PassBuilderPipelines.cpp:476
 
+  FPM.addPass(EarlyCSEPass());
+

nikic wrote:
> Why the extra EarlyCSE pass in the `O1` pipeline?
forgot to update the commit message, see that



Comment at: llvm/lib/Passes/PassBuilderPipelines.cpp:547
+  SimplifyCFGPass(SimplifyCFGOptions().convertSwitchRangeToICmp(true)));
+  FPM.addPass(AggressiveInstCombinePass());
 

nikic wrote:
> Any particular reason why InstCombine and AggressiveInstCombine are no longer 
> directly next to each other?
we need InstCombine -> SimplifyCFG, so swapped them (see updated commit 
message). I don't necessarily see why AIC needs to be right after IC


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145265

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


[PATCH] D145265: [Pipeline] Remove GlobalCleanupPM

2023-05-17 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 523182.
aeubanks edited the summary of this revision.
aeubanks added a comment.

update commit message


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145265

Files:
  clang/test/Headers/mm_malloc.c
  llvm/lib/Passes/PassBuilderPipelines.cpp
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-pgo-preinline.ll
  llvm/test/Other/new-pm-thinlto-postlink-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
  llvm/test/Transforms/Coroutines/coro-async.ll
  llvm/test/Transforms/Coroutines/coro-retcon-alloca-opaque-ptr.ll
  llvm/test/Transforms/Coroutines/coro-retcon-alloca.ll
  llvm/test/Transforms/Coroutines/coro-retcon-once-value.ll
  llvm/test/Transforms/Coroutines/coro-retcon-opaque-ptr.ll
  llvm/test/Transforms/Coroutines/coro-retcon-resume-values.ll
  llvm/test/Transforms/Coroutines/coro-retcon-value.ll
  llvm/test/Transforms/Coroutines/coro-retcon.ll
  llvm/test/Transforms/Coroutines/coro-swifterror.ll
  llvm/test/Transforms/PhaseOrdering/X86/pr52289.ll
  llvm/test/Transforms/PhaseOrdering/inlining-alignment-assumptions.ll

Index: llvm/test/Transforms/PhaseOrdering/inlining-alignment-assumptions.ll
===
--- llvm/test/Transforms/PhaseOrdering/inlining-alignment-assumptions.ll
+++ llvm/test/Transforms/PhaseOrdering/inlining-alignment-assumptions.ll
@@ -16,10 +16,13 @@
 
 define void @caller1(i1 %c, ptr align 1 %ptr) {
 ; ASSUMPTIONS-OFF-LABEL: @caller1(
-; ASSUMPTIONS-OFF-NEXT:br i1 [[C:%.*]], label [[COMMON_RET:%.*]], label [[FALSE2:%.*]]
+; ASSUMPTIONS-OFF-NEXT:br i1 [[C:%.*]], label [[COMMON_RET:%.*]], label [[FALSE1:%.*]]
+; ASSUMPTIONS-OFF:   false1:
+; ASSUMPTIONS-OFF-NEXT:store volatile i64 1, ptr [[PTR:%.*]], align 4
+; ASSUMPTIONS-OFF-NEXT:br label [[COMMON_RET]]
 ; ASSUMPTIONS-OFF:   common.ret:
-; ASSUMPTIONS-OFF-NEXT:[[DOTSINK:%.*]] = phi i64 [ 3, [[FALSE2]] ], [ 2, [[TMP0:%.*]] ]
-; ASSUMPTIONS-OFF-NEXT:store volatile i64 0, ptr [[PTR:%.*]], align 8
+; ASSUMPTIONS-OFF-NEXT:[[DOTSINK:%.*]] = phi i64 [ 3, [[FALSE1]] ], [ 2, [[TMP0:%.*]] ]
+; ASSUMPTIONS-OFF-NEXT:store volatile i64 0, ptr [[PTR]], align 8
 ; ASSUMPTIONS-OFF-NEXT:store volatile i64 -1, ptr [[PTR]], align 4
 ; ASSUMPTIONS-OFF-NEXT:store volatile i64 -1, ptr [[PTR]], align 4
 ; ASSUMPTIONS-OFF-NEXT:store volatile i64 -1, ptr [[PTR]], align 4
@@ -27,15 +30,15 @@
 ; ASSUMPTIONS-OFF-NEXT:store volatile i64 -1, ptr [[PTR]], align 4
 ; ASSUMPTIONS-OFF-NEXT:store volatile i64 [[DOTSINK]], ptr [[PTR]], align 4
 ; ASSUMPTIONS-OFF-NEXT:ret void
-; ASSUMPTIONS-OFF:   false2:
-; ASSUMPTIONS-OFF-NEXT:store volatile i64 1, ptr [[PTR]], align 4
-; ASSUMPTIONS-OFF-NEXT:br label [[COMMON_RET]]
 ;
 ; ASSUMPTIONS-ON-LABEL: @caller1(
-; ASSUMPTIONS-ON-NEXT:br i1 [[C:%.*]], label [[COMMON_RET:%.*]], label [[FALSE2:%.*]]
+; ASSUMPTIONS-ON-NEXT:br i1 [[C:%.*]], label [[COMMON_RET:%.*]], label [[FALSE1:%.*]]
+; ASSUMPTIONS-ON:   false1:
+; ASSUMPTIONS-ON-NEXT:store volatile i64 1, ptr [[PTR:%.*]], align 4
+; ASSUMPTIONS-ON-NEXT:br label [[COMMON_RET]]
 ; ASSUMPTIONS-ON:   common.ret:
-; ASSUMPTIONS-ON-NEXT:[[DOTSINK:%.*]] = phi i64 [ 3, [[FALSE2]] ], [ 2, [[TMP0:%.*]] ]
-; ASSUMPTIONS-ON-NEXT:call void @llvm.assume(i1 true) [ "align"(ptr [[PTR:%.*]], i64 8) ]
+; ASSUMPTIONS-ON-NEXT:[[DOTSINK:%.*]] = phi i64 [ 3, [[FALSE1]] ], [ 2, [[TMP0:%.*]] ]
+; ASSUMPTIONS-ON-NEXT:call void @llvm.assume(i1 true) [ "align"(ptr [[PTR]], i64 8) ]
 ; ASSUMPTIONS-ON-NEXT:store volatile i64 0, ptr [[PTR]], align 8
 ; ASSUMPTIONS-ON-NEXT:store volatile i64 -1, ptr [[PTR]], align 8
 ; ASSUMPTIONS-ON-NEXT:store volatile i64 -1, ptr [[PTR]], align 8
@@ -44,9 +47,6 @@
 ; ASSUMPTIONS-ON-NEXT:store volatile i64 -1, ptr [[PTR]], align 8
 ; ASSUMPTIONS-ON-NEXT:store volatile i64 [[DOTSINK]], ptr [[PTR]], align 8
 ; ASSUMPTIONS-ON-NEXT:ret void
-; ASSUMPTIONS-ON:   false2:
-; ASSUMPTIONS-ON-NEXT:store volatile i64 1, ptr [[PTR]], align 4
-; ASSUMPTIONS-ON-NEXT:br label [[COMMON_RET]]
 ;
   br i1 %c, label %true1, label %false1
 
Index: llvm/test/Transforms/PhaseOrdering/X86/pr52289.ll
===
--- llvm/test/Transforms/PhaseOrdering/X86/pr52289.ll
+++ llvm/test/Transforms/PhaseOrdering/X86/pr52289.ll
@@ -1,11 +1,28 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt -O3 -S < %s | FileCheck %s
 
+; FIXME: see the following issues for background
+; https://github.com/llvm/llvm-project/issues/51631

[PATCH] D145265: [Pipeline] Remove GlobalCleanupPM

2023-05-17 Thread Nikita Popov via Phabricator via cfe-commits
nikic added inline comments.



Comment at: llvm/lib/Passes/PassBuilderPipelines.cpp:476
 
+  FPM.addPass(EarlyCSEPass());
+

Why the extra EarlyCSE pass in the `O1` pipeline?



Comment at: llvm/lib/Passes/PassBuilderPipelines.cpp:547
+  SimplifyCFGPass(SimplifyCFGOptions().convertSwitchRangeToICmp(true)));
+  FPM.addPass(AggressiveInstCombinePass());
 

Any particular reason why InstCombine and AggressiveInstCombine are no longer 
directly next to each other?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145265

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


[PATCH] D150670: [WebAssembly] Disable generation of fshl/fshr for rotates

2023-05-17 Thread Nikita Popov via Phabricator via cfe-commits
nikic requested changes to this revision.
nikic added a comment.
This revision now requires changes to proceed.

This doesn't looks like a wasm specific problem. You get essentially the same 
issue on any target that has a rotate instruction but no funnel shift 
instruction. Here are just a couple examples: https://godbolt.org/z/8v6nfaax9

I believe this needs to be either solved by preventing demanded bits 
simplifications that break a rotate pattern (though I'm not sure if that would 
break any other optimizations we care about) or by adding a special case for 
this in the backend when lowering FSH to ROT.

Lowering to a rotate intrinsic only "solves" this for wasm and will at the same 
time make these rotates completely opaque to optimization -- heck, it looks 
like we don't even support constant folding for these intrinsics 
(https://llvm.godbolt.org/z/hMWG16b9W).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150670

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


[PATCH] D150730: [Clang][Sema] Substitute constraints only for declarations with different lexical contexts

2023-05-17 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG122b938944ce: [Clang][Sema] Substitute constraints only for 
declarations with different… (authored by alexander-shaposhnikov).

Changed prior to commit:
  https://reviews.llvm.org/D150730?vs=522856=523179#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150730

Files:
  clang/lib/Sema/SemaConcept.cpp
  clang/test/SemaTemplate/concepts-no-early-substitution.cpp


Index: clang/test/SemaTemplate/concepts-no-early-substitution.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/concepts-no-early-substitution.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -std=c++20 -x c++ %s -verify -fsyntax-only
+// expected-no-diagnostics
+
+template 
+concept HasMemberBegin = requires(T0 t) { t.begin(); };
+
+struct GetBegin {
+  template 
+  void operator()(T1);
+};
+
+GetBegin begin;
+
+template 
+concept Concept = requires(T2 t) { begin(t); };
+
+struct Subrange;
+
+template 
+struct View {
+  Subrange ();
+
+  operator bool()
+requires true;
+
+  operator bool()
+requires requires { begin(getSubrange()); };
+
+  void begin();
+};
+
+struct Subrange : View {};
+static_assert(Concept);
Index: clang/lib/Sema/SemaConcept.cpp
===
--- clang/lib/Sema/SemaConcept.cpp
+++ clang/lib/Sema/SemaConcept.cpp
@@ -780,7 +780,9 @@
  const Expr *NewConstr) {
   if (OldConstr == NewConstr)
 return true;
-  if (Old && New && Old != New) {
+  // C++ [temp.constr.decl]p4
+  if (Old && New && Old != New &&
+  Old->getLexicalDeclContext() != New->getLexicalDeclContext()) {
 if (const Expr *SubstConstr =
 SubstituteConstraintExpression(*this, Old, OldConstr))
   OldConstr = SubstConstr;


Index: clang/test/SemaTemplate/concepts-no-early-substitution.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/concepts-no-early-substitution.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -std=c++20 -x c++ %s -verify -fsyntax-only
+// expected-no-diagnostics
+
+template 
+concept HasMemberBegin = requires(T0 t) { t.begin(); };
+
+struct GetBegin {
+  template 
+  void operator()(T1);
+};
+
+GetBegin begin;
+
+template 
+concept Concept = requires(T2 t) { begin(t); };
+
+struct Subrange;
+
+template 
+struct View {
+  Subrange ();
+
+  operator bool()
+requires true;
+
+  operator bool()
+requires requires { begin(getSubrange()); };
+
+  void begin();
+};
+
+struct Subrange : View {};
+static_assert(Concept);
Index: clang/lib/Sema/SemaConcept.cpp
===
--- clang/lib/Sema/SemaConcept.cpp
+++ clang/lib/Sema/SemaConcept.cpp
@@ -780,7 +780,9 @@
  const Expr *NewConstr) {
   if (OldConstr == NewConstr)
 return true;
-  if (Old && New && Old != New) {
+  // C++ [temp.constr.decl]p4
+  if (Old && New && Old != New &&
+  Old->getLexicalDeclContext() != New->getLexicalDeclContext()) {
 if (const Expr *SubstConstr =
 SubstituteConstraintExpression(*this, Old, OldConstr))
   OldConstr = SubstConstr;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 122b938 - [Clang][Sema] Substitute constraints only for declarations with different lexical contexts

2023-05-17 Thread Alexander Shaposhnikov via cfe-commits

Author: Alexander Shaposhnikov
Date: 2023-05-17T21:24:44Z
New Revision: 122b938944ceb966e04d7a4d253f7f9ba27c477d

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

LOG: [Clang][Sema] Substitute constraints only for declarations with different 
lexical contexts

Substitute constraints only for declarations with different lexical contexts.
This results in avoiding the substitution of constraints during the 
redeclaration check
inside a class (and by product caching the wrong substitution result).

Test plan: ninja check-all

Differential revision: https://reviews.llvm.org/D150730

Added: 
clang/test/SemaTemplate/concepts-no-early-substitution.cpp

Modified: 
clang/lib/Sema/SemaConcept.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index 1126c2c517fe4..2f5fb8f8d029e 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -780,7 +780,9 @@ bool Sema::AreConstraintExpressionsEqual(const NamedDecl 
*Old,
  const Expr *NewConstr) {
   if (OldConstr == NewConstr)
 return true;
-  if (Old && New && Old != New) {
+  // C++ [temp.constr.decl]p4
+  if (Old && New && Old != New &&
+  Old->getLexicalDeclContext() != New->getLexicalDeclContext()) {
 if (const Expr *SubstConstr =
 SubstituteConstraintExpression(*this, Old, OldConstr))
   OldConstr = SubstConstr;

diff  --git a/clang/test/SemaTemplate/concepts-no-early-substitution.cpp 
b/clang/test/SemaTemplate/concepts-no-early-substitution.cpp
new file mode 100644
index 0..9e576f16a263b
--- /dev/null
+++ b/clang/test/SemaTemplate/concepts-no-early-substitution.cpp
@@ -0,0 +1,33 @@
+// RUN: %clang_cc1 -std=c++20 -x c++ %s -verify -fsyntax-only
+// expected-no-diagnostics
+
+template 
+concept HasMemberBegin = requires(T0 t) { t.begin(); };
+
+struct GetBegin {
+  template 
+  void operator()(T1);
+};
+
+GetBegin begin;
+
+template 
+concept Concept = requires(T2 t) { begin(t); };
+
+struct Subrange;
+
+template 
+struct View {
+  Subrange ();
+
+  operator bool()
+requires true;
+
+  operator bool()
+requires requires { begin(getSubrange()); };
+
+  void begin();
+};
+
+struct Subrange : View {};
+static_assert(Concept);



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


[PATCH] D145265: [Pipeline] Remove GlobalCleanupPM

2023-05-17 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 523175.
aeubanks added a comment.

rebase

keep the existing EarlyCSE/InstCombine ordering


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145265

Files:
  clang/test/Headers/mm_malloc.c
  llvm/lib/Passes/PassBuilderPipelines.cpp
  llvm/test/Feature/optnone-opt.ll
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-pgo-preinline.ll
  llvm/test/Other/new-pm-thinlto-postlink-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
  llvm/test/Transforms/Coroutines/coro-async.ll
  llvm/test/Transforms/Coroutines/coro-retcon-alloca-opaque-ptr.ll
  llvm/test/Transforms/Coroutines/coro-retcon-alloca.ll
  llvm/test/Transforms/Coroutines/coro-retcon-once-value.ll
  llvm/test/Transforms/Coroutines/coro-retcon-opaque-ptr.ll
  llvm/test/Transforms/Coroutines/coro-retcon-resume-values.ll
  llvm/test/Transforms/Coroutines/coro-retcon-value.ll
  llvm/test/Transforms/Coroutines/coro-retcon.ll
  llvm/test/Transforms/Coroutines/coro-swifterror.ll
  llvm/test/Transforms/PhaseOrdering/X86/pr52289.ll
  llvm/test/Transforms/PhaseOrdering/inlining-alignment-assumptions.ll

Index: llvm/test/Transforms/PhaseOrdering/inlining-alignment-assumptions.ll
===
--- llvm/test/Transforms/PhaseOrdering/inlining-alignment-assumptions.ll
+++ llvm/test/Transforms/PhaseOrdering/inlining-alignment-assumptions.ll
@@ -16,10 +16,13 @@
 
 define void @caller1(i1 %c, ptr align 1 %ptr) {
 ; ASSUMPTIONS-OFF-LABEL: @caller1(
-; ASSUMPTIONS-OFF-NEXT:br i1 [[C:%.*]], label [[COMMON_RET:%.*]], label [[FALSE2:%.*]]
+; ASSUMPTIONS-OFF-NEXT:br i1 [[C:%.*]], label [[COMMON_RET:%.*]], label [[FALSE1:%.*]]
+; ASSUMPTIONS-OFF:   false1:
+; ASSUMPTIONS-OFF-NEXT:store volatile i64 1, ptr [[PTR:%.*]], align 4
+; ASSUMPTIONS-OFF-NEXT:br label [[COMMON_RET]]
 ; ASSUMPTIONS-OFF:   common.ret:
-; ASSUMPTIONS-OFF-NEXT:[[DOTSINK:%.*]] = phi i64 [ 3, [[FALSE2]] ], [ 2, [[TMP0:%.*]] ]
-; ASSUMPTIONS-OFF-NEXT:store volatile i64 0, ptr [[PTR:%.*]], align 8
+; ASSUMPTIONS-OFF-NEXT:[[DOTSINK:%.*]] = phi i64 [ 3, [[FALSE1]] ], [ 2, [[TMP0:%.*]] ]
+; ASSUMPTIONS-OFF-NEXT:store volatile i64 0, ptr [[PTR]], align 8
 ; ASSUMPTIONS-OFF-NEXT:store volatile i64 -1, ptr [[PTR]], align 4
 ; ASSUMPTIONS-OFF-NEXT:store volatile i64 -1, ptr [[PTR]], align 4
 ; ASSUMPTIONS-OFF-NEXT:store volatile i64 -1, ptr [[PTR]], align 4
@@ -27,15 +30,15 @@
 ; ASSUMPTIONS-OFF-NEXT:store volatile i64 -1, ptr [[PTR]], align 4
 ; ASSUMPTIONS-OFF-NEXT:store volatile i64 [[DOTSINK]], ptr [[PTR]], align 4
 ; ASSUMPTIONS-OFF-NEXT:ret void
-; ASSUMPTIONS-OFF:   false2:
-; ASSUMPTIONS-OFF-NEXT:store volatile i64 1, ptr [[PTR]], align 4
-; ASSUMPTIONS-OFF-NEXT:br label [[COMMON_RET]]
 ;
 ; ASSUMPTIONS-ON-LABEL: @caller1(
-; ASSUMPTIONS-ON-NEXT:br i1 [[C:%.*]], label [[COMMON_RET:%.*]], label [[FALSE2:%.*]]
+; ASSUMPTIONS-ON-NEXT:br i1 [[C:%.*]], label [[COMMON_RET:%.*]], label [[FALSE1:%.*]]
+; ASSUMPTIONS-ON:   false1:
+; ASSUMPTIONS-ON-NEXT:store volatile i64 1, ptr [[PTR:%.*]], align 4
+; ASSUMPTIONS-ON-NEXT:br label [[COMMON_RET]]
 ; ASSUMPTIONS-ON:   common.ret:
-; ASSUMPTIONS-ON-NEXT:[[DOTSINK:%.*]] = phi i64 [ 3, [[FALSE2]] ], [ 2, [[TMP0:%.*]] ]
-; ASSUMPTIONS-ON-NEXT:call void @llvm.assume(i1 true) [ "align"(ptr [[PTR:%.*]], i64 8) ]
+; ASSUMPTIONS-ON-NEXT:[[DOTSINK:%.*]] = phi i64 [ 3, [[FALSE1]] ], [ 2, [[TMP0:%.*]] ]
+; ASSUMPTIONS-ON-NEXT:call void @llvm.assume(i1 true) [ "align"(ptr [[PTR]], i64 8) ]
 ; ASSUMPTIONS-ON-NEXT:store volatile i64 0, ptr [[PTR]], align 8
 ; ASSUMPTIONS-ON-NEXT:store volatile i64 -1, ptr [[PTR]], align 8
 ; ASSUMPTIONS-ON-NEXT:store volatile i64 -1, ptr [[PTR]], align 8
@@ -44,9 +47,6 @@
 ; ASSUMPTIONS-ON-NEXT:store volatile i64 -1, ptr [[PTR]], align 8
 ; ASSUMPTIONS-ON-NEXT:store volatile i64 [[DOTSINK]], ptr [[PTR]], align 8
 ; ASSUMPTIONS-ON-NEXT:ret void
-; ASSUMPTIONS-ON:   false2:
-; ASSUMPTIONS-ON-NEXT:store volatile i64 1, ptr [[PTR]], align 4
-; ASSUMPTIONS-ON-NEXT:br label [[COMMON_RET]]
 ;
   br i1 %c, label %true1, label %false1
 
Index: llvm/test/Transforms/PhaseOrdering/X86/pr52289.ll
===
--- llvm/test/Transforms/PhaseOrdering/X86/pr52289.ll
+++ llvm/test/Transforms/PhaseOrdering/X86/pr52289.ll
@@ -1,11 +1,28 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt -O3 -S < %s | FileCheck %s
 
+; FIXME: see the following issues for background
+; 

[PATCH] D147920: [clang] Add test for CWG399

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

LGTM, apologies, it fell off my radar


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147920

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


[PATCH] D150817: Use windows baskslash on anonymous tag locations if using MSVCFormatting and it's not absolute path.

2023-05-17 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu created this revision.
zequanwu added a reviewer: hans.
Herald added a project: All.
zequanwu requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This fixes a nondeterminism on debug info when building on windows natively vs
cross building to windows.

[1] 
https://github.com/llvm/llvm-project/blob/llvmorg-17-init/clang/lib/Lex/HeaderSearch.cpp#L465


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150817

Files:
  clang/lib/AST/TypePrinter.cpp
  clang/test/CodeGen/Inputs/debug-info-slash.cpp
  clang/test/CodeGen/Inputs/debug-info-slash.h
  clang/test/CodeGen/debug-info-slash.test


Index: clang/test/CodeGen/debug-info-slash.test
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-slash.test
@@ -0,0 +1,10 @@
+RUN: rm -rf %t-dir
+RUN: mkdir -p %t-dir/header/Inputs
+RUN: cp %S/Inputs/debug-info-slash.cpp %t-dir/
+RUN: cp %S/Inputs/debug-info-slash.h %t-dir/header/Inputs
+RUN: cd %t-dir
+RUN: %clang -target x86_64-pc-win32 -emit-llvm -S -g  
%t-dir/debug-info-slash.cpp -Iheader -o - | FileCheck --check-prefix=WIN %s
+RUN: %clang -target x86_64-linux-gnu -emit-llvm -S -g  
%t-dir/debug-info-slash.cpp -Iheader -o - | FileCheck --check-prefix=LINUX %s
+
+WIN:   lambda at header\\Inputs\\debug-info-slash.h
+LINUX: lambda at header/Inputs/debug-info-slash.h
Index: clang/test/CodeGen/Inputs/debug-info-slash.h
===
--- /dev/null
+++ clang/test/CodeGen/Inputs/debug-info-slash.h
@@ -0,0 +1,6 @@
+template 
+void f1() {}
+void a() {
+  auto Lambda = [] {};
+  f1();
+}
Index: clang/test/CodeGen/Inputs/debug-info-slash.cpp
===
--- /dev/null
+++ clang/test/CodeGen/Inputs/debug-info-slash.cpp
@@ -0,0 +1,2 @@
+#include "Inputs/debug-info-slash.h"
+int main() { a(); return 0; }
Index: clang/lib/AST/TypePrinter.cpp
===
--- clang/lib/AST/TypePrinter.cpp
+++ clang/lib/AST/TypePrinter.cpp
@@ -1385,11 +1385,18 @@
   if (PLoc.isValid()) {
 OS << " at ";
 StringRef File = PLoc.getFilename();
+llvm::SmallString<1024> WrittenFile(File);
 if (auto *Callbacks = Policy.Callbacks)
-  OS << Callbacks->remapPath(File);
-else
-  OS << File;
-OS << ':' << PLoc.getLine() << ':' << PLoc.getColumn();
+  WrittenFile = Callbacks->remapPath(File);
+// The following tries to fix inconsistent path separator created by
+// clang::DirectoryLookup::LookupFile when the file path is relative
+// path.
+llvm::sys::path::Style Style =
+!llvm::sys::path::is_absolute(WrittenFile) && Policy.MSVCFormatting
+? llvm::sys::path::Style::windows_backslash
+: llvm::sys::path::Style::native;
+llvm::sys::path::native(WrittenFile, Style);
+OS << WrittenFile << ':' << PLoc.getLine() << ':' << PLoc.getColumn();
   }
 }
 


Index: clang/test/CodeGen/debug-info-slash.test
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-slash.test
@@ -0,0 +1,10 @@
+RUN: rm -rf %t-dir
+RUN: mkdir -p %t-dir/header/Inputs
+RUN: cp %S/Inputs/debug-info-slash.cpp %t-dir/
+RUN: cp %S/Inputs/debug-info-slash.h %t-dir/header/Inputs
+RUN: cd %t-dir
+RUN: %clang -target x86_64-pc-win32 -emit-llvm -S -g  %t-dir/debug-info-slash.cpp -Iheader -o - | FileCheck --check-prefix=WIN %s
+RUN: %clang -target x86_64-linux-gnu -emit-llvm -S -g  %t-dir/debug-info-slash.cpp -Iheader -o - | FileCheck --check-prefix=LINUX %s
+
+WIN:   lambda at header\\Inputs\\debug-info-slash.h
+LINUX: lambda at header/Inputs/debug-info-slash.h
Index: clang/test/CodeGen/Inputs/debug-info-slash.h
===
--- /dev/null
+++ clang/test/CodeGen/Inputs/debug-info-slash.h
@@ -0,0 +1,6 @@
+template 
+void f1() {}
+void a() {
+  auto Lambda = [] {};
+  f1();
+}
Index: clang/test/CodeGen/Inputs/debug-info-slash.cpp
===
--- /dev/null
+++ clang/test/CodeGen/Inputs/debug-info-slash.cpp
@@ -0,0 +1,2 @@
+#include "Inputs/debug-info-slash.h"
+int main() { a(); return 0; }
Index: clang/lib/AST/TypePrinter.cpp
===
--- clang/lib/AST/TypePrinter.cpp
+++ clang/lib/AST/TypePrinter.cpp
@@ -1385,11 +1385,18 @@
   if (PLoc.isValid()) {
 OS << " at ";
 StringRef File = PLoc.getFilename();
+llvm::SmallString<1024> WrittenFile(File);
 if (auto *Callbacks = Policy.Callbacks)
-  OS << Callbacks->remapPath(File);
-else
-  OS << File;
-OS << ':' << PLoc.getLine() << ':' << PLoc.getColumn();
+  WrittenFile = Callbacks->remapPath(File);

[PATCH] D100394: [Clang][NVPTX] Add NVPTX intrinsics and builtins for CUDA PTX cp.async instructions

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

Hi. It looks like CUDA-11+ headers need a variant of cm.async intrinsics which 
provides the optional src_size argument.

I'm planning to add it to the existing intrinsics in NVPTX. It's just a 
heads-up in case you may have existing uses of them that may need to be updated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100394

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


[PATCH] D148094: [clang][CodeGen] Break up TargetInfo.cpp [8/8]

2023-05-17 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 updated this revision to Diff 523163.
barannikov88 added a comment.

Rebase & ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148094

Files:
  clang/docs/UsersManual.rst
  clang/docs/tools/clang-formatted-files.txt
  clang/lib/CodeGen/ABIInfo.cpp
  clang/lib/CodeGen/ABIInfo.h
  clang/lib/CodeGen/ABIInfoImpl.cpp
  clang/lib/CodeGen/ABIInfoImpl.h
  clang/lib/CodeGen/CMakeLists.txt
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/Targets/AArch64.cpp
  clang/lib/CodeGen/Targets/AMDGPU.cpp
  clang/lib/CodeGen/Targets/ARC.cpp
  clang/lib/CodeGen/Targets/ARM.cpp
  clang/lib/CodeGen/Targets/AVR.cpp
  clang/lib/CodeGen/Targets/BPF.cpp
  clang/lib/CodeGen/Targets/CSKY.cpp
  clang/lib/CodeGen/Targets/Hexagon.cpp
  clang/lib/CodeGen/Targets/Lanai.cpp
  clang/lib/CodeGen/Targets/LoongArch.cpp
  clang/lib/CodeGen/Targets/M68k.cpp
  clang/lib/CodeGen/Targets/MSP430.cpp
  clang/lib/CodeGen/Targets/Mips.cpp
  clang/lib/CodeGen/Targets/NVPTX.cpp
  clang/lib/CodeGen/Targets/PNaCl.cpp
  clang/lib/CodeGen/Targets/PPC.cpp
  clang/lib/CodeGen/Targets/RISCV.cpp
  clang/lib/CodeGen/Targets/SPIR.cpp
  clang/lib/CodeGen/Targets/Sparc.cpp
  clang/lib/CodeGen/Targets/SystemZ.cpp
  clang/lib/CodeGen/Targets/TCE.cpp
  clang/lib/CodeGen/Targets/VE.cpp
  clang/lib/CodeGen/Targets/WebAssembly.cpp
  clang/lib/CodeGen/Targets/X86.cpp
  clang/lib/CodeGen/Targets/XCore.cpp
  clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp
  llvm/utils/gn/secondary/clang/lib/CodeGen/BUILD.gn

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


[PATCH] D150215: [clang][CodeGen] Break up TargetInfo.cpp [7/8]

2023-05-17 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 updated this revision to Diff 523161.
barannikov88 added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150215

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h

Index: clang/lib/CodeGen/TargetInfo.h
===
--- clang/lib/CodeGen/TargetInfo.h
+++ clang/lib/CodeGen/TargetInfo.h
@@ -405,6 +405,150 @@
  CodeGen::CodeGenModule ) const;
 };
 
+std::unique_ptr
+createDefaultTargetCodeGenInfo(CodeGenModule );
+
+enum class AArch64ABIKind {
+  AAPCS = 0,
+  DarwinPCS,
+  Win64,
+};
+
+std::unique_ptr
+createAArch64TargetCodeGenInfo(CodeGenModule , AArch64ABIKind Kind);
+
+std::unique_ptr
+createWindowsAArch64TargetCodeGenInfo(CodeGenModule , AArch64ABIKind K);
+
+std::unique_ptr
+createAMDGPUTargetCodeGenInfo(CodeGenModule );
+
+std::unique_ptr
+createARCTargetCodeGenInfo(CodeGenModule );
+
+enum class ARMABIKind {
+  APCS = 0,
+  AAPCS = 1,
+  AAPCS_VFP = 2,
+  AAPCS16_VFP = 3,
+};
+
+std::unique_ptr
+createARMTargetCodeGenInfo(CodeGenModule , ARMABIKind Kind);
+
+std::unique_ptr
+createWindowsARMTargetCodeGenInfo(CodeGenModule , ARMABIKind K);
+
+std::unique_ptr
+createAVRTargetCodeGenInfo(CodeGenModule , unsigned NPR, unsigned NRR);
+
+std::unique_ptr
+createBPFTargetCodeGenInfo(CodeGenModule );
+
+std::unique_ptr
+createCSKYTargetCodeGenInfo(CodeGenModule , unsigned FLen);
+
+std::unique_ptr
+createHexagonTargetCodeGenInfo(CodeGenModule );
+
+std::unique_ptr
+createLanaiTargetCodeGenInfo(CodeGenModule );
+
+std::unique_ptr
+createLoongArchTargetCodeGenInfo(CodeGenModule , unsigned GRLen,
+ unsigned FLen);
+
+std::unique_ptr
+createM68kTargetCodeGenInfo(CodeGenModule );
+
+std::unique_ptr
+createMIPSTargetCodeGenInfo(CodeGenModule , bool IsOS32);
+
+std::unique_ptr
+createMSP430TargetCodeGenInfo(CodeGenModule );
+
+std::unique_ptr
+createNVPTXTargetCodeGenInfo(CodeGenModule );
+
+std::unique_ptr
+createPNaClTargetCodeGenInfo(CodeGenModule );
+
+enum class PPC64_SVR4_ABIKind {
+  ELFv1 = 0,
+  ELFv2,
+};
+
+std::unique_ptr
+createAIXTargetCodeGenInfo(CodeGenModule , bool Is64Bit);
+
+std::unique_ptr
+createPPC32TargetCodeGenInfo(CodeGenModule , bool SoftFloatABI);
+
+std::unique_ptr
+createPPC64TargetCodeGenInfo(CodeGenModule );
+
+std::unique_ptr
+createPPC64_SVR4_TargetCodeGenInfo(CodeGenModule , PPC64_SVR4_ABIKind Kind,
+   bool SoftFloatABI);
+
+std::unique_ptr
+createRISCVTargetCodeGenInfo(CodeGenModule , unsigned XLen, unsigned FLen);
+
+std::unique_ptr
+createCommonSPIRTargetCodeGenInfo(CodeGenModule );
+
+std::unique_ptr
+createSPIRVTargetCodeGenInfo(CodeGenModule );
+
+std::unique_ptr
+createSparcV8TargetCodeGenInfo(CodeGenModule );
+
+std::unique_ptr
+createSparcV9TargetCodeGenInfo(CodeGenModule );
+
+std::unique_ptr
+createSystemZTargetCodeGenInfo(CodeGenModule , bool HasVector,
+   bool SoftFloatABI);
+
+std::unique_ptr
+createTCETargetCodeGenInfo(CodeGenModule );
+
+std::unique_ptr
+createVETargetCodeGenInfo(CodeGenModule );
+
+enum class WebAssemblyABIKind {
+  MVP = 0,
+  ExperimentalMV = 1,
+};
+
+std::unique_ptr
+createWebAssemblyTargetCodeGenInfo(CodeGenModule , WebAssemblyABIKind K);
+
+/// The AVX ABI level for X86 targets.
+enum class X86AVXABILevel {
+  None,
+  AVX,
+  AVX512,
+};
+
+std::unique_ptr createX86_32TargetCodeGenInfo(
+CodeGenModule , bool DarwinVectorABI, bool Win32StructABI,
+unsigned NumRegisterParameters, bool SoftFloatABI);
+
+std::unique_ptr
+createWinX86_32TargetCodeGenInfo(CodeGenModule , bool DarwinVectorABI,
+ bool Win32StructABI,
+ unsigned NumRegisterParameters);
+
+std::unique_ptr
+createX86_64TargetCodeGenInfo(CodeGenModule , X86AVXABILevel AVXLevel);
+
+std::unique_ptr
+createWinX86_64TargetCodeGenInfo(CodeGenModule , X86AVXABILevel AVXLevel);
+
+std::unique_ptr
+createXCoreTargetCodeGenInfo(CodeGenModule );
+
 } // namespace CodeGen
 } // namespace clang
 
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -829,11 +829,6 @@
 // This is a very simple ABI that relies a lot on DefaultABIInfo.
 //===--===//
 
-enum class WebAssemblyABIKind {
-  MVP = 0,
-  ExperimentalMV = 1,
-};
-
 class WebAssemblyABIInfo final : public ABIInfo {
   DefaultABIInfo defaultInfo;
   WebAssemblyABIKind Kind;
@@ -2248,12 +2243,6 @@
 
 
 namespace {
-/// The AVX ABI level for X86 targets.
-enum class X86AVXABILevel {
-  None,
-  AVX,
-  AVX512
-};
 
 /// \p returns the size in bits of the largest (native) vector for \p AVXLevel.
 static unsigned getNativeVectorSizeForAVXABI(X86AVXABILevel 

[PATCH] D150178: [clang][CodeGen] Break up TargetInfo.cpp [6/8]

2023-05-17 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 updated this revision to Diff 523160.
barannikov88 added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150178

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h


Index: clang/lib/CodeGen/TargetInfo.h
===
--- clang/lib/CodeGen/TargetInfo.h
+++ clang/lib/CodeGen/TargetInfo.h
@@ -397,6 +397,12 @@
   virtual llvm::Type *getOpenCLType(CodeGenModule , const Type *T) const {
 return nullptr;
   }
+
+protected:
+  static std::string qualifyWindowsLibrary(StringRef Lib);
+
+  void addStackProbeTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
+ CodeGen::CodeGenModule ) const;
 };
 
 } // namespace CodeGen
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -2561,6 +2561,7 @@
 const FunctionDecl *Callee,
 const CallArgList ) const override;
 };
+} // namespace
 
 static void initFeatureMaps(const ASTContext ,
 llvm::StringMap ,
@@ -2659,7 +2660,7 @@
   }
 }
 
-static std::string qualifyWindowsLibrary(llvm::StringRef Lib) {
+std::string TargetCodeGenInfo::qualifyWindowsLibrary(StringRef Lib) {
   // If the argument does not end in .lib, automatically add the suffix.
   // If the argument contains a space, enclose it in quotes.
   // This matches the behavior of MSVC.
@@ -2672,6 +2673,7 @@
   return ArgStr;
 }
 
+namespace {
 class WinX86_32TargetCodeGenInfo : public X86_32TargetCodeGenInfo {
 public:
   WinX86_32TargetCodeGenInfo(CodeGen::CodeGenTypes ,
@@ -2695,11 +2697,11 @@
 Opt = "/FAILIFMISMATCH:\"" + Name.str() + "=" + Value.str() + "\"";
   }
 };
+} // namespace
 
-static void addStackProbeTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
-  CodeGen::CodeGenModule ) {
+void TargetCodeGenInfo::addStackProbeTargetAttributes(
+const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule ) const {
   if (llvm::Function *Fn = dyn_cast_or_null(GV)) {
-
 if (CGM.getCodeGenOpts().StackProbeSize != 4096)
   Fn->addFnAttr("stack-probe-size",
 llvm::utostr(CGM.getCodeGenOpts().StackProbeSize));
@@ -2716,6 +2718,7 @@
   addStackProbeTargetAttributes(D, GV, CGM);
 }
 
+namespace {
 class WinX86_64TargetCodeGenInfo : public TargetCodeGenInfo {
 public:
   WinX86_64TargetCodeGenInfo(CodeGen::CodeGenTypes ,
@@ -2754,6 +2757,7 @@
 Opt = "/FAILIFMISMATCH:\"" + Name.str() + "=" + Value.str() + "\"";
   }
 };
+} // namespace
 
 void WinX86_64TargetCodeGenInfo::setTargetAttributes(
 const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule ) const {
@@ -2771,7 +2775,6 @@
 
   addStackProbeTargetAttributes(D, GV, CGM);
 }
-}
 
 void X86_64ABIInfo::postMerge(unsigned AggregateSize, Class ,
   Class ) const {


Index: clang/lib/CodeGen/TargetInfo.h
===
--- clang/lib/CodeGen/TargetInfo.h
+++ clang/lib/CodeGen/TargetInfo.h
@@ -397,6 +397,12 @@
   virtual llvm::Type *getOpenCLType(CodeGenModule , const Type *T) const {
 return nullptr;
   }
+
+protected:
+  static std::string qualifyWindowsLibrary(StringRef Lib);
+
+  void addStackProbeTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
+ CodeGen::CodeGenModule ) const;
 };
 
 } // namespace CodeGen
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -2561,6 +2561,7 @@
 const FunctionDecl *Callee,
 const CallArgList ) const override;
 };
+} // namespace
 
 static void initFeatureMaps(const ASTContext ,
 llvm::StringMap ,
@@ -2659,7 +2660,7 @@
   }
 }
 
-static std::string qualifyWindowsLibrary(llvm::StringRef Lib) {
+std::string TargetCodeGenInfo::qualifyWindowsLibrary(StringRef Lib) {
   // If the argument does not end in .lib, automatically add the suffix.
   // If the argument contains a space, enclose it in quotes.
   // This matches the behavior of MSVC.
@@ -2672,6 +2673,7 @@
   return ArgStr;
 }
 
+namespace {
 class WinX86_32TargetCodeGenInfo : public X86_32TargetCodeGenInfo {
 public:
   WinX86_32TargetCodeGenInfo(CodeGen::CodeGenTypes ,
@@ -2695,11 +2697,11 @@
 Opt = "/FAILIFMISMATCH:\"" + Name.str() + "=" + Value.str() + "\"";
   }
 };
+} // namespace
 
-static void addStackProbeTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
-  CodeGen::CodeGenModule ) {
+void TargetCodeGenInfo::addStackProbeTargetAttributes(
+const Decl 

[PATCH] D148093: [clang][CodeGen] Break up TargetInfo.cpp [5/8]

2023-05-17 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 updated this revision to Diff 523159.
barannikov88 added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148093

Files:
  clang/lib/CodeGen/ABIInfo.h
  clang/lib/CodeGen/TargetInfo.cpp


Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -125,7 +125,7 @@
 /// registers when expanded?
 ///
 /// This is intended to be the basis of a reasonable basic implementation
-/// of should{Pass,Return}IndirectlyForSwift.
+/// of should{Pass,Return}Indirectly.
 ///
 /// For most targets, a limit of four total registers is reasonable; this
 /// limits the amount of code required in order to move around the value
@@ -134,15 +134,14 @@
 /// immediately within the callee.  But some targets may need to further
 /// limit the register count due to an inability to support that many
 /// return registers.
-static bool occupiesMoreThan(CodeGenTypes ,
- ArrayRef scalarTypes,
- unsigned maxAllRegisters) {
+bool SwiftABIInfo::occupiesMoreThan(ArrayRef scalarTypes,
+unsigned maxAllRegisters) const {
   unsigned intCount = 0, fpCount = 0;
   for (llvm::Type *type : scalarTypes) {
 if (type->isPointerTy()) {
   intCount++;
 } else if (auto intTy = dyn_cast(type)) {
-  auto ptrWidth = cgt.getTarget().getPointerWidth(LangAS::Default);
+  auto ptrWidth = CGT.getTarget().getPointerWidth(LangAS::Default);
   intCount += (intTy->getBitWidth() + ptrWidth - 1) / ptrWidth;
 } else {
   assert(type->isVectorTy() || type->isFloatingPointTy());
@@ -155,7 +154,7 @@
 
 bool SwiftABIInfo::shouldPassIndirectly(ArrayRef ComponentTys,
 bool AsReturnValue) const {
-  return occupiesMoreThan(CGT, ComponentTys, /*total=*/4);
+  return occupiesMoreThan(ComponentTys, /*total=*/4);
 }
 
 bool SwiftABIInfo::isLegalVectorType(CharUnits VectorSize, llvm::Type *EltTy,
@@ -1248,7 +1247,7 @@
 // integer registers and three fp registers.  Oddly, it'll use up to
 // four vector registers for vectors, but those can overlap with the
 // scalar registers.
-return occupiesMoreThan(CGT, ComponentTys, /*total=*/3);
+return occupiesMoreThan(ComponentTys, /*total=*/3);
   }
 };
 
Index: clang/lib/CodeGen/ABIInfo.h
===
--- clang/lib/CodeGen/ABIInfo.h
+++ clang/lib/CodeGen/ABIInfo.h
@@ -120,6 +120,9 @@
 CodeGenTypes 
 bool SwiftErrorInRegister;
 
+bool occupiesMoreThan(ArrayRef scalarTypes,
+  unsigned maxAllRegisters) const;
+
   public:
 SwiftABIInfo(CodeGen::CodeGenTypes , bool SwiftErrorInRegister)
 : CGT(CGT), SwiftErrorInRegister(SwiftErrorInRegister) {}


Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -125,7 +125,7 @@
 /// registers when expanded?
 ///
 /// This is intended to be the basis of a reasonable basic implementation
-/// of should{Pass,Return}IndirectlyForSwift.
+/// of should{Pass,Return}Indirectly.
 ///
 /// For most targets, a limit of four total registers is reasonable; this
 /// limits the amount of code required in order to move around the value
@@ -134,15 +134,14 @@
 /// immediately within the callee.  But some targets may need to further
 /// limit the register count due to an inability to support that many
 /// return registers.
-static bool occupiesMoreThan(CodeGenTypes ,
- ArrayRef scalarTypes,
- unsigned maxAllRegisters) {
+bool SwiftABIInfo::occupiesMoreThan(ArrayRef scalarTypes,
+unsigned maxAllRegisters) const {
   unsigned intCount = 0, fpCount = 0;
   for (llvm::Type *type : scalarTypes) {
 if (type->isPointerTy()) {
   intCount++;
 } else if (auto intTy = dyn_cast(type)) {
-  auto ptrWidth = cgt.getTarget().getPointerWidth(LangAS::Default);
+  auto ptrWidth = CGT.getTarget().getPointerWidth(LangAS::Default);
   intCount += (intTy->getBitWidth() + ptrWidth - 1) / ptrWidth;
 } else {
   assert(type->isVectorTy() || type->isFloatingPointTy());
@@ -155,7 +154,7 @@
 
 bool SwiftABIInfo::shouldPassIndirectly(ArrayRef ComponentTys,
 bool AsReturnValue) const {
-  return occupiesMoreThan(CGT, ComponentTys, /*total=*/4);
+  return occupiesMoreThan(ComponentTys, /*total=*/4);
 }
 
 bool SwiftABIInfo::isLegalVectorType(CharUnits VectorSize, llvm::Type *EltTy,
@@ -1248,7 +1247,7 @@
 // integer registers and three fp registers.  Oddly, it'll use up to
 // four vector registers for vectors, but those can overlap 

[PATCH] D148092: [clang][CodeGen] Break up TargetInfo.cpp [4/8]

2023-05-17 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 updated this revision to Diff 523158.
barannikov88 added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148092

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h

Index: clang/lib/CodeGen/TargetInfo.h
===
--- clang/lib/CodeGen/TargetInfo.h
+++ clang/lib/CodeGen/TargetInfo.h
@@ -52,6 +52,11 @@
   // by returning true from TargetInfo::checkCallingConvention for them.
   std::unique_ptr SwiftInfo;
 
+  // Returns ABI info helper for the target. This is for use by derived classes.
+  template  const T () const {
+return static_cast(*Info);
+  }
+
 public:
   TargetCodeGenInfo(std::unique_ptr Info);
   virtual ~TargetCodeGenInfo();
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -2485,10 +2485,6 @@
 std::make_unique(CGT, /*SwiftErrorInRegister=*/true);
   }
 
-  const X86_64ABIInfo () const {
-return static_cast(TargetCodeGenInfo::getABIInfo());
-  }
-
   /// Disable tail call on x86-64. The epilogue code before the tail jump blocks
   /// autoreleaseRV/retainRV and autoreleaseRV/unsafeClaimRV optimizations.
   bool markARCOptimizedReturnCallsAsNoTail() const override { return true; }
@@ -2525,7 +2521,7 @@
   bool HasAVXType = false;
   for (CallArgList::const_iterator
  it = args.begin(), ie = args.end(); it != ie; ++it) {
-if (getABIInfo().isPassedUsingAVXType(it->Ty)) {
+if (getABIInfo().isPassedUsingAVXType(it->Ty)) {
   HasAVXType = true;
   break;
 }
@@ -6406,10 +6402,6 @@
 SwiftInfo = std::make_unique(CGT);
   }
 
-  const ARMABIInfo () const {
-return static_cast(TargetCodeGenInfo::getABIInfo());
-  }
-
   int getDwarfEHStackPointer(CodeGen::CodeGenModule ) const override {
 return 13;
   }
@@ -6428,7 +6420,8 @@
   }
 
   unsigned getSizeOfUnwindException() const override {
-if (getABIInfo().isEABI()) return 88;
+if (getABIInfo().isEABI())
+  return 88;
 return TargetCodeGenInfo::getSizeOfUnwindException();
   }
 
@@ -6495,7 +6488,7 @@
 
 Fn->addFnAttr("interrupt", Kind);
 
-ARMABIKind ABI = cast(getABIInfo()).getABIKind();
+ARMABIKind ABI = getABIInfo().getABIKind();
 if (ABI == ARMABIKind::APCS)
   return;
 
@@ -7433,10 +7426,6 @@
 class SystemZTargetCodeGenInfo : public TargetCodeGenInfo {
   ASTContext 
 
-  const SystemZABIInfo () const {
-return static_cast(TargetCodeGenInfo::getABIInfo());
-  }
-
   // These are used for speeding up the search for a visible vector ABI.
   mutable bool HasVisibleVecABIFlag = false;
   mutable std::set SeenTypes;
@@ -7885,8 +7874,9 @@
 // it will be passed in a vector register. A wide (>16 bytes) vector will
 // be passed via "hidden" pointer where any extra alignment is not
 // required (per GCC).
-const Type *SingleEltTy =
-  getABIInfo().GetSingleElementType(QualType(Ty, 0)).getTypePtr();
+const Type *SingleEltTy = getABIInfo()
+  .GetSingleElementType(QualType(Ty, 0))
+  .getTypePtr();
 bool SingleVecEltStruct = SingleEltTy != Ty && SingleEltTy->isVectorType() &&
   Ctx.getTypeSize(SingleEltTy) == Ctx.getTypeSize(Ty);
 if (Ty->isVectorType() || SingleVecEltStruct)
@@ -11859,10 +11849,6 @@
 public:
   BPFTargetCodeGenInfo(CodeGenTypes )
   : TargetCodeGenInfo(std::make_unique(CGT)) {}
-
-  const BPFABIInfo () const {
-return static_cast(TargetCodeGenInfo::getABIInfo());
-  }
 };
 
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D148091: [clang][CodeGen] Break up TargetInfo.cpp [3/8]

2023-05-17 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 updated this revision to Diff 523157.
barannikov88 added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148091

Files:
  clang/lib/CodeGen/TargetInfo.cpp


Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -5067,9 +5067,10 @@
llvm::Value *Address) const override;
 };
 
-class PPC64TargetCodeGenInfo : public DefaultTargetCodeGenInfo {
+class PPC64TargetCodeGenInfo : public TargetCodeGenInfo {
 public:
-  PPC64TargetCodeGenInfo(CodeGenTypes ) : DefaultTargetCodeGenInfo(CGT) {}
+  PPC64TargetCodeGenInfo(CodeGenTypes )
+  : TargetCodeGenInfo(std::make_unique(CGT)) {}
 
   int getDwarfEHStackPointer(CodeGen::CodeGenModule ) const override {
 // This is recovered from gcc output.
@@ -5079,7 +5080,6 @@
   bool initDwarfEHRegSizeTable(CodeGen::CodeGenFunction ,
llvm::Value *Address) const override;
 };
-
 }
 
 // Return true if the ABI requires Ty to be passed sign- or zero-
@@ -8602,10 +8602,10 @@
 
 namespace {
 
-class TCETargetCodeGenInfo : public DefaultTargetCodeGenInfo {
+class TCETargetCodeGenInfo : public TargetCodeGenInfo {
 public:
   TCETargetCodeGenInfo(CodeGenTypes )
-: DefaultTargetCodeGenInfo(CGT) {}
+  : TargetCodeGenInfo(std::make_unique(CGT)) {}
 
   void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
CodeGen::CodeGenModule ) const override;


Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -5067,9 +5067,10 @@
llvm::Value *Address) const override;
 };
 
-class PPC64TargetCodeGenInfo : public DefaultTargetCodeGenInfo {
+class PPC64TargetCodeGenInfo : public TargetCodeGenInfo {
 public:
-  PPC64TargetCodeGenInfo(CodeGenTypes ) : DefaultTargetCodeGenInfo(CGT) {}
+  PPC64TargetCodeGenInfo(CodeGenTypes )
+  : TargetCodeGenInfo(std::make_unique(CGT)) {}
 
   int getDwarfEHStackPointer(CodeGen::CodeGenModule ) const override {
 // This is recovered from gcc output.
@@ -5079,7 +5080,6 @@
   bool initDwarfEHRegSizeTable(CodeGen::CodeGenFunction ,
llvm::Value *Address) const override;
 };
-
 }
 
 // Return true if the ABI requires Ty to be passed sign- or zero-
@@ -8602,10 +8602,10 @@
 
 namespace {
 
-class TCETargetCodeGenInfo : public DefaultTargetCodeGenInfo {
+class TCETargetCodeGenInfo : public TargetCodeGenInfo {
 public:
   TCETargetCodeGenInfo(CodeGenTypes )
-: DefaultTargetCodeGenInfo(CGT) {}
+  : TargetCodeGenInfo(std::make_unique(CGT)) {}
 
   void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
CodeGen::CodeGenModule ) const override;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D148090: [clang][CodeGen] Break up TargetInfo.cpp [2/8]

2023-05-17 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 updated this revision to Diff 523155.
barannikov88 added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148090

Files:
  clang/lib/CodeGen/TargetInfo.cpp

Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -830,19 +830,18 @@
 // This is a very simple ABI that relies a lot on DefaultABIInfo.
 //===--===//
 
-class WebAssemblyABIInfo final : public ABIInfo {
-public:
-  enum ABIKind {
-MVP = 0,
-ExperimentalMV = 1,
-  };
+enum class WebAssemblyABIKind {
+  MVP = 0,
+  ExperimentalMV = 1,
+};
 
-private:
+class WebAssemblyABIInfo final : public ABIInfo {
   DefaultABIInfo defaultInfo;
-  ABIKind Kind;
+  WebAssemblyABIKind Kind;
 
 public:
-  explicit WebAssemblyABIInfo(CodeGen::CodeGenTypes , ABIKind Kind)
+  explicit WebAssemblyABIInfo(CodeGen::CodeGenTypes ,
+  WebAssemblyABIKind Kind)
   : ABIInfo(CGT), defaultInfo(CGT), Kind(Kind) {}
 
 private:
@@ -866,7 +865,7 @@
 class WebAssemblyTargetCodeGenInfo final : public TargetCodeGenInfo {
 public:
   explicit WebAssemblyTargetCodeGenInfo(CodeGen::CodeGenTypes ,
-WebAssemblyABIInfo::ABIKind K)
+WebAssemblyABIKind K)
   : TargetCodeGenInfo(std::make_unique(CGT, K)) {
 SwiftInfo =
 std::make_unique(CGT, /*SwiftErrorInRegister=*/false);
@@ -931,7 +930,7 @@
 if (const Type *SeltTy = isSingleElementStruct(Ty, getContext()))
   return ABIArgInfo::getDirect(CGT.ConvertType(QualType(SeltTy, 0)));
 // For the experimental multivalue ABI, fully expand all other aggregates
-if (Kind == ABIKind::ExperimentalMV) {
+if (Kind == WebAssemblyABIKind::ExperimentalMV) {
   const RecordType *RT = Ty->getAs();
   assert(RT);
   bool HasBitField = false;
@@ -964,7 +963,7 @@
   if (const Type *SeltTy = isSingleElementStruct(RetTy, getContext()))
 return ABIArgInfo::getDirect(CGT.ConvertType(QualType(SeltTy, 0)));
   // For the experimental multivalue ABI, return all other aggregates
-  if (Kind == ABIKind::ExperimentalMV)
+  if (Kind == WebAssemblyABIKind::ExperimentalMV)
 return ABIArgInfo::getDirect();
 }
   }
@@ -4991,21 +4990,19 @@
 // PowerPC-64
 
 namespace {
+enum class PPC64_SVR4_ABIKind {
+  ELFv1 = 0,
+  ELFv2,
+};
+
 /// PPC64_SVR4_ABIInfo - The 64-bit PowerPC ELF (SVR4) ABI information.
 class PPC64_SVR4_ABIInfo : public ABIInfo {
-public:
-  enum ABIKind {
-ELFv1 = 0,
-ELFv2
-  };
-
-private:
   static const unsigned GPRBits = 64;
-  ABIKind Kind;
+  PPC64_SVR4_ABIKind Kind;
   bool IsSoftFloatABI;
 
 public:
-  PPC64_SVR4_ABIInfo(CodeGen::CodeGenTypes , ABIKind Kind,
+  PPC64_SVR4_ABIInfo(CodeGen::CodeGenTypes , PPC64_SVR4_ABIKind Kind,
  bool SoftFloatABI)
   : ABIInfo(CGT), Kind(Kind), IsSoftFloatABI(SoftFloatABI) {}
 
@@ -5053,8 +5050,7 @@
 class PPC64_SVR4_TargetCodeGenInfo : public TargetCodeGenInfo {
 
 public:
-  PPC64_SVR4_TargetCodeGenInfo(CodeGenTypes ,
-   PPC64_SVR4_ABIInfo::ABIKind Kind,
+  PPC64_SVR4_TargetCodeGenInfo(CodeGenTypes , PPC64_SVR4_ABIKind Kind,
bool SoftFloatABI)
   : TargetCodeGenInfo(
 std::make_unique(CGT, Kind, SoftFloatABI)) {
@@ -5153,7 +5149,7 @@
   // Likewise for ELFv2 homogeneous aggregates.
   const Type *Base = nullptr;
   uint64_t Members = 0;
-  if (!AlignAsType && Kind == ELFv2 &&
+  if (!AlignAsType && Kind == PPC64_SVR4_ABIKind::ELFv2 &&
   isAggregateTypeForABI(Ty) && isHomogeneousAggregate(Ty, Base, Members))
 AlignAsType = Base;
 
@@ -5347,7 +5343,7 @@
 // ELFv2 homogeneous aggregates are passed as array types.
 const Type *Base = nullptr;
 uint64_t Members = 0;
-if (Kind == ELFv2 &&
+if (Kind == PPC64_SVR4_ABIKind::ELFv2 &&
 isHomogeneousAggregate(Ty, Base, Members)) {
   llvm::Type *BaseTy = CGT.ConvertType(QualType(Base, 0));
   llvm::Type *CoerceTy = llvm::ArrayType::get(BaseTy, Members);
@@ -5417,7 +5413,7 @@
 // ELFv2 homogeneous aggregates are returned as array types.
 const Type *Base = nullptr;
 uint64_t Members = 0;
-if (Kind == ELFv2 &&
+if (Kind == PPC64_SVR4_ABIKind::ELFv2 &&
 isHomogeneousAggregate(RetTy, Base, Members)) {
   llvm::Type *BaseTy = CGT.ConvertType(QualType(Base, 0));
   llvm::Type *CoerceTy = llvm::ArrayType::get(BaseTy, Members);
@@ -5426,7 +5422,7 @@
 
 // ELFv2 small aggregates are returned in up to two registers.
 uint64_t Bits = getContext().getTypeSize(RetTy);
-if (Kind == ELFv2 && Bits <= 2 * GPRBits) {
+if (Kind == PPC64_SVR4_ABIKind::ELFv2 && Bits <= 2 * GPRBits) {

[PATCH] D144509: [CMake] Bumps minimum version to 3.20.0.

2023-05-17 Thread Mike Hommey via Phabricator via cfe-commits
glandium added a comment.

In D144509#4349051 , @hans wrote:

> In D144509#4347562 , @glandium 
> wrote:
>
>> FYI, 65429b9af6a2c99d340ab2dcddd41dab201f399c 
>>  is 
>> causing problems on Windows compiler-rt for some reason I haven't identified 
>> yet (with cmake 3.25.1). Which suggests for a same version of cmake, this is 
>> actually altering its behavior, which I wouldn't have expected...
>
> It is indeed unfortunate that this seems to come with such a fundamental 
> behavior change. (we already have 
> https://github.com/llvm/llvm-project/issues/62719) Do you have a repro for 
> the issue you're seeing?

The Chromium issue that is discussed there is essentially the same thing I was 
seeing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144509

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


[PATCH] D148089: [clang][CodeGen] Break up TargetInfo.cpp [1/8]

2023-05-17 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 updated this revision to Diff 523153.
barannikov88 added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148089

Files:
  clang/lib/CodeGen/TargetInfo.cpp


Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -9074,13 +9074,17 @@
 
 namespace {
 class LanaiABIInfo : public DefaultABIInfo {
+  struct CCState {
+unsigned FreeRegs;
+  };
+
 public:
   LanaiABIInfo(CodeGen::CodeGenTypes ) : DefaultABIInfo(CGT) {}
 
   bool shouldUseInReg(QualType Ty, CCState ) const;
 
   void computeInfo(CGFunctionInfo ) const override {
-CCState State(FI);
+CCState State;
 // Lanai uses 4 registers to pass arguments unless the function has the
 // regparm attribute set.
 if (FI.getHasRegParm()) {
@@ -10092,6 +10096,10 @@
 namespace {
 
 class ARCABIInfo : public DefaultABIInfo {
+  struct CCState {
+unsigned FreeRegs;
+  };
+
 public:
   using DefaultABIInfo::DefaultABIInfo;
 
@@ -10114,7 +10122,7 @@
   }
 
   void computeInfo(CGFunctionInfo ) const override {
-CCState State(FI);
+CCState State;
 // ARC uses 8 registers to pass arguments.
 State.FreeRegs = 8;
 


Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -9074,13 +9074,17 @@
 
 namespace {
 class LanaiABIInfo : public DefaultABIInfo {
+  struct CCState {
+unsigned FreeRegs;
+  };
+
 public:
   LanaiABIInfo(CodeGen::CodeGenTypes ) : DefaultABIInfo(CGT) {}
 
   bool shouldUseInReg(QualType Ty, CCState ) const;
 
   void computeInfo(CGFunctionInfo ) const override {
-CCState State(FI);
+CCState State;
 // Lanai uses 4 registers to pass arguments unless the function has the
 // regparm attribute set.
 if (FI.getHasRegParm()) {
@@ -10092,6 +10096,10 @@
 namespace {
 
 class ARCABIInfo : public DefaultABIInfo {
+  struct CCState {
+unsigned FreeRegs;
+  };
+
 public:
   using DefaultABIInfo::DefaultABIInfo;
 
@@ -10114,7 +10122,7 @@
   }
 
   void computeInfo(CGFunctionInfo ) const override {
-CCState State(FI);
+CCState State;
 // ARC uses 8 registers to pass arguments.
 State.FreeRegs = 8;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150733: [clang] Convert remaining OpenMP tests to opaque pointers

2023-05-17 Thread Sergei Barannikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8be4bd16ca41: [clang] Convert remaining OpenMP tests to 
opaque pointers (authored by barannikov88).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150733

Files:
  clang/test/OpenMP/declare_reduction_codegen.cpp
  clang/test/OpenMP/parallel_for_simd_codegen.cpp
  clang/test/OpenMP/simd_codegen.cpp
  clang/test/OpenMP/target_codegen.cpp
  clang/test/OpenMP/target_data_codegen.cpp
  clang/test/OpenMP/target_enter_data_codegen.cpp
  clang/test/OpenMP/target_enter_data_depend_codegen.cpp
  clang/test/OpenMP/target_exit_data_codegen.cpp
  clang/test/OpenMP/target_exit_data_depend_codegen.cpp
  clang/test/OpenMP/target_in_reduction_codegen.cpp
  clang/test/OpenMP/target_private_codegen.cpp
  clang/test/OpenMP/target_reduction_codegen.cpp
  clang/test/OpenMP/target_simd_codegen.cpp
  clang/test/OpenMP/target_update_depend_codegen.cpp

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


[PATCH] D150670: [WebAssembly] Disable generation of fshl/fshr for rotates

2023-05-17 Thread Paulo Matos via Phabricator via cfe-commits
pmatos added a comment.

Ready for review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150670

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


[PATCH] D150670: [WebAssembly] Disable generation of fshl/fshr for rotates

2023-05-17 Thread Paulo Matos via Phabricator via cfe-commits
pmatos updated this revision to Diff 523149.
pmatos added a comment.

Generate rotates for 64bits as well. Add tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150670

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/WebAssembly/wasm-rotate.c
  llvm/include/llvm/IR/IntrinsicsWebAssembly.td
  llvm/lib/Target/WebAssembly/WebAssemblyInstrInteger.td
  llvm/test/CodeGen/WebAssembly/rotate-i3264.ll

Index: llvm/test/CodeGen/WebAssembly/rotate-i3264.ll
===
--- /dev/null
+++ llvm/test/CodeGen/WebAssembly/rotate-i3264.ll
@@ -0,0 +1,46 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
+; RUN: sed 's/iX/i32/g' %s | llc --mtriple=wasm32-unknown-unknown | FileCheck --check-prefix=I32 %s
+; RUN: sed 's/iX/i64/g' %s | llc --mtriple=wasm64-unknown-unknown | FileCheck --check-prefix=I64 %s
+
+declare iX @llvm.wasm.rotl.iX(iX, iX) nounwind
+declare iX @llvm.wasm.rotr.iX(iX, iX) nounwind
+
+define iX @testLeft(iX noundef %0, iX noundef %1) {
+; I32-LABEL: testLeft:
+; I32: .functype testLeft (i32, i32) -> (i32)
+; I32-NEXT:  # %bb.0:
+; I32-NEXT:local.get 0
+; I32-NEXT:local.get 1
+; I32-NEXT:i32.rotl
+; I32-NEXT:# fallthrough-return
+;
+; I64-LABEL: testLeft:
+; I64: .functype testLeft (i64, i64) -> (i64)
+; I64-NEXT:  # %bb.0:
+; I64-NEXT:local.get 0
+; I64-NEXT:local.get 1
+; I64-NEXT:i64.rotl
+; I64-NEXT:# fallthrough-return
+  %3 = call iX @llvm.wasm.rotl.iX(iX %0, iX %1)
+  ret iX %3
+}
+
+define iX @testRight(iX noundef %0, iX noundef %1) {
+; I32-LABEL: testRight:
+; I32: .functype testRight (i32, i32) -> (i32)
+; I32-NEXT:  # %bb.0:
+; I32-NEXT:local.get 0
+; I32-NEXT:local.get 1
+; I32-NEXT:i32.rotr
+; I32-NEXT:# fallthrough-return
+;
+; I64-LABEL: testRight:
+; I64: .functype testRight (i64, i64) -> (i64)
+; I64-NEXT:  # %bb.0:
+; I64-NEXT:local.get 0
+; I64-NEXT:local.get 1
+; I64-NEXT:i64.rotr
+; I64-NEXT:# fallthrough-return
+  %3 = call iX @llvm.wasm.rotr.iX(iX %0, iX %1)
+  ret iX %3
+}
Index: llvm/lib/Target/WebAssembly/WebAssemblyInstrInteger.td
===
--- llvm/lib/Target/WebAssembly/WebAssemblyInstrInteger.td
+++ llvm/lib/Target/WebAssembly/WebAssemblyInstrInteger.td
@@ -107,6 +107,16 @@
 def : Pat<(rotl I64:$lhs, (and I64:$rhs, 63)), (ROTL_I64 I64:$lhs, I64:$rhs)>;
 def : Pat<(rotr I64:$lhs, (and I64:$rhs, 63)), (ROTR_I64 I64:$lhs, I64:$rhs)>;
 
+// Lower the rotate intrinsic to a rotate instruction
+def : Pat<(int_wasm_rotl_i32 I32:$lhs, I32:$rhs),
+  (ROTL_I32 I32:$lhs, I32:$rhs)>;
+def : Pat<(int_wasm_rotr_i32 I32:$lhs, I32:$rhs),
+  (ROTR_I32 I32:$lhs, I32:$rhs)>;
+def : Pat<(int_wasm_rotl_i64 I64:$lhs, I64:$rhs),
+  (ROTL_I64 I64:$lhs, I64:$rhs)>;
+def : Pat<(int_wasm_rotr_i64 I64:$lhs, I64:$rhs),
+  (ROTR_I64 I64:$lhs, I64:$rhs)>;
+
 defm SELECT_I32 : I<(outs I32:$dst), (ins I32:$lhs, I32:$rhs, I32:$cond),
 (outs), (ins),
 [(set I32:$dst, (select I32:$cond, I32:$lhs, I32:$rhs))],
Index: llvm/include/llvm/IR/IntrinsicsWebAssembly.td
===
--- llvm/include/llvm/IR/IntrinsicsWebAssembly.td
+++ llvm/include/llvm/IR/IntrinsicsWebAssembly.td
@@ -341,4 +341,22 @@
 [],
 [IntrReadMem]>;
 
+//===--===//
+// Rotate Intrinsics
+// These are lowered from the target independent intrinsics to avoid
+// funnel shift optimizations
+//===--===//
+
+def int_wasm_rotl_i32 : 
+  DefaultAttrsIntrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty], [IntrNoMem]>;
+
+def int_wasm_rotr_i32 : 
+  DefaultAttrsIntrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty], [IntrNoMem]>;
+
+def int_wasm_rotl_i64 : 
+  DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i64_ty], [IntrNoMem]>;
+
+def int_wasm_rotr_i64 : 
+  DefaultAttrsIntrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i64_ty], [IntrNoMem]>;
+
 } // TargetPrefix = "wasm"
Index: clang/test/CodeGen/WebAssembly/wasm-rotate.c
===
--- /dev/null
+++ clang/test/CodeGen/WebAssembly/wasm-rotate.c
@@ -0,0 +1,53 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -o - -emit-llvm %s | FileCheck --check-prefix=WEBASSEMBLY32 %s
+// RUN: %clang_cc1 -triple wasm64-unknown-unknown -o - -emit-llvm %s | FileCheck --check-prefix=WEBASSEMBLY64 %s
+
+// WEBASSEMBLY32-LABEL: define i32 @test32
+// WEBASSEMBLY32-SAME: (i32 noundef [[X:%.*]]) 

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

2023-05-17 Thread Vy Nguyen via Phabricator via cfe-commits
oontvoo added a comment.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144999

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


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

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

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144999

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

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

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

2023-05-17 Thread Vy Nguyen via Phabricator via cfe-commits
oontvoo updated this revision to Diff 523147.
oontvoo marked an inline comment as done.
oontvoo edited the summary of this revision.
oontvoo added a comment.

updated comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144999

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

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

[PATCH] D150744: [NFC][CLANG] Fix uninitialized scalar field issues found by Coverity

2023-05-17 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann added a comment.

I'm not opposed to these changes, but please note that these changes mean is 
will no longer be possible to use ubsan to discover when these data members are 
used before having been assigned an appropriate value. That is only a concern 
when an appropriate value would differ from the member initializers added via 
this change. I haven't reviewed the changes in depth, so I don't know if there 
are any such cases for which such a concern is applicable.


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

https://reviews.llvm.org/D150744

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


[PATCH] D150221: Add option -fkeep-static-variables to emit all static variables

2023-05-17 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

In D150221#4350761 , @rjmccall wrote:

> I'm not sure if it's better to represent that by using 
> `__attribute__((used))` on every global variable or by setting something more 
> globally in the module.  The latter seems more impervious to the LTO problem, 
> at least.

`__attribute__((__used__))` has the advantage of being something that already 
exists. If the "more global" property can hook in as treating all variables as 
`__attribute__((__used__))` where the query for `__attribute__((__used__))` is 
implemented in the middle-end/back-end (including places where the symbol is 
marked as used with respect to linker garbage collection), then maybe it is not 
too intrusive in terms of implementation.

As for which aspect of `__attribute__((__used__))` is more important: The 
explicit user request we had was for the variables to be kept in an obvious 
manner in the symbol table. It seems multiple aspects of the 
`__attribute__((__used__))` semantics are helpful here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150221

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


[PATCH] D139010: [clang][WebAssembly] Implement support for table types and builtins

2023-05-17 Thread Thomas Lively via Phabricator via cfe-commits
tlively added a comment.

It looks like the LLVM-side changes are generally moving Wasm type 
classification functions to a more global location. Since no other backend 
should care about these things, it would be better if we could get away without 
these changes.




Comment at: llvm/include/llvm/IR/Type.h:23
 #include "llvm/Support/TypeSize.h"
+#include "llvm/CodeGen/WasmAddressSpaces.h"
 #include 

I don't know if things in IR are supposed to depend on things in CodeGen. Is 
there precedent here?



Comment at: llvm/include/llvm/IR/Type.h:220-232
+  bool isWebAssemblyReferenceType() const { return 
isWebAssemblyExternrefType() || isWebAssemblyFuncrefType(); }
+
+  /// Return true if this is a WebAssembly Externref Type.
+  bool isWebAssemblyExternrefType() const {
+return getPointerAddressSpace() ==
+ WebAssembly::WasmAddressSpace::WASM_ADDRESS_SPACE_EXTERNREF;
+  }

Do these need to be in Type.h? If not, it would be good to keep them in a more 
Wasm-specific location.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139010

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


[clang] a825f37 - [CUDA] Relax restrictions on GPU-side variadic functions

2023-05-17 Thread Artem Belevich via cfe-commits

Author: Artem Belevich
Date: 2023-05-17T12:51:01-07:00
New Revision: a825f3754b3ca1591068cf99bc224af30a311e63

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

LOG: [CUDA] Relax restrictions on GPU-side variadic functions

Allow parsing GPU-side variadic functions when we're compiling with CUDA-9 or
newer. We still do not allow accessing variadic arguments.

CUDA-9 was the version which introduced PTX-6.0 which allows implementing
variadic functions, so older versions can't have variadics in principle.

This is required for dealing with headers in recent CUDA versions that rely on
variadic function declarations in some of the templated code in libcu++.
E.g. https://github.com/llvm/llvm-project/issues/58410

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Cuda.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Cuda.cpp 
b/clang/lib/Driver/ToolChains/Cuda.cpp
index 37b0b9c2ed05b..eae5ebdc192b2 100644
--- a/clang/lib/Driver/ToolChains/Cuda.cpp
+++ b/clang/lib/Driver/ToolChains/Cuda.cpp
@@ -800,6 +800,13 @@ void CudaToolChain::addClangTargetOptions(
 if (DriverArgs.hasFlag(options::OPT_fcuda_approx_transcendentals,
options::OPT_fno_cuda_approx_transcendentals, 
false))
   CC1Args.push_back("-fcuda-approx-transcendentals");
+
+// Unsized function arguments used for variadics were introduced in 
CUDA-9.0
+// We still do not support generating code that actually uses variadic
+// arguments yet, but we do need to allow parsing them as recent CUDA
+// headers rely on that. https://github.com/llvm/llvm-project/issues/58410
+if (CudaInstallation.version() >= CudaVersion::CUDA_90)
+  CC1Args.push_back("-fcuda-allow-variadic-functions");
   }
 
   if (DriverArgs.hasArg(options::OPT_nogpulib))



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


[PATCH] D150718: [CUDA] Relax restrictions on GPU-side variadic functions

2023-05-17 Thread Artem Belevich 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 rGa825f3754b3c: [CUDA] Relax restrictions on GPU-side variadic 
functions (authored by tra).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150718

Files:
  clang/lib/Driver/ToolChains/Cuda.cpp


Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -800,6 +800,13 @@
 if (DriverArgs.hasFlag(options::OPT_fcuda_approx_transcendentals,
options::OPT_fno_cuda_approx_transcendentals, 
false))
   CC1Args.push_back("-fcuda-approx-transcendentals");
+
+// Unsized function arguments used for variadics were introduced in 
CUDA-9.0
+// We still do not support generating code that actually uses variadic
+// arguments yet, but we do need to allow parsing them as recent CUDA
+// headers rely on that. https://github.com/llvm/llvm-project/issues/58410
+if (CudaInstallation.version() >= CudaVersion::CUDA_90)
+  CC1Args.push_back("-fcuda-allow-variadic-functions");
   }
 
   if (DriverArgs.hasArg(options::OPT_nogpulib))


Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -800,6 +800,13 @@
 if (DriverArgs.hasFlag(options::OPT_fcuda_approx_transcendentals,
options::OPT_fno_cuda_approx_transcendentals, false))
   CC1Args.push_back("-fcuda-approx-transcendentals");
+
+// Unsized function arguments used for variadics were introduced in CUDA-9.0
+// We still do not support generating code that actually uses variadic
+// arguments yet, but we do need to allow parsing them as recent CUDA
+// headers rely on that. https://github.com/llvm/llvm-project/issues/58410
+if (CudaInstallation.version() >= CudaVersion::CUDA_90)
+  CC1Args.push_back("-fcuda-allow-variadic-functions");
   }
 
   if (DriverArgs.hasArg(options::OPT_nogpulib))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] a07b135 - [Driver][gcov] Derive .gcno .gcda file names from -o and -dumpdir

2023-05-17 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-05-17T12:43:49-07:00
New Revision: a07b135ce0c0111bd83450b5dc29ef0381cdbc39

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

LOG: [Driver][gcov] Derive .gcno .gcda file names from -o and -dumpdir

Resolve a FIXME.
When -ftest-profile, -fprofile-arcs, or --coverage is specified and the
driver performs both compilation and linking phases, derive the .gcno &
.gcda file names from -o and -dumpdir.

`clang --coverage d/a.c d/b.c -o e/x && e/x` will now emit
`e/x-[ab].gc{no,da}` like GCC.

For -fprofile-dir=, we make the deliberate decision to not mangle the
input filename if relative.

The following script demonstrates the .gcno and .gcda filenames.

```
PATH=/tmp/Rel/bin:$PATH# adapt according to your build directory
mkdir -p d e f
echo 'int main() {}' > d/a.c
echo > d/b.c

a() { rm $@ || exit 1; }

clang --coverage d/a.c d/b.c && ./a.out
a a-[ab].gc{no,da}
clang --coverage d/a.c d/b.c -o e/x && e/x
a e/x-[ab].gc{no,da}
clang --coverage d/a.c d/b.c -o e/x -dumpdir f/ && e/x
a f/[ab].gc{no,da}
clang --coverage -fprofile-dir=f d/a.c d/b.c -o e/x && e/x
a e/x-[ab].gcno f/e/x-[ab].gcda

clang -c --coverage d/a.c d/b.c && clang --coverage a.o b.o && ./a.out
a [ab].gc{no,da}
clang -c --coverage -fprofile-dir=f d/a.c d/b.c && clang --coverage a.o b.o && 
./a.out
a [ab].gcno f/[ab].gcda

clang -c --coverage d/a.c -o e/xa.o && clang --coverage e/xa.o && ./a.out
a e/xa.gc{no,da}
clang -c --coverage d/a.c -o e/xa.o -dumpdir f/g && clang --coverage e/xa.o && 
./a.out
a f/ga.gc{no,da}
```

The gcov code accidentally claims -c and -S, so -fsyntax-only -c/-S and
-E -c/-S don't lead to a -Wunused-command-line-argument warning. Keep
the unintended code for now.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/coverage.c
clang/test/Driver/working-directory.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index e2c401218a006..be4fceb793758 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -705,10 +705,10 @@ static void addDashXForInput(const ArgList , const 
InputInfo ,
 }
 
 static void addPGOAndCoverageFlags(const ToolChain , Compilation ,
-   const Driver , const InputInfo ,
+   const JobAction , const InputInfo 
,
const ArgList , SanitizerArgs ,
ArgStringList ) {
-
+  const Driver  = TC.getDriver();
   auto *PGOGenerateArg = Args.getLastArg(options::OPT_fprofile_generate,
  options::OPT_fprofile_generate_EQ,
  options::OPT_fno_profile_generate);
@@ -911,32 +911,39 @@ static void addPGOAndCoverageFlags(const ToolChain , 
Compilation ,
   Args.hasArg(options::OPT_coverage))
 FProfileDir = Args.getLastArg(options::OPT_fprofile_dir);
 
-  // Put the .gcno and .gcda files (if needed) next to the object file or
-  // bitcode file in the case of LTO.
-  // FIXME: There should be a simpler way to find the object file for this
-  // input, and this code probably does the wrong thing for commands that
-  // compile and link all at once.
-  if ((Args.hasArg(options::OPT_c) || Args.hasArg(options::OPT_S)) &&
-  (EmitCovNotes || EmitCovData) && Output.isFilename()) {
-SmallString<128> OutputFilename;
-if (Arg *FinalOutput = C.getArgs().getLastArg(options::OPT__SLASH_Fo))
-  OutputFilename = FinalOutput->getValue();
-else if (Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o))
-  OutputFilename = FinalOutput->getValue();
-else
-  OutputFilename = llvm::sys::path::filename(Output.getBaseInput());
-SmallString<128> CoverageFilename = OutputFilename;
-if (llvm::sys::path::is_relative(CoverageFilename))
-  (void)D.getVFS().makeAbsolute(CoverageFilename);
+  // TODO: Don't claim -c/-S to warn about -fsyntax-only -c/-S, -E -c/-S,
+  // like we warn about -fsyntax-only -E.
+  (void)(Args.hasArg(options::OPT_c) || Args.hasArg(options::OPT_S));
+
+  // Put the .gcno and .gcda files (if needed) next to the primary output file,
+  // or fall back to a file in the current directory for `clang -c --coverage
+  // d/a.c` in the absence of -o.
+  if (EmitCovNotes || EmitCovData) {
+SmallString<128> CoverageFilename;
+if (Arg *DumpDir = Args.getLastArgNoClaim(options::OPT_dumpdir)) {
+  // Form ${dumpdir}${basename}.gcno. Note that dumpdir may not end with a
+  // path separator.
+  CoverageFilename = DumpDir->getValue();
+  CoverageFilename += llvm::sys::path::filename(Output.getBaseInput());
+} else if (Arg *FinalOutput =
+

[PATCH] D146358: [clang][AST] Print name instead of type when diagnosing uninitialized subobject in constexpr variables

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

Slightly smaller reproducer: https://godbolt.org/z/W5zjrKaz9


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146358

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


[PATCH] D146358: [clang][AST] Print name instead of type when diagnosing uninitialized subobject in constexpr variables

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

Our downstream discovered that this causes a regression when compiling 
`utility` with `ast-dump`.  I've put up a minimal reproducer: 
https://godbolt.org/z/oaezas7Ws

@hazohelet : Will you be able to look into this soon?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146358

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


[PATCH] D150646: [clang][X86] Add __cpuidex function to cpuid.h

2023-05-17 Thread Aiden Grossman 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 rG286cefcf35d0: [clang][X86] Add __cpuidex function to cpuid.h 
(authored by aidengrossman).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150646

Files:
  clang/lib/Headers/cpuid.h
  clang/test/Headers/cpuid.c


Index: clang/test/Headers/cpuid.c
===
--- clang/test/Headers/cpuid.c
+++ clang/test/Headers/cpuid.c
@@ -6,14 +6,19 @@
 
 // CHECK-64: {{.*}} call { i32, i32, i32, i32 } asm "  xchgq  %rbx,${1:q}\0A 
cpuid\0A xchgq %rbx,${1:q}", 
"={ax},=r,={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}})
 // CHECK-64: {{.*}} call { i32, i32, i32, i32 } asm "  xchgq  %rbx,${1:q}\0A  
cpuid\0A  xchgq  %rbx,${1:q}", 
"={ax},=r,={cx},={dx},0,2,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}}, i32 
%{{[a-z0-9]+}})
+// CHECK-64: {{.*}} call { i32, i32, i32, i32 } asm "  xchgq  %rbx,${1:q}\0A  
cpuid\0A  xchgq  %rbx,${1:q}", 
"={ax},=r,={cx},={dx},0,2,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}}, i32 
%{{[a-z0-9]+}})
 
 // CHECK-32: {{.*}} call { i32, i32, i32, i32 } asm "cpuid", 
"={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}})
 // CHECK-32: {{.*}} call { i32, i32, i32, i32 } asm "cpuid", 
"={ax},={bx},={cx},={dx},0,2,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}}, 
i32 %{{[a-z0-9]+}})
+// CHECK-32: {{.*}} call { i32, i32, i32, i32 } asm "cpuid", 
"={ax},={bx},={cx},={dx},0,2,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}}, 
i32 %{{[a-z0-9]+}})
 
 unsigned eax0, ebx0, ecx0, edx0;
 unsigned eax1, ebx1, ecx1, edx1;
 
+int cpuid_info[4];
+
 void test_cpuid(unsigned level, unsigned count) {
   __cpuid(level, eax1, ebx1, ecx1, edx1);
   __cpuid_count(level, count, eax0, ebx0, ecx0, edx0);
+  __cpuidex(cpuid_info, level, count);
 }
Index: clang/lib/Headers/cpuid.h
===
--- clang/lib/Headers/cpuid.h
+++ clang/lib/Headers/cpuid.h
@@ -328,4 +328,10 @@
 return 1;
 }
 
+static __inline void __cpuidex (int __cpu_info[4], int __leaf, int __subleaf)
+{
+  __cpuid_count(__leaf, __subleaf, __cpu_info[0], __cpu_info[1], __cpu_info[2],
+__cpu_info[3]);
+}
+
 #endif /* __CPUID_H */


Index: clang/test/Headers/cpuid.c
===
--- clang/test/Headers/cpuid.c
+++ clang/test/Headers/cpuid.c
@@ -6,14 +6,19 @@
 
 // CHECK-64: {{.*}} call { i32, i32, i32, i32 } asm "  xchgq  %rbx,${1:q}\0A cpuid\0A xchgq %rbx,${1:q}", "={ax},=r,={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}})
 // CHECK-64: {{.*}} call { i32, i32, i32, i32 } asm "  xchgq  %rbx,${1:q}\0A  cpuid\0A  xchgq  %rbx,${1:q}", "={ax},=r,={cx},={dx},0,2,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}}, i32 %{{[a-z0-9]+}})
+// CHECK-64: {{.*}} call { i32, i32, i32, i32 } asm "  xchgq  %rbx,${1:q}\0A  cpuid\0A  xchgq  %rbx,${1:q}", "={ax},=r,={cx},={dx},0,2,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}}, i32 %{{[a-z0-9]+}})
 
 // CHECK-32: {{.*}} call { i32, i32, i32, i32 } asm "cpuid", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}})
 // CHECK-32: {{.*}} call { i32, i32, i32, i32 } asm "cpuid", "={ax},={bx},={cx},={dx},0,2,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}}, i32 %{{[a-z0-9]+}})
+// CHECK-32: {{.*}} call { i32, i32, i32, i32 } asm "cpuid", "={ax},={bx},={cx},={dx},0,2,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}}, i32 %{{[a-z0-9]+}})
 
 unsigned eax0, ebx0, ecx0, edx0;
 unsigned eax1, ebx1, ecx1, edx1;
 
+int cpuid_info[4];
+
 void test_cpuid(unsigned level, unsigned count) {
   __cpuid(level, eax1, ebx1, ecx1, edx1);
   __cpuid_count(level, count, eax0, ebx0, ecx0, edx0);
+  __cpuidex(cpuid_info, level, count);
 }
Index: clang/lib/Headers/cpuid.h
===
--- clang/lib/Headers/cpuid.h
+++ clang/lib/Headers/cpuid.h
@@ -328,4 +328,10 @@
 return 1;
 }
 
+static __inline void __cpuidex (int __cpu_info[4], int __leaf, int __subleaf)
+{
+  __cpuid_count(__leaf, __subleaf, __cpu_info[0], __cpu_info[1], __cpu_info[2],
+__cpu_info[3]);
+}
+
 #endif /* __CPUID_H */
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 286cefc - [clang][X86] Add __cpuidex function to cpuid.h

2023-05-17 Thread Aiden Grossman via cfe-commits

Author: Aiden Grossman
Date: 2023-05-17T19:38:28Z
New Revision: 286cefcf35d0f55c57184c4219b95e82c96f1420

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

LOG: [clang][X86] Add __cpuidex function to cpuid.h

MSVC has a `__cpuidex` function implemented to call the underlying cpuid
instruction which accepts a leaf, subleaf, and data array that the output
data is written into. This patch adds this functionality into clang
under the cpuid.h header. This also makes clang match GCC's behavior.
GCC has had `__cpuidex` in its cpuid.h since 2020.

Reviewed By: craig.topper

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

Added: 


Modified: 
clang/lib/Headers/cpuid.h
clang/test/Headers/cpuid.c

Removed: 




diff  --git a/clang/lib/Headers/cpuid.h b/clang/lib/Headers/cpuid.h
index 1ad6853a97c9d..22260c48c0c42 100644
--- a/clang/lib/Headers/cpuid.h
+++ b/clang/lib/Headers/cpuid.h
@@ -328,4 +328,10 @@ static __inline int __get_cpuid_count (unsigned int __leaf,
 return 1;
 }
 
+static __inline void __cpuidex (int __cpu_info[4], int __leaf, int __subleaf)
+{
+  __cpuid_count(__leaf, __subleaf, __cpu_info[0], __cpu_info[1], __cpu_info[2],
+__cpu_info[3]);
+}
+
 #endif /* __CPUID_H */

diff  --git a/clang/test/Headers/cpuid.c b/clang/test/Headers/cpuid.c
index 7e485495c1066..6ed12eca7a61d 100644
--- a/clang/test/Headers/cpuid.c
+++ b/clang/test/Headers/cpuid.c
@@ -6,14 +6,19 @@
 
 // CHECK-64: {{.*}} call { i32, i32, i32, i32 } asm "  xchgq  %rbx,${1:q}\0A 
cpuid\0A xchgq %rbx,${1:q}", 
"={ax},=r,={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}})
 // CHECK-64: {{.*}} call { i32, i32, i32, i32 } asm "  xchgq  %rbx,${1:q}\0A  
cpuid\0A  xchgq  %rbx,${1:q}", 
"={ax},=r,={cx},={dx},0,2,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}}, i32 
%{{[a-z0-9]+}})
+// CHECK-64: {{.*}} call { i32, i32, i32, i32 } asm "  xchgq  %rbx,${1:q}\0A  
cpuid\0A  xchgq  %rbx,${1:q}", 
"={ax},=r,={cx},={dx},0,2,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}}, i32 
%{{[a-z0-9]+}})
 
 // CHECK-32: {{.*}} call { i32, i32, i32, i32 } asm "cpuid", 
"={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}})
 // CHECK-32: {{.*}} call { i32, i32, i32, i32 } asm "cpuid", 
"={ax},={bx},={cx},={dx},0,2,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}}, 
i32 %{{[a-z0-9]+}})
+// CHECK-32: {{.*}} call { i32, i32, i32, i32 } asm "cpuid", 
"={ax},={bx},={cx},={dx},0,2,~{dirflag},~{fpsr},~{flags}"(i32 %{{[a-z0-9]+}}, 
i32 %{{[a-z0-9]+}})
 
 unsigned eax0, ebx0, ecx0, edx0;
 unsigned eax1, ebx1, ecx1, edx1;
 
+int cpuid_info[4];
+
 void test_cpuid(unsigned level, unsigned count) {
   __cpuid(level, eax1, ebx1, ecx1, edx1);
   __cpuid_count(level, count, eax0, ebx0, ecx0, edx0);
+  __cpuidex(cpuid_info, level, count);
 }



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


[PATCH] D150646: [clang][X86] Add __cpuidex function to cpuid.h

2023-05-17 Thread Aiden Grossman via Phabricator via cfe-commits
aidengrossman added a comment.

Thanks for the review! Definitely a little bit odd and it probably would've 
been better if originally replicated in some other way, but definitely agree on 
the matching behavior.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150646

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


[PATCH] D150733: [clang] Convert remaining OpenMP tests to opaque pointers

2023-05-17 Thread Nikita Popov via Phabricator via cfe-commits
nikic accepted this revision.
nikic added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150733

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


[PATCH] D150221: Add option -fkeep-static-variables to emit all static variables

2023-05-17 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Hmm.  Preserving unused global variables in case a hot patch might use them 
doesn't seem very compelling to me — hot patches need to be able to introduce 
globals of their own anyway.  What I find more convincing is related to the 
*other* meaning of `__attribute__((used))`, that the compiler needs to treat 
the global as potentially referenced and used in ways that it cannot analyze.  
Considered from that perspective, a hot patch is essentially extra code that 
can be loaded into any translation unit dynamically.  If there are 
hot-patchable functions in a translation unit, the compiler needs to broadly 
avoid optimizing any globals referenceable from that translation unit as if it 
understood all their uses.  So it's less that we need to preserve globals that 
are actually unused and more that we need to preserve the use-patterns of 
globals.  For example, we can't decide that a mutable global variable is never 
reassigned and so forward its constant initializer to all the loads from it, 
because we need to treat that global as potentially reassigned by the code 
loaded in a hot patch.

I'm not sure if it's better to represent that by using `__attribute__((used))` 
on every global variable or by setting something more globally in the module.  
The latter seems more impervious to the LTO problem, at least.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150221

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


[PATCH] D150614: [clang-format] Ignore first token when finding MustBreak

2023-05-17 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks accepted this revision.
HazardyKnusperkeks added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:20136
"#ifdef _DEBUG\n"
-   "void bar()\n"
-   "  {\n"
-   "  }\n"
+   "void bar() {}\n"
"#else\n"

rymiel wrote:
> rymiel wrote:
> > HazardyKnusperkeks wrote:
> > > This doesn't seem right.
> > WhitesmithsBraceStyle.AllowShortFunctionsOnASingleLine = 
> > FormatStyle::SFS_Empty; is set above
> (this is mentioned in the summary)
> (this is mentioned in the summary)

Sorry about that, I must've skipped that part.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150614

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


[PATCH] D150718: [CUDA] Relax restrictions on GPU-side variadic functions

2023-05-17 Thread Justin Lebar via Phabricator via cfe-commits
jlebar accepted this revision.
jlebar added a comment.
This revision is now accepted and ready to land.

OK, sgtm.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150718

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


[PATCH] D150746: [CodeGen]Translating pointer arguments can require an address space cast

2023-05-17 Thread Alex Voicu via Phabricator via cfe-commits
AlexVlx added a comment.

In D150746#4350716 , @rjmccall wrote:

> Passing the VTT in the appropriate AS for global variables seems like the 
> right way to go — we do know that that argument will always be such a 
> pointer, so there's no point in converting to the generic address space.
>
> For that matter, v-table pointer slots within classes should also be pointers 
> into the global AS and not the generic AS.  That's a separate issue, though.

Sounds good, I will rework this patch; I have a set of forthcoming patches 
dealing with the second paragraph, FWIW:)


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

https://reviews.llvm.org/D150746

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


[PATCH] D150183: [Clang][clang-cl] Implement `__builtin_FUNCSIG`

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

Thank you! In general, this is looking pretty close to ready.




Comment at: clang/lib/Parse/ParseExpr.cpp:807-809
+/// [C++11] simple-type-specifier braced-init-list[C++11 5.2.3]
 /// [C++]   typename-specifier '(' expression-list[opt] ')' [C++ 5.2.3]
+/// [C++11] typename-specifier braced-init-list   [C++11 5.2.3]

Might as well revert the clang-format changes here.



Comment at: clang/test/Preprocessor/feature_tests.c:1-2
-// RUN: %clang_cc1 %s -triple=i686-apple-darwin9 -target-cpu pentium4 -verify 
-DVERIFY
-// RUN: %clang_cc1 %s -E -triple=i686-apple-darwin9 -target-cpu pentium4
+// RUN: %clang_cc1 %s -triple=i686-apple-darwin9 -target-cpu pentium4 
-fms-extensions -verify -DVERIFY
+// RUN: %clang_cc1 %s -E -triple=i686-apple-darwin9 -target-cpu pentium4 
-fms-extensions
 #ifndef __has_feature

We should continue to have non-ms-extension RUN lines as well. (This is testing 
feature tests, so enabling ms extensions can impact things in surprising ways 
and we don't want to lose coverage for non-ms modes.)



Comment at: clang/test/Sema/source_location.c:1-2
-// RUN: %clang_cc1 -std=c90 -fconst-strings -DCONST_STRINGS -verify %s
-// RUN: %clang_cc1 -std=c90 -verify %s
+// RUN: %clang_cc1 -std=c90 -fms-extensions -fconst-strings -DCONST_STRINGS 
-verify %s
+// RUN: %clang_cc1 -std=c90 -fms-extensions -verify %s
 

I would add a RUN line for -fms-extensions, same as above.



Comment at: clang/test/SemaCXX/source_location.cpp:1
-// RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fexceptions -verify %s
-// RUN: %clang_cc1 -std=c++2a -fcxx-exceptions -DUSE_CONSTEVAL -fexceptions 
-verify %s
+// RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fms-extensions -fexceptions 
-verify %s
+// RUN: %clang_cc1 -std=c++2a -fcxx-exceptions -fms-extensions -DUSE_CONSTEVAL 
-fexceptions -verify %s

Same here.


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

https://reviews.llvm.org/D150183

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


[PATCH] D150746: [CodeGen]Translating pointer arguments can require an address space cast

2023-05-17 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Passing the VTT in the appropriate AS for global variables seems like the right 
way to go — we do know that that argument will always be such a pointer, so 
there's no point in converting to the generic address space.

For that matter, v-table pointer slots within classes should also be pointers 
into the global AS and not the generic AS.  That's a separate issue, though.


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

https://reviews.llvm.org/D150746

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


[PATCH] D150221: Add option -fkeep-static-variables to emit all static variables

2023-05-17 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

In D150221#4347840 , @efriedma wrote:

>> This is an adaptation of the IBM XL compiler's -qstatsym option, which is 
>> meant to generate symbol table entries for static variables. An artifact of 
>> that compiler is that static variables are often not discarded even when 
>> unused.
>
> Oh, I see; the compiler actually doesn't guarantee that the variables are 
> preserved, it just ends up preserving them by accident because it's bad at 
> optimizing global variables?

That is my understanding, yes. However, that behaviour seems to serve the use 
case: Users can enable functions for hot-patching proactively to allow for bug 
fixes in live instances, and they would not necessarily know which static 
variables they need preserved for use in the replacement code up front. 
Additionally, sometimes the variables are not eliminated but their location is 
obfuscated by GlobalMerge (and potentially other optimizations).

The `-fkeep-static-variables` option only addresses the use case when users do 
not apply LTO though. LTO internalization exposes more variables to the 
obfuscation/removal issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150221

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


  1   2   3   >