[clang] [clang] Add another test case for CWG78 (PR #93708)

2024-05-29 Thread via cfe-commits

cor3ntin wrote:

My reading is that 
`const int k;` ought to be conforming indeed but the fact no compiler supports 
that gives me pause.
@zygoloid are we missing something?

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


[clang] [X86]Add support for _outp{|w|d} (PR #93774)

2024-05-29 Thread Malay Sanghi via cfe-commits


@@ -329,6 +329,26 @@ static __inline__ void __DEFAULT_FN_ATTRS __stosq(unsigned 
__int64 *__dst,
 static __inline__ void __DEFAULT_FN_ATTRS __halt(void) {
   __asm__ volatile("hlt");
 }
+
+static __inline__ int __DEFAULT_FN_ATTRS _outp(unsigned short port, int data) {
+  __asm__ volatile("outb %b0, %w1" : : "a"(data), "Nd"(port) : "memory");
+  return data;
+}
+
+static __inline__ unsigned short __DEFAULT_FN_ATTRS
+_outpw(unsigned short port, unsigned short data) {
+  __asm__ volatile("outw %w0, %w1" : : "a"(data), "Nd"(port) : "memory");
+  return data;
+}
+
+static __inline__ unsigned long __DEFAULT_FN_ATTRS _outpd(unsigned short port,
+  unsigned long data) {
+  __asm__ volatile("outl %k0, %w1" : : "a"(data), "Nd"(port) : "memory");
+  return data;
+}
+
+#define outp(port, data) _outp(port, data)
+#define outpw(R, D) _outpw(port, data)

MalaySanghi wrote:

No, ms does not define one: 
https://learn.microsoft.com/en-us/cpp/c-runtime-library/outp-outpw-outpd?view=msvc-170

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


[clang] [clang] CWG150: add tests and change to unreleased (PR #93758)

2024-05-29 Thread Vlad Serebrennikov via cfe-commits


@@ -753,6 +753,46 @@ namespace cwg148 { // cwg148: yes
 
 // cwg149: na
 
+namespace cwg150 { // cwg150: yes

Endilll wrote:

```suggestion
namespace cwg150 { // cwg150: 19
```

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


[clang] [clang] CWG150: add tests and change to unreleased (PR #93758)

2024-05-29 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll requested changes to this pull request.

You should apply the suggested change, and run `make_cxx_dr_status` script. I 
don't expect it to introduce new changes, though, but we should be on a safe 
side here, and not rely on manual editing of `cxx_dr_status.html`.

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


[clang] [clang] CWG150: add tests and change to unreleased (PR #93758)

2024-05-29 Thread Vlad Serebrennikov via cfe-commits

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


[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)

2024-05-29 Thread Freddy Ye via cfe-commits

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


[clang] 73f4c25 - [X86] Support EGPR for inline assembly. (#92338)

2024-05-29 Thread via cfe-commits

Author: Freddy Ye
Date: 2024-05-30T14:47:47+08:00
New Revision: 73f4c2547dc3d1b6a453d3c4388648b122554dd1

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

LOG: [X86] Support EGPR for inline assembly. (#92338)

"jR": explicitly enables EGPR
"r", "l", "q": enables/disables EGPR w/wo -mapx-inline-asm-use-gpr32
"jr": explicitly enables GPR with -mapx-inline-asm-use-gpr32
-mapx-inline-asm-use-gpr32 will also define a new macro:
`__APX_INLINE_ASM_USE_GPR32__`

GCC patches:
https://gcc.gnu.org/pipermail/gcc-patches/2023-September/631183.html
https://gcc.gnu.org/pipermail/gcc-patches/2023-September/631186.html
[[PATCH v2] x86: Define _APX_INLINE_ASM_USE_GPR32_
(gnu.org)](https://gcc.gnu.org/pipermail/gcc-patches/2024-April/649003.html)

Reference: https://gcc.godbolt.org/z/nPPvbY6r4

Added: 
clang/test/Driver/x86-apx-inline-asm-use-gpr32.cpp
llvm/test/CodeGen/X86/apx/asm-constraint-jR.ll
llvm/test/CodeGen/X86/apx/asm-constraint-jr.ll

Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Basic/Targets/X86.cpp
clang/lib/Basic/Targets/X86.h
clang/lib/Driver/ToolChains/Arch/X86.cpp
clang/test/Preprocessor/x86_target_features.c
llvm/docs/LangRef.rst
llvm/lib/Target/X86/X86.td
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/apx/asm-constraint.ll

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 4119e69c85540..1637a114fcce1 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6280,6 +6280,8 @@ def mno_apx_features_EQ : CommaJoined<["-"], 
"mno-apx-features=">, Group, Alias, 
AliasArgs<["egpr","push2pop2","ppx","ndd","ccmp","nf"]>;
 def mno_apxf : Flag<["-"], "mno-apxf">, Alias, 
AliasArgs<["egpr","push2pop2","ppx","ndd","ccmp","nf"]>;
+def mapx_inline_asm_use_gpr32 : Flag<["-"], "mapx-inline-asm-use-gpr32">, 
Group,
+HelpText<"Enable use of GPR32 in inline 
assembly for APX">;
 } // let Flags = [TargetSpecific]
 
 // VE feature flags

diff  --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index 08e44360bfbe3..34d249ed27ce5 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -441,6 +441,8 @@ bool 
X86TargetInfo::handleTargetFeatures(std::vector &Features,
   HasFullBFloat16 = true;
 } else if (Feature == "+egpr") {
   HasEGPR = true;
+} else if (Feature == "+inline-asm-use-gpr32") {
+  HasInlineAsmUseGPR32 = true;
 } else if (Feature == "+push2pop2") {
   HasPush2Pop2 = true;
 } else if (Feature == "+ppx") {
@@ -963,6 +965,8 @@ void X86TargetInfo::getTargetDefines(const LangOptions 
&Opts,
   // Condition here is aligned with the feature set of mapxf in Options.td
   if (HasEGPR && HasPush2Pop2 && HasPPX && HasNDD && HasCCMP && HasNF)
 Builder.defineMacro("__APX_F__");
+  if (HasEGPR && HasInlineAsmUseGPR32)
+Builder.defineMacro("__APX_INLINE_ASM_USE_GPR32__");
 
   // Each case falls through to the previous one here.
   switch (SSELevel) {
@@ -1478,6 +1482,18 @@ bool X86TargetInfo::validateAsmConstraint(
   case 'C': // SSE floating point constant.
   case 'G': // x87 floating point constant.
 return true;
+  case 'j':
+Name++;
+switch (*Name) {
+default:
+  return false;
+case 'r':
+  Info.setAllowsRegister();
+  return true;
+case 'R':
+  Info.setAllowsRegister();
+  return true;
+}
   case '@':
 // CC condition changes.
 if (auto Len = matchAsmCCConstraint(Name)) {
@@ -1749,6 +1765,20 @@ std::string X86TargetInfo::convertConstraint(const char 
*&Constraint) const {
   // to the next constraint.
   return std::string("^") + std::string(Constraint++, 2);
 }
+  case 'j':
+switch (Constraint[1]) {
+default:
+  // Break from inner switch and fall through (copy single char),
+  // continue parsing after copying the current constraint into
+  // the return string.
+  break;
+case 'r':
+case 'R':
+  // "^" hints llvm that this is a 2 letter constraint.
+  // "Constraint++" is used to promote the string iterator
+  // to the next constraint.
+  return std::string("^") + std::string(Constraint++, 2);
+}
 [[fallthrough]];
   default:
 return std::string(1, *Constraint);

diff  --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h
index 0633b7e0da96a..9b2ae87adb2e7 100644
--- a/clang/lib/Basic/Targets/X86.h
+++ b/clang/lib/Basic/Targets/X86.h
@@ -172,6 +172,7 @@ class LLVM_LIBRARY_VISIBILITY X86TargetInfo : public 
TargetInfo {
   bool HasCCMP = false;
   bool HasNF = false;
   bool HasCF = false;
+  bool HasInlineAsmUseGPR32 = false;
 
 protected:
   llvm::X86::CP

[clang] [X86]Add support for _outp{|w|d} (PR #93774)

2024-05-29 Thread Phoebe Wang via cfe-commits


@@ -329,6 +329,26 @@ static __inline__ void __DEFAULT_FN_ATTRS __stosq(unsigned 
__int64 *__dst,
 static __inline__ void __DEFAULT_FN_ATTRS __halt(void) {
   __asm__ volatile("hlt");
 }
+
+static __inline__ int __DEFAULT_FN_ATTRS _outp(unsigned short port, int data) {
+  __asm__ volatile("outb %b0, %w1" : : "a"(data), "Nd"(port) : "memory");
+  return data;
+}
+
+static __inline__ unsigned short __DEFAULT_FN_ATTRS
+_outpw(unsigned short port, unsigned short data) {
+  __asm__ volatile("outw %w0, %w1" : : "a"(data), "Nd"(port) : "memory");
+  return data;
+}
+
+static __inline__ unsigned long __DEFAULT_FN_ATTRS _outpd(unsigned short port,
+  unsigned long data) {
+  __asm__ volatile("outl %k0, %w1" : : "a"(data), "Nd"(port) : "memory");
+  return data;
+}
+
+#define outp(port, data) _outp(port, data)
+#define outpw(R, D) _outpw(port, data)

phoebewang wrote:

No outpd?

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


[clang] [X86]Add support for _outp{|w|d} (PR #93774)

2024-05-29 Thread Phoebe Wang via cfe-commits


@@ -329,6 +329,26 @@ static __inline__ void __DEFAULT_FN_ATTRS __stosq(unsigned 
__int64 *__dst,
 static __inline__ void __DEFAULT_FN_ATTRS __halt(void) {
   __asm__ volatile("hlt");
 }
+
+static __inline__ int __DEFAULT_FN_ATTRS _outp(unsigned short port, int data) {
+  __asm__ volatile("outb %b0, %w1" : : "a"(data), "Nd"(port) : "memory");

phoebewang wrote:

Instruction doesn't clobber memory.

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


[clang] [clang] fix merging of UsingShadowDecl (PR #80245)

2024-05-29 Thread Matheus Izvekov via cfe-commits

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


[clang] 1ac592c - [clang] fix merging of UsingShadowDecl (#80245)

2024-05-29 Thread via cfe-commits

Author: Matheus Izvekov
Date: 2024-05-30T03:43:27-03:00
New Revision: 1ac592c4e7b4ba7c680af9286ad79ed27ad628f1

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

LOG: [clang] fix merging of UsingShadowDecl (#80245)

[clang] fix merging of UsingShadowDecl

Previously, when deciding if two UsingShadowDecls where mergeable,
we would incorrectly only look for both pointing to the exact redecla
ration, whereas the correct thing is to look for declarations to the
same entity.

This problem has existed as far back as 2013, introduced in commit
fd8634a09de71.

This problem could manifest itself as ODR check false positives when
importing modules.

Fixes: #80252

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/AST/ASTContext.cpp
clang/test/Modules/cxx20-decls.cppm

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 44035f48cb3f9..9dc93f53fe716 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -813,6 +813,9 @@ Bug Fixes to C++ Support
 - Clang now allows ``@$``` in raw string literals. Fixes (#GH93130).
 - Fix an assertion failure when checking invalid ``this`` usage in the wrong 
context. (Fixes #GH91536).
 - Clang no longer models dependent NTTP arguments as 
``TemplateParamObjectDecl`` s. Fixes (#GH84052).
+- Fix incorrect merging of modules which contain using declarations which 
shadow
+  other declarations. This could manifest as ODR checker false positives.
+  Fixes (`#80252 `_)
 
 Bug Fixes to AST Handling
 ^

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 06780ceba4074..73d3b152c49f1 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -6794,7 +6794,7 @@ bool ASTContext::isSameEntity(const NamedDecl *X, const 
NamedDecl *Y) const {
   // Using shadow declarations with the same target match.
   if (const auto *USX = dyn_cast(X)) {
 const auto *USY = cast(Y);
-return USX->getTargetDecl() == USY->getTargetDecl();
+return declaresSameEntity(USX->getTargetDecl(), USY->getTargetDecl());
   }
 
   // Using declarations with the same qualifier match. (We already know that

diff  --git a/clang/test/Modules/cxx20-decls.cppm 
b/clang/test/Modules/cxx20-decls.cppm
index 9f0c40685b68f..0e8b59708ab4c 100644
--- a/clang/test/Modules/cxx20-decls.cppm
+++ b/clang/test/Modules/cxx20-decls.cppm
@@ -28,8 +28,8 @@ using xxx = baz::foo;
 // CHECK-NEXT: NamespaceDecl 0x[[BAZ_REDECL_ADDR:[^ ]*]] prev 0x[[BAZ_ADDR:[^ 
]*]]
 // CHECK:  TypeAliasDecl 0x[[ALIAS_REDECL_ADDR:[^ ]*]] prev 
0x[[ALIAS_ADDR:[^ ]*]]
 // FIXME: UsingShadowDecl should have been merged
-// CHECK:  UsingShadowDecl 0x{{[^ ]*}} <{{.*}}> col:{{.*}} imported in 
A. hidden implicit TypeAlias 0x[[ALIAS_REDECL_ADDR]] 'foo'
+// CHECK:  UsingShadowDecl 0x{{[^ ]*}} prev 0x[[SHADOW_ADDR:[^ ]*]] {{.*}} 
imported in A. {{.*}} 'foo'
 
 // CHECK-LABEL: Dumping baz:
 // CHECK-NEXT: NamespaceDecl 0x[[BAZ_ADDR]] <{{.*}}> line:{{.*}} baz
-// CHECK:  UsingShadowDecl 0x[[SHADOW_ADDR:[^ ]*]] <{{.*}}> col:{{.*}} 
implicit TypeAlias 0x[[ALIAS_ADDR]] 'foo'
+// CHECK:  UsingShadowDecl 0x[[SHADOW_ADDR]] {{.*}} 'foo'



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


[clang] [X86]Add support for _outp{|w|d} (PR #93774)

2024-05-29 Thread Malay Sanghi via cfe-commits

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


[clang] Add support for _outp{|w|d} (PR #93774)

2024-05-29 Thread Malay Sanghi via cfe-commits

MalaySanghi wrote:

@FreddyLeaf @phoebewang please review

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


[clang] Add support for _outp{|w|d} (PR #93774)

2024-05-29 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-x86

Author: Malay Sanghi (MalaySanghi)


Changes

Supported: outp, outpw, _outp, _outpw, _outpd
These functions were removed from the Windows runtime library, but for kernel 
mode development it's still supported

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


2 Files Affected:

- (modified) clang/lib/Headers/intrin.h (+20) 
- (modified) clang/test/CodeGen/X86/ms-x86-intrinsics.c (+85) 


``diff
diff --git a/clang/lib/Headers/intrin.h b/clang/lib/Headers/intrin.h
index 5ceb986a1f652..21a3f030216e6 100644
--- a/clang/lib/Headers/intrin.h
+++ b/clang/lib/Headers/intrin.h
@@ -329,6 +329,26 @@ static __inline__ void __DEFAULT_FN_ATTRS __stosq(unsigned 
__int64 *__dst,
 static __inline__ void __DEFAULT_FN_ATTRS __halt(void) {
   __asm__ volatile("hlt");
 }
+
+static __inline__ int __DEFAULT_FN_ATTRS _outp(unsigned short port, int data) {
+  __asm__ volatile("outb %b0, %w1" : : "a"(data), "Nd"(port) : "memory");
+  return data;
+}
+
+static __inline__ unsigned short __DEFAULT_FN_ATTRS
+_outpw(unsigned short port, unsigned short data) {
+  __asm__ volatile("outw %w0, %w1" : : "a"(data), "Nd"(port) : "memory");
+  return data;
+}
+
+static __inline__ unsigned long __DEFAULT_FN_ATTRS _outpd(unsigned short port,
+  unsigned long data) {
+  __asm__ volatile("outl %k0, %w1" : : "a"(data), "Nd"(port) : "memory");
+  return data;
+}
+
+#define outp(port, data) _outp(port, data)
+#define outpw(R, D) _outpw(port, data)
 #endif
 
 #if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__)
diff --git a/clang/test/CodeGen/X86/ms-x86-intrinsics.c 
b/clang/test/CodeGen/X86/ms-x86-intrinsics.c
index aa557c8e19a83..e990ccd3449ac 100644
--- a/clang/test/CodeGen/X86/ms-x86-intrinsics.c
+++ b/clang/test/CodeGen/X86/ms-x86-intrinsics.c
@@ -63,6 +63,91 @@ unsigned __int64 test__emulu(unsigned int a, unsigned int b) 
{
 // CHECK: [[RES:%[0-9]+]] = mul nuw i64 [[Y]], [[X]]
 // CHECK: ret i64 [[RES]]
 
+//
+// CHECK-I386-LABEL: define dso_local noundef i32 @test_outp(
+// CHECK-I386-SAME: i16 noundef zeroext [[PORT:%.*]], i32 noundef returned 
[[DATA:%.*]]) local_unnamed_addr #[[ATTR2:[0-9]+]] {
+// CHECK-I386-NEXT:  [[ENTRY:.*:]]
+// CHECK-I386-NEXT:tail call void asm sideeffect "outb ${0:b}, ${1:w}", 
"{ax},N{dx},~{memory},~{dirflag},~{fpsr},~{flags}"(i32 [[DATA]], i16 [[PORT]]) 
#[[ATTR3:[0-9]+]], !srcloc [[META4:![0-9]+]]
+// CHECK-I386-NEXT:ret i32 [[DATA]]
+//
+// CHECK-X64-LABEL: define dso_local noundef i32 @test_outp(
+// CHECK-X64-SAME: i16 noundef [[PORT:%.*]], i32 noundef returned 
[[DATA:%.*]]) local_unnamed_addr #[[ATTR1:[0-9]+]] {
+// CHECK-X64-NEXT:  [[ENTRY:.*:]]
+// CHECK-X64-NEXT:tail call void asm sideeffect "outb ${0:b}, ${1:w}", 
"{ax},N{dx},~{memory},~{dirflag},~{fpsr},~{flags}"(i32 [[DATA]], i16 [[PORT]]) 
#[[ATTR5:[0-9]+]], !srcloc [[META3:![0-9]+]]
+// CHECK-X64-NEXT:ret i32 [[DATA]]
+//
+int test_outp(unsigned short port, int data) {
+return _outp(port, data);
+}
+
+//
+// CHECK-I386-LABEL: define dso_local noundef zeroext i16 @test_outpw(
+// CHECK-I386-SAME: i16 noundef zeroext [[PORT:%.*]], i16 noundef returned 
zeroext [[DATA:%.*]]) local_unnamed_addr #[[ATTR2]] {
+// CHECK-I386-NEXT:  [[ENTRY:.*:]]
+// CHECK-I386-NEXT:tail call void asm sideeffect "outw ${0:w}, ${1:w}", 
"{ax},N{dx},~{memory},~{dirflag},~{fpsr},~{flags}"(i16 [[DATA]], i16 [[PORT]]) 
#[[ATTR3]], !srcloc [[META5:![0-9]+]]
+// CHECK-I386-NEXT:ret i16 [[DATA]]
+//
+// CHECK-X64-LABEL: define dso_local noundef i16 @test_outpw(
+// CHECK-X64-SAME: i16 noundef [[PORT:%.*]], i16 noundef returned 
[[DATA:%.*]]) local_unnamed_addr #[[ATTR1]] {
+// CHECK-X64-NEXT:  [[ENTRY:.*:]]
+// CHECK-X64-NEXT:tail call void asm sideeffect "outw ${0:w}, ${1:w}", 
"{ax},N{dx},~{memory},~{dirflag},~{fpsr},~{flags}"(i16 [[DATA]], i16 [[PORT]]) 
#[[ATTR5]], !srcloc [[META4:![0-9]+]]
+// CHECK-X64-NEXT:ret i16 [[DATA]]
+//
+unsigned short test_outpw(unsigned short port, unsigned short data) {
+return _outpw(port, data);
+}
+
+//
+// CHECK-I386-LABEL: define dso_local noundef i32 @test_outpd(
+// CHECK-I386-SAME: i16 noundef zeroext [[PORT:%.*]], i32 noundef returned 
[[DATA:%.*]]) local_unnamed_addr #[[ATTR2]] {
+// CHECK-I386-NEXT:  [[ENTRY:.*:]]
+// CHECK-I386-NEXT:tail call void asm sideeffect "outl ${0:k}, ${1:w}", 
"{ax},N{dx},~{memory},~{dirflag},~{fpsr},~{flags}"(i32 [[DATA]], i16 [[PORT]]) 
#[[ATTR3]], !srcloc [[META6:![0-9]+]]
+// CHECK-I386-NEXT:ret i32 [[DATA]]
+//
+// CHECK-X64-LABEL: define dso_local noundef i32 @test_outpd(
+// CHECK-X64-SAME: i16 noundef [[PORT:%.*]], i32 noundef returned 
[[DATA:%.*]]) local_unnamed_addr #[[ATTR1]] {
+// CHECK-X64-NEXT:  [[ENTRY:.*:]]
+// CHECK-X64-NEXT:tail call void asm sideeffect "outl ${0:k}, ${1:w}", 
"{ax},N{dx},~{memory},~{dirflag},~{fpsr},~{flags}"(i32 [[DATA]], i16 [[PORT]]) 
#[[ATTR5]], !srcloc [[META5:![0-9]+]]

[clang] Add support for _outp{|w|d} (PR #93774)

2024-05-29 Thread Malay Sanghi via cfe-commits

https://github.com/MalaySanghi created 
https://github.com/llvm/llvm-project/pull/93774

Supported: outp, outpw, _outp, _outpw, _outpd
These functions were removed from the Windows runtime library, but for kernel 
mode development it's still supported

>From 38359132ea0b3b56900ba48827c86a93c017223a Mon Sep 17 00:00:00 2001
From: Malay Sanghi 
Date: Wed, 29 May 2024 22:40:47 -0700
Subject: [PATCH] Add support for _outp{|w|d}

---
 clang/lib/Headers/intrin.h | 20 +
 clang/test/CodeGen/X86/ms-x86-intrinsics.c | 85 ++
 2 files changed, 105 insertions(+)

diff --git a/clang/lib/Headers/intrin.h b/clang/lib/Headers/intrin.h
index 5ceb986a1f652..21a3f030216e6 100644
--- a/clang/lib/Headers/intrin.h
+++ b/clang/lib/Headers/intrin.h
@@ -329,6 +329,26 @@ static __inline__ void __DEFAULT_FN_ATTRS __stosq(unsigned 
__int64 *__dst,
 static __inline__ void __DEFAULT_FN_ATTRS __halt(void) {
   __asm__ volatile("hlt");
 }
+
+static __inline__ int __DEFAULT_FN_ATTRS _outp(unsigned short port, int data) {
+  __asm__ volatile("outb %b0, %w1" : : "a"(data), "Nd"(port) : "memory");
+  return data;
+}
+
+static __inline__ unsigned short __DEFAULT_FN_ATTRS
+_outpw(unsigned short port, unsigned short data) {
+  __asm__ volatile("outw %w0, %w1" : : "a"(data), "Nd"(port) : "memory");
+  return data;
+}
+
+static __inline__ unsigned long __DEFAULT_FN_ATTRS _outpd(unsigned short port,
+  unsigned long data) {
+  __asm__ volatile("outl %k0, %w1" : : "a"(data), "Nd"(port) : "memory");
+  return data;
+}
+
+#define outp(port, data) _outp(port, data)
+#define outpw(R, D) _outpw(port, data)
 #endif
 
 #if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__)
diff --git a/clang/test/CodeGen/X86/ms-x86-intrinsics.c 
b/clang/test/CodeGen/X86/ms-x86-intrinsics.c
index aa557c8e19a83..e990ccd3449ac 100644
--- a/clang/test/CodeGen/X86/ms-x86-intrinsics.c
+++ b/clang/test/CodeGen/X86/ms-x86-intrinsics.c
@@ -63,6 +63,91 @@ unsigned __int64 test__emulu(unsigned int a, unsigned int b) 
{
 // CHECK: [[RES:%[0-9]+]] = mul nuw i64 [[Y]], [[X]]
 // CHECK: ret i64 [[RES]]
 
+//
+// CHECK-I386-LABEL: define dso_local noundef i32 @test_outp(
+// CHECK-I386-SAME: i16 noundef zeroext [[PORT:%.*]], i32 noundef returned 
[[DATA:%.*]]) local_unnamed_addr #[[ATTR2:[0-9]+]] {
+// CHECK-I386-NEXT:  [[ENTRY:.*:]]
+// CHECK-I386-NEXT:tail call void asm sideeffect "outb ${0:b}, ${1:w}", 
"{ax},N{dx},~{memory},~{dirflag},~{fpsr},~{flags}"(i32 [[DATA]], i16 [[PORT]]) 
#[[ATTR3:[0-9]+]], !srcloc [[META4:![0-9]+]]
+// CHECK-I386-NEXT:ret i32 [[DATA]]
+//
+// CHECK-X64-LABEL: define dso_local noundef i32 @test_outp(
+// CHECK-X64-SAME: i16 noundef [[PORT:%.*]], i32 noundef returned 
[[DATA:%.*]]) local_unnamed_addr #[[ATTR1:[0-9]+]] {
+// CHECK-X64-NEXT:  [[ENTRY:.*:]]
+// CHECK-X64-NEXT:tail call void asm sideeffect "outb ${0:b}, ${1:w}", 
"{ax},N{dx},~{memory},~{dirflag},~{fpsr},~{flags}"(i32 [[DATA]], i16 [[PORT]]) 
#[[ATTR5:[0-9]+]], !srcloc [[META3:![0-9]+]]
+// CHECK-X64-NEXT:ret i32 [[DATA]]
+//
+int test_outp(unsigned short port, int data) {
+return _outp(port, data);
+}
+
+//
+// CHECK-I386-LABEL: define dso_local noundef zeroext i16 @test_outpw(
+// CHECK-I386-SAME: i16 noundef zeroext [[PORT:%.*]], i16 noundef returned 
zeroext [[DATA:%.*]]) local_unnamed_addr #[[ATTR2]] {
+// CHECK-I386-NEXT:  [[ENTRY:.*:]]
+// CHECK-I386-NEXT:tail call void asm sideeffect "outw ${0:w}, ${1:w}", 
"{ax},N{dx},~{memory},~{dirflag},~{fpsr},~{flags}"(i16 [[DATA]], i16 [[PORT]]) 
#[[ATTR3]], !srcloc [[META5:![0-9]+]]
+// CHECK-I386-NEXT:ret i16 [[DATA]]
+//
+// CHECK-X64-LABEL: define dso_local noundef i16 @test_outpw(
+// CHECK-X64-SAME: i16 noundef [[PORT:%.*]], i16 noundef returned 
[[DATA:%.*]]) local_unnamed_addr #[[ATTR1]] {
+// CHECK-X64-NEXT:  [[ENTRY:.*:]]
+// CHECK-X64-NEXT:tail call void asm sideeffect "outw ${0:w}, ${1:w}", 
"{ax},N{dx},~{memory},~{dirflag},~{fpsr},~{flags}"(i16 [[DATA]], i16 [[PORT]]) 
#[[ATTR5]], !srcloc [[META4:![0-9]+]]
+// CHECK-X64-NEXT:ret i16 [[DATA]]
+//
+unsigned short test_outpw(unsigned short port, unsigned short data) {
+return _outpw(port, data);
+}
+
+//
+// CHECK-I386-LABEL: define dso_local noundef i32 @test_outpd(
+// CHECK-I386-SAME: i16 noundef zeroext [[PORT:%.*]], i32 noundef returned 
[[DATA:%.*]]) local_unnamed_addr #[[ATTR2]] {
+// CHECK-I386-NEXT:  [[ENTRY:.*:]]
+// CHECK-I386-NEXT:tail call void asm sideeffect "outl ${0:k}, ${1:w}", 
"{ax},N{dx},~{memory},~{dirflag},~{fpsr},~{flags}"(i32 [[DATA]], i16 [[PORT]]) 
#[[ATTR3]], !srcloc [[META6:![0-9]+]]
+// CHECK-I386-NEXT:ret i32 [[DATA]]
+//
+// CHECK-X64-LABEL: define dso_local noundef i32 @test_outpd(
+// CHECK-X64-SAME: i16 noundef [[PORT:%.*]], i32 noundef returned 
[[DATA:%.*]]) local_unnamed_addr #[[ATTR1]] {
+// CHECK-X64-NEXT:  [[ENTRY:.*:]]
+// CHECK-X64-NEXT:tail call void asm sideeffect "outl ${0:k}, ${1:w}", 

[clang] [clang-format] add an option to insert a space only for non-code block empty braces, not for empty parentheses (PR #93634)

2024-05-29 Thread Owen Pan via cfe-commits

owenca wrote:

See https://github.com/llvm/llvm-project/issues/93635#issuecomment-2138778128. 
Also, we need to deprecate 
[`SpaceInEmptyBlock`](https://clang.llvm.org/docs/ClangFormatStyleOptions.html#spaceinemptyblock).

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


[clang] d10b765 - [ConstantFold] Remove notional over-indexing fold (#93697)

2024-05-29 Thread via cfe-commits

Author: Nikita Popov
Date: 2024-05-30T08:36:44+02:00
New Revision: d10b76552f919ddb84347ab03908a55804ea6b8a

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

LOG: [ConstantFold] Remove notional over-indexing fold (#93697)

The data-layout independent constant folding currently has some rather
gnarly code for canonicalizing GEP indices to reduce "notional
overindexing", and then infers inbounds based on that canonicalization.

Now that we canonicalize to i8 GEPs, this canonicalization is
essentially useless, as we'll discard it as soon as the GEP hits the
data-layout aware constant folder anyway. As such, I'd like to remove
this code entirely.

This shouldn't have any impact on optimization capabilities.

Added: 


Modified: 
clang/test/CodeGen/object-size.c
clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp
clang/test/CodeGenHLSL/cbuf.hlsl
clang/test/Driver/linker-wrapper-image.c

compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_allowlist_ignorelist.cpp
llvm/lib/IR/ConstantFold.cpp
llvm/test/Assembler/ConstantExprFold.ll
llvm/test/Assembler/getelementptr.ll
llvm/test/Assembler/getelementptr_vec_ce.ll
llvm/test/CodeGen/AMDGPU/opencl-printf.ll
llvm/test/Linker/comdat-largest.ll

llvm/test/Transforms/CodeGenPrepare/AArch64/gather-scatter-opt-inseltpoison.ll
llvm/test/Transforms/CodeGenPrepare/AArch64/gather-scatter-opt.ll
llvm/test/Transforms/CodeGenPrepare/X86/gather-scatter-opt-inseltpoison.ll
llvm/test/Transforms/CodeGenPrepare/X86/gather-scatter-opt.ll
llvm/test/Transforms/GlobalOpt/globalsra-opaque-ptr.ll
llvm/test/Transforms/GlobalSplit/basic.ll
llvm/test/Transforms/InferAddressSpaces/AMDGPU/infer-address-space.ll
llvm/test/Transforms/InferAddressSpaces/AMDGPU/infer-getelementptr.ll

llvm/test/Transforms/InferAddressSpaces/AMDGPU/old-pass-regressions-inseltpoison.ll
llvm/test/Transforms/InferAddressSpaces/AMDGPU/old-pass-regressions.ll
llvm/test/Transforms/InferAddressSpaces/NVPTX/bug31948.ll
llvm/test/Transforms/InferAlignment/gep-array.ll
llvm/test/Transforms/InstCombine/gep-vector.ll
llvm/test/Transforms/InstSimplify/ConstProp/vectorgep-crash.ll
llvm/test/Transforms/InstSimplify/vector_gep.ll
llvm/test/Transforms/NewGVN/2007-07-26-InterlockingLoops.ll
mlir/test/Target/LLVMIR/omptarget-constant-indexing-device-region.mlir
mlir/test/Target/LLVMIR/omptarget-fortran-allocatable-types-host.mlir

Removed: 




diff  --git a/clang/test/CodeGen/object-size.c 
b/clang/test/CodeGen/object-size.c
index b39b15fcc65b9..58561a5470f72 100644
--- a/clang/test/CodeGen/object-size.c
+++ b/clang/test/CodeGen/object-size.c
@@ -34,7 +34,7 @@ void test2(void) {
 
 // CHECK-LABEL: define{{.*}} void @test3
 void test3(void) {
-  // CHECK: = call ptr @__strcpy_chk(ptr getelementptr inbounds ([63 x 
i8], ptr @gbuf, i64 1, i64 37), ptr @.str, i64 0)
+  // CHECK: = call ptr @__strcpy_chk(ptr getelementptr inbounds ([63 x 
i8], ptr @gbuf, i64 0, i64 100), ptr @.str, i64 0)
   strcpy(&gbuf[100], "Hi there");
 }
 

diff  --git 
a/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp 
b/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp
index c15a6183d15df..6fbe4c7fd17a7 100644
--- a/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp
+++ b/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp
@@ -112,21 +112,21 @@ std::initializer_list> nested 
= {
 // CHECK-DYNAMIC-BE: store i32 {{.*}}, ptr getelementptr inbounds (i32, ptr 
@_ZGR6nested0_, i64 1)
 // CHECK-DYNAMIC-BE: store ptr @_ZGR6nested0_,
 // CHECK-DYNAMIC-BE:   ptr @_ZGR6nested_, align 8
-// CHECK-DYNAMIC-BE: store ptr getelementptr inbounds ([2 x i32], ptr 
@_ZGR6nested0_, i64 1, i64 0),
+// CHECK-DYNAMIC-BE: store ptr getelementptr inbounds ([2 x i32], ptr 
@_ZGR6nested0_, i64 0, i64 2),
 // CHECK-DYNAMIC-BE:   ptr getelementptr inbounds ({{.*}}, ptr 
@_ZGR6nested_, i32 0, i32 1), align 8
 // CHECK-DYNAMIC-BE: store i32 3, ptr @_ZGR6nested1_
 // CHECK-DYNAMIC-BE: store i32 {{.*}}, ptr getelementptr inbounds (i32, ptr 
@_ZGR6nested1_, i64 1)
 // CHECK-DYNAMIC-BE: store ptr @_ZGR6nested1_,
 // CHECK-DYNAMIC-BE:   ptr getelementptr inbounds ({{.*}}, ptr 
@_ZGR6nested_, i64 1), align 8
-// CHECK-DYNAMIC-BE: store ptr getelementptr inbounds ([2 x i32], ptr 
@_ZGR6nested1_, i64 1, i64 0),
+// CHECK-DYNAMIC-BE: store ptr getelementptr inbounds ([2 x i32], ptr 
@_ZGR6nested1_, i64 0, i64 2),
 // CHECK-DYNAMIC-BE:   ptr getelementptr inbounds ({{.*}}, ptr 
@_ZGR6nested_, i64 1, i32 1), align 8
 // CHECK-DYNAMIC-BE: store i32 5, ptr @_ZGR6nested2_
 // CHECK-DYNAMIC-BE: store i32 {{.*}}, ptr getelementptr inbounds (

[clang] [compiler-rt] [llvm] [mlir] [ConstantFold] Remove notional over-indexing fold (PR #93697)

2024-05-29 Thread Nikita Popov via cfe-commits

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


[clang] [clang] Add another test case for CWG78 (PR #93708)

2024-05-29 Thread Vlad Serebrennikov via cfe-commits

https://github.com/Endilll updated 
https://github.com/llvm/llvm-project/pull/93708

>From 210d58b7133aeb007d423464bcd40d016fc25863 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Wed, 29 May 2024 15:57:30 +0300
Subject: [PATCH] [clang] Add another test case for CWG78

---
 clang/test/CXX/drs/cwg0xx.cpp |  8 +---
 clang/test/CXX/drs/cwg78.cpp  | 34 ++
 clang/www/cxx_dr_status.html  |  2 +-
 3 files changed, 36 insertions(+), 8 deletions(-)
 create mode 100644 clang/test/CXX/drs/cwg78.cpp

diff --git a/clang/test/CXX/drs/cwg0xx.cpp b/clang/test/CXX/drs/cwg0xx.cpp
index 6c600bbc7c3f6..abfaca7fe06e7 100644
--- a/clang/test/CXX/drs/cwg0xx.cpp
+++ b/clang/test/CXX/drs/cwg0xx.cpp
@@ -1180,13 +1180,7 @@ namespace cwg77 { // cwg77: yes
   };
 }
 
-namespace cwg78 { // cwg78: sup 
-  // Under CWG78, this is valid, because 'k' has static storage duration, so is
-  // zero-initialized.
-  const int k;
-  // expected-error@-1 {{default initialization of an object of const type 
'const int'}}
-}
-
+// cwg78 is in cwg78.cpp
 // cwg79: na
 
 namespace cwg80 { // cwg80: 2.9
diff --git a/clang/test/CXX/drs/cwg78.cpp b/clang/test/CXX/drs/cwg78.cpp
new file mode 100644
index 0..e0c3b72c537cf
--- /dev/null
+++ b/clang/test/CXX/drs/cwg78.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -std=c++98 %s -verify -DVERIFY -fexceptions 
-fcxx-exceptions -pedantic-errors -triple %itanium_abi_triple
+// RUN: %clang_cc1 -std=c++11 %s -verify -DVERIFY -fexceptions 
-fcxx-exceptions -pedantic-errors -triple %itanium_abi_triple
+// RUN: %clang_cc1 -std=c++14 %s -verify -DVERIFY -fexceptions 
-fcxx-exceptions -pedantic-errors -triple %itanium_abi_triple
+// RUN: %clang_cc1 -std=c++17 %s -verify -DVERIFY -fexceptions 
-fcxx-exceptions -pedantic-errors -triple %itanium_abi_triple
+// RUN: %clang_cc1 -std=c++20 %s -verify -DVERIFY -fexceptions 
-fcxx-exceptions -pedantic-errors -triple %itanium_abi_triple
+// RUN: %clang_cc1 -std=c++23 %s -verify -DVERIFY -fexceptions 
-fcxx-exceptions -pedantic-errors -triple %itanium_abi_triple
+// RUN: %clang_cc1 -std=c++23 %s -verify -DVERIFY -fexceptions 
-fcxx-exceptions -pedantic-errors -triple %itanium_abi_triple
+
+// RUN: %clang_cc1 -std=c++98 %s -triple %itanium_abi_triple -emit-llvm 
-disable-llvm-passes -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++11 %s -triple %itanium_abi_triple -emit-llvm 
-disable-llvm-passes -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++14 %s -triple %itanium_abi_triple -emit-llvm 
-disable-llvm-passes -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++17 %s -triple %itanium_abi_triple -emit-llvm 
-disable-llvm-passes -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++20 %s -triple %itanium_abi_triple -emit-llvm 
-disable-llvm-passes -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++23 %s -triple %itanium_abi_triple -emit-llvm 
-disable-llvm-passes -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+// RUN: %clang_cc1 -std=c++2c %s -triple %itanium_abi_triple -emit-llvm 
-disable-llvm-passes -o - -fexceptions -fcxx-exceptions -pedantic-errors | 
llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
+
+namespace cwg78 { // cwg78: partial
+// Under CWG78, this is valid, because 'k' has static storage duration, so is
+// zero-initialized.
+#ifdef VERIFY
+const int k;
+// expected-error@-1 {{default initialization of an object of const type 
'const int'}}
+#endif
+
+int f() {
+  static int i;
+  return i;
+}
+
+// Checking that static variable is zero-initialized,
+// and not default-initialized (which means no initialization in this case).
+
+// CHECK: @cwg78::f()::i = {{.*}} i32 0
+} // namespace cwg78
diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 4cce88fe0490f..ff50a11c3f525 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -506,7 +506,7 @@ C++ defect report implementation status
 https://cplusplus.github.io/CWG/issues/78.html";>78
 CD1
 Section 8.5 paragraph 9 should state it only applies to non-static 
objects
-Superseded by 
+Partial
   
   
 https://cplusplus.github.io/CWG/issues/79.html";>79

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


[clang] [llvm] [llvm] Add triples for managarm (PR #87845)

2024-05-29 Thread Alexander van der Grinten via cfe-commits

avdgrinten wrote:

Regarding the acceptance bar, I'd like to stress the following point: it is 
true that Managarm is not a mainstream OS (but neither are some of the other 
OSes that have existing LLVM and Clang targets); however, LLVM is an 
infrastructure project that is used by a lot of downstreams (e.g., out of tree 
compilers), and not being supported by LLVM seriously impacts our ability to 
integrate with downstream projects.

In fact, maintaining our LLVM patches has been quite easy ([and we've been 
doing that out-of-tree since 
2019](https://github.com/managarm/bootstrap-managarm/commit/565104262b7aa96995c80c86b6857ae872da6efa)),
 but maintaining patches for downstream compilers tends to be much more 
involved. This is especially true for Rust, where the mainstream tooling is not 
built in a way that allows us to easily apply out-of-tree patches to packages 
managed by `cargo` etc. One of the main reasons why we want to get into 
upstream LLVM now is that we also have a Rust port that we want to upstream, 
and upstream Rust wants us to submit the LLVM target first.

We are committed to maintain our LLVM port indefinitely, and we've been doing 
it out-of-tree already since LLVM 6.

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


[clang] [clang] fix merging of UsingShadowDecl (PR #80245)

2024-05-29 Thread Chuanqi Xu via cfe-commits

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


[clang] [clang] fix merging of UsingShadowDecl (PR #80245)

2024-05-29 Thread Chuanqi Xu via cfe-commits

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

LG. It looks not wise to block this good PR. After all, it is a change 6 lines. 
Let's go ahead.

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


[clang] [clang] fix merging of UsingShadowDecl (PR #80245)

2024-05-29 Thread Matheus Izvekov via cfe-commits

mizvekov wrote:

I have revived this PR after a long time.

The original ODR violation bad diagnostic from the GH issue is gone from main, 
so I have removed the test for it.
My best guess is that the ODR checking must have gotten weakened somehow.
I really don't have time to dig into it though.

The original bug is still there in main, is self evident from looking at the 
source code, and can be confirmed bad and that it gets fixed by just looking at 
the AST dump.

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


[clang] [clang] fix merging of UsingShadowDecl (PR #80245)

2024-05-29 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov updated 
https://github.com/llvm/llvm-project/pull/80245

>From 9763cc9e6f081bc28b74164c77a2b80ac42aec1c Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Thu, 1 Feb 2024 02:26:10 -0300
Subject: [PATCH] [clang] fix merging of UsingShadowDecl

Previously, when deciding if two UsingShadowDecls where mergeable,
we would incorrectly only look for both pointing to the exact redecla
ration, whereas the correct thing is to look for declarations to the
same entity.

This problem has existed as far back as 2013, introduced in commit
fd8634a09de71.

This problem could manifest itself as ODR check false positives
when importing modules.

Fixes: #80252
---
 clang/docs/ReleaseNotes.rst | 3 +++
 clang/lib/AST/ASTContext.cpp| 2 +-
 clang/test/Modules/cxx20-decls.cppm | 4 ++--
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 44035f48cb3f9..9dc93f53fe716 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -813,6 +813,9 @@ Bug Fixes to C++ Support
 - Clang now allows ``@$``` in raw string literals. Fixes (#GH93130).
 - Fix an assertion failure when checking invalid ``this`` usage in the wrong 
context. (Fixes #GH91536).
 - Clang no longer models dependent NTTP arguments as 
``TemplateParamObjectDecl`` s. Fixes (#GH84052).
+- Fix incorrect merging of modules which contain using declarations which 
shadow
+  other declarations. This could manifest as ODR checker false positives.
+  Fixes (`#80252 `_)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 06780ceba4074..73d3b152c49f1 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -6794,7 +6794,7 @@ bool ASTContext::isSameEntity(const NamedDecl *X, const 
NamedDecl *Y) const {
   // Using shadow declarations with the same target match.
   if (const auto *USX = dyn_cast(X)) {
 const auto *USY = cast(Y);
-return USX->getTargetDecl() == USY->getTargetDecl();
+return declaresSameEntity(USX->getTargetDecl(), USY->getTargetDecl());
   }
 
   // Using declarations with the same qualifier match. (We already know that
diff --git a/clang/test/Modules/cxx20-decls.cppm 
b/clang/test/Modules/cxx20-decls.cppm
index 9f0c40685b68f..0e8b59708ab4c 100644
--- a/clang/test/Modules/cxx20-decls.cppm
+++ b/clang/test/Modules/cxx20-decls.cppm
@@ -28,8 +28,8 @@ using xxx = baz::foo;
 // CHECK-NEXT: NamespaceDecl 0x[[BAZ_REDECL_ADDR:[^ ]*]] prev 0x[[BAZ_ADDR:[^ 
]*]]
 // CHECK:  TypeAliasDecl 0x[[ALIAS_REDECL_ADDR:[^ ]*]] prev 
0x[[ALIAS_ADDR:[^ ]*]]
 // FIXME: UsingShadowDecl should have been merged
-// CHECK:  UsingShadowDecl 0x{{[^ ]*}} <{{.*}}> col:{{.*}} imported in 
A. hidden implicit TypeAlias 0x[[ALIAS_REDECL_ADDR]] 'foo'
+// CHECK:  UsingShadowDecl 0x{{[^ ]*}} prev 0x[[SHADOW_ADDR:[^ ]*]] {{.*}} 
imported in A. {{.*}} 'foo'
 
 // CHECK-LABEL: Dumping baz:
 // CHECK-NEXT: NamespaceDecl 0x[[BAZ_ADDR]] <{{.*}}> line:{{.*}} baz
-// CHECK:  UsingShadowDecl 0x[[SHADOW_ADDR:[^ ]*]] <{{.*}}> col:{{.*}} 
implicit TypeAlias 0x[[ALIAS_ADDR]] 'foo'
+// CHECK:  UsingShadowDecl 0x[[SHADOW_ADDR]] {{.*}} 'foo'

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


[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)

2024-05-29 Thread Shengchen Kan via cfe-commits

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

LGTM

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


[clang] 498da62 - [NFC] [clang] add tests for merging of UsingShadowDecl

2024-05-29 Thread Matheus Izvekov via cfe-commits

Author: Matheus Izvekov
Date: 2024-05-30T02:56:57-03:00
New Revision: 498da62088b22ef1d4e90d6021a80ae7bab6abae

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

LOG: [NFC] [clang] add tests for merging of UsingShadowDecl

Added: 
clang/test/Modules/cxx20-decls.cppm

Modified: 


Removed: 




diff  --git a/clang/test/Modules/cxx20-decls.cppm 
b/clang/test/Modules/cxx20-decls.cppm
new file mode 100644
index 0..9f0c40685b68f
--- /dev/null
+++ b/clang/test/Modules/cxx20-decls.cppm
@@ -0,0 +1,35 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: cd %t
+//
+// RUN: %clang_cc1 -std=c++20 -I %t %t/A.cppm -emit-module-interface -o 
%t/A.pcm -verify
+// RUN: %clang_cc1 -std=c++20 -I %t %t/B.cpp -fmodule-file=A=%t/A.pcm 
-fsyntax-only -verify -ast-dump-all -ast-dump-filter baz | FileCheck %s
+
+//--- foo.h
+namespace baz {
+  using foo = char;
+  using baz::foo;
+}
+
+//--- A.cppm
+// expected-no-diagnostics
+module;
+#include "foo.h"
+export module A;
+
+//--- B.cpp
+// expected-no-diagnostics
+#include "foo.h"
+import A;
+// Since modules are loaded lazily, force loading by performing a lookup.
+using xxx = baz::foo;
+
+// CHECK-LABEL: Dumping baz:
+// CHECK-NEXT: NamespaceDecl 0x[[BAZ_REDECL_ADDR:[^ ]*]] prev 0x[[BAZ_ADDR:[^ 
]*]]
+// CHECK:  TypeAliasDecl 0x[[ALIAS_REDECL_ADDR:[^ ]*]] prev 
0x[[ALIAS_ADDR:[^ ]*]]
+// FIXME: UsingShadowDecl should have been merged
+// CHECK:  UsingShadowDecl 0x{{[^ ]*}} <{{.*}}> col:{{.*}} imported in 
A. hidden implicit TypeAlias 0x[[ALIAS_REDECL_ADDR]] 'foo'
+
+// CHECK-LABEL: Dumping baz:
+// CHECK-NEXT: NamespaceDecl 0x[[BAZ_ADDR]] <{{.*}}> line:{{.*}} baz
+// CHECK:  UsingShadowDecl 0x[[SHADOW_ADDR:[^ ]*]] <{{.*}}> col:{{.*}} 
implicit TypeAlias 0x[[ALIAS_ADDR]] 'foo'



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


[clang] Revert "[DebugInfo] Add flag to only emit referenced member functions" (PR #93767)

2024-05-29 Thread David Blaikie via cfe-commits

dwblaikie wrote:

Thanks! Sorry I didn't get to it sooner

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


[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)

2024-05-29 Thread Freddy Ye via cfe-commits

https://github.com/FreddyLeaf updated 
https://github.com/llvm/llvm-project/pull/92338

>From 41fbc18c7a4a26b11bc4b772bbe2e384ad9d9dbc Mon Sep 17 00:00:00 2001
From: Freddy Ye 
Date: Fri, 10 May 2024 16:29:55 +0800
Subject: [PATCH 01/13] [X86] Support EGPR for inline assembly.

"jR": explictly enables EGPR
"r": enables/disables EGPR w/wo -mapx-inline-asm-use-gpr32
-mapx-inline-asm-use-gpr32 will also define a new Macro:
__APX_INLINE_ASM_USE_GPR32__
---
 clang/include/clang/Driver/Options.td |  2 +
 clang/lib/Basic/Targets/X86.cpp   | 26 +
 clang/lib/Basic/Targets/X86.h |  1 +
 clang/lib/Driver/ToolChains/Arch/X86.cpp  |  2 +
 .../Driver/x86-apx-inline-asm-use-gpr32.cpp   |  3 +
 clang/test/Preprocessor/x86_target_features.c |  3 +
 llvm/lib/Target/X86/X86.td|  3 +
 llvm/lib/Target/X86/X86ISelLowering.cpp   | 57 +--
 .../CodeGen/X86/inline-asm-jR-constraint.ll   | 19 +++
 .../CodeGen/X86/inline-asm-r-constraint.ll| 16 ++
 10 files changed, 127 insertions(+), 5 deletions(-)
 create mode 100644 clang/test/Driver/x86-apx-inline-asm-use-gpr32.cpp
 create mode 100644 llvm/test/CodeGen/X86/inline-asm-jR-constraint.ll
 create mode 100644 llvm/test/CodeGen/X86/inline-asm-r-constraint.ll

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 73a2518480e9b..20a7c482bbf06 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6281,6 +6281,8 @@ def mno_apx_features_EQ : CommaJoined<["-"], 
"mno-apx-features=">, Group, Alias, 
AliasArgs<["egpr","push2pop2","ppx", "ndd"]>;
 def mno_apxf : Flag<["-"], "mno-apxf">, Alias, 
AliasArgs<["egpr","push2pop2","ppx","ndd"]>;
+def mapx_inline_asm_use_gpr32 : Flag<["-"], "mapx-inline-asm-use-gpr32">, 
Group,
+HelpText<"Enable use of GPR32 in inline 
assembly for APX">;
 } // let Flags = [TargetSpecific]
 
 // VE feature flags
diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index 67e2126cf766b..9e61b6e6d6441 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -450,6 +450,8 @@ bool 
X86TargetInfo::handleTargetFeatures(std::vector &Features,
   HasFullBFloat16 = true;
 } else if (Feature == "+egpr") {
   HasEGPR = true;
+} else if (Feature == "+inline-asm-use-gpr32") {
+  HasInlineAsmUseGPR32 = true;
 } else if (Feature == "+push2pop2") {
   HasPush2Pop2 = true;
 } else if (Feature == "+ppx") {
@@ -974,6 +976,8 @@ void X86TargetInfo::getTargetDefines(const LangOptions 
&Opts,
   // Condition here is aligned with the feature set of mapxf in Options.td
   if (HasEGPR && HasPush2Pop2 && HasPPX && HasNDD)
 Builder.defineMacro("__APX_F__");
+  if (HasInlineAsmUseGPR32)
+Builder.defineMacro("__APX_INLINE_ASM_USE_GPR32__");
 
   // Each case falls through to the previous one here.
   switch (SSELevel) {
@@ -1493,6 +1497,15 @@ bool X86TargetInfo::validateAsmConstraint(
   case 'C': // SSE floating point constant.
   case 'G': // x87 floating point constant.
 return true;
+  case 'j':
+Name++;
+switch (*Name) {
+default:
+  return false;
+case 'R':
+  Info.setAllowsRegister();
+  return true;
+}
   case '@':
 // CC condition changes.
 if (auto Len = matchAsmCCConstraint(Name)) {
@@ -1764,6 +1777,19 @@ std::string X86TargetInfo::convertConstraint(const char 
*&Constraint) const {
   // to the next constraint.
   return std::string("^") + std::string(Constraint++, 2);
 }
+  case 'j':
+switch (Constraint[1]) {
+default:
+  // Break from inner switch and fall through (copy single char),
+  // continue parsing after copying the current constraint into
+  // the return string.
+  break;
+case 'R':
+  // "^" hints llvm that this is a 2 letter constraint.
+  // "Constraint++" is used to promote the string iterator
+  // to the next constraint.
+  return std::string("^") + std::string(Constraint++, 2);
+}
 [[fallthrough]];
   default:
 return std::string(1, *Constraint);
diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h
index c14e4d5f433d8..69c68ee80f3ba 100644
--- a/clang/lib/Basic/Targets/X86.h
+++ b/clang/lib/Basic/Targets/X86.h
@@ -174,6 +174,7 @@ class LLVM_LIBRARY_VISIBILITY X86TargetInfo : public 
TargetInfo {
   bool HasNDD = false;
   bool HasCCMP = false;
   bool HasCF = false;
+  bool HasInlineAsmUseGPR32 = false;
 
 protected:
   llvm::X86::CPUKind CPU = llvm::X86::CK_None;
diff --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp 
b/clang/lib/Driver/ToolChains/Arch/X86.cpp
index 53e26a9f8e229..085ff4824a9b0 100644
--- a/clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -309,4 +309,6 @@ void x86::getX86TargetFeatures(const Driver &D, const 
llvm::Triple &Triple,
 Features.push_back("+prefer-no-gat

[clang] Pass LangOpts from CompilerInstance to DependencyScanningWorker (PR #93753)

2024-05-29 Thread via cfe-commits

cor3ntin wrote:

Thanks for working on that. Your change is pretty much what i expected yes, 
it's great!

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


[clang] [clang-format] Insert a space between a keyword and a literal (PR #93632)

2024-05-29 Thread Owen Pan via cfe-commits

https://github.com/owenca updated 
https://github.com/llvm/llvm-project/pull/93632

>From be3cb7662b789c7ffa61aab55c9390543cbab2ca Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Tue, 28 May 2024 19:36:36 -0700
Subject: [PATCH 1/2] [clang-format] Insert a space between a keyword and a
 literal

Fixes #93603.
---
 clang/lib/Format/FormatToken.h   | 23 +++
 clang/lib/Format/TokenAnnotator.cpp  |  8 ++--
 clang/lib/Format/UnwrappedLineParser.cpp |  9 +
 clang/unittests/Format/FormatTest.cpp|  6 ++
 4 files changed, 36 insertions(+), 10 deletions(-)

diff --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h
index 8792f4c750748..f663a80cd3917 100644
--- a/clang/lib/Format/FormatToken.h
+++ b/clang/lib/Format/FormatToken.h
@@ -727,6 +727,29 @@ struct FormatToken {
 return isOneOf(tok::star, tok::amp, tok::ampamp);
   }
 
+  bool isAltOperator() const {
+assert(!TokenText.empty());
+if (!isalpha(TokenText[0]))
+  return false;
+
+switch (Tok.getKind()) {
+case tok::ampamp:
+case tok::ampequal:
+case tok::amp:
+case tok::pipe:
+case tok::tilde:
+case tok::exclaim:
+case tok::exclaimequal:
+case tok::pipepipe:
+case tok::pipeequal:
+case tok::caret:
+case tok::caretequal:
+  return true;
+default:
+  return false;
+}
+  }
+
   bool isUnaryOperator() const {
 switch (Tok.getKind()) {
 case tok::plus:
diff --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 7c4c76a91f2c5..58a82e6daca73 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -4846,8 +4846,12 @@ bool TokenAnnotator::spaceRequiredBefore(const 
AnnotatedLine &Line,
 Right.is(TT_TemplateOpener)) {
   return true;
 }
-if (Left.Tok.getIdentifierInfo() && Right.is(tok::numeric_constant))
-  return Right.TokenText[0] != '.';
+if (Right.Tok.isLiteral()) {
+  if (Left.is(tok::identifier))
+return Right.TokenText[0] != '.';
+  if (Left.isAltOperator())
+return true;
+}
   } else if (Style.isProto()) {
 if (Right.is(tok::period) &&
 Left.isOneOf(Keywords.kw_optional, Keywords.kw_required,
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index b6f7567adc140..b2f8108edeaec 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -1410,13 +1410,6 @@ void UnwrappedLineParser::readTokenWithJavaScriptASI() {
   }
 }
 
-static bool isAltOperator(const FormatToken &Tok) {
-  return isalpha(Tok.TokenText[0]) &&
- Tok.isOneOf(tok::ampamp, tok::ampequal, tok::amp, tok::pipe,
- tok::tilde, tok::exclaim, tok::exclaimequal, 
tok::pipepipe,
- tok::pipeequal, tok::caret, tok::caretequal);
-}
-
 void UnwrappedLineParser::parseStructuralElement(
 const FormatToken *OpeningBrace, IfStmtKind *IfKind,
 FormatToken **IfLeftBrace, bool *HasDoWhile, bool *HasLabel) {
@@ -1699,7 +1692,7 @@ void UnwrappedLineParser::parseStructuralElement(
   for (const bool InRequiresExpression =
OpeningBrace && OpeningBrace->is(TT_RequiresExpressionLBrace);
!eof();) {
-if (IsCpp && isAltOperator(*FormatTok)) {
+if (IsCpp && FormatTok->isAltOperator()) {
   if (auto *Next = Tokens->peekNextToken(/*SkipComment=*/true);
   Next && Next->isBinaryOperator()) {
 FormatTok->Tok.setKind(tok::identifier);
diff --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 76eb2b6cd994c..59f1ff6a4b296 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -27452,6 +27452,12 @@ TEST_F(FormatTest, AlignUTFCommentsAndStringLiterals) {
Style);
 }
 
+TEST_F(FormatTest, SpaceBetweenKeywordAndLiteral) {
+  verifyFormat("return .5;");
+  verifyFormat("return not '5';");
+  verifyFormat("return sizeof \"5\";");
+}
+
 } // namespace
 } // namespace test
 } // namespace format

>From 07276bc90bbd0f6c04e5a374e53cd1309ce9c5f0 Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Wed, 29 May 2024 22:33:00 -0700
Subject: [PATCH 2/2] Improve code in TokenAnnotator.cpp and give
 `isAltOperator` a better name.

---
 clang/lib/Format/FormatToken.h   |  2 +-
 clang/lib/Format/TokenAnnotator.cpp  | 12 ++--
 clang/lib/Format/UnwrappedLineParser.cpp |  2 +-
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h
index f663a80cd3917..e4a4f27e502b1 100644
--- a/clang/lib/Format/FormatToken.h
+++ b/clang/lib/Format/FormatToken.h
@@ -727,7 +727,7 @@ struct FormatToken {
 return isOneOf(tok::star, tok::amp, tok::ampamp);
   }
 
-  bool isAltOperator() const {
+  bool isCppAlternativeOperatorKeyword() const {
 assert(!TokenText.empty());
 if (!isalpha(TokenText[0]))

[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)

2024-05-29 Thread Freddy Ye via cfe-commits


@@ -1,21 +1,27 @@
 ; Check r16-r31 can not be used with 'q','r','l' constraint for backward 
compatibility.
-; RUN: not llc < %s -mtriple=x86_64-unknown-unknown -mattr=+egpr 2>&1 | 
FileCheck %s
+; RUN: not llc < %s -mtriple=x86_64-unknown-unknown -mattr=+egpr 2>&1 | 
FileCheck %s --check-prefix=ERR

FreddyLeaf wrote:

[e752556](https://github.com/llvm/llvm-project/pull/92338/commits/e752556c06ac25d905c6e642bdcb5e9244db5da3)

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


[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)

2024-05-29 Thread Freddy Ye via cfe-commits


@@ -57999,13 +58020,25 @@ X86TargetLowering::getRegForInlineAsmConstraint(const 
TargetRegisterInfo *TRI,
 case 'q':   // GENERAL_REGS in 64-bit mode, Q_REGS in 32-bit mode.
   if (Subtarget.is64Bit()) {
 if (VT == MVT::i8 || VT == MVT::i1)
-  return std::make_pair(0U, &X86::GR8_NOREX2RegClass);
+  return std::make_pair(0U, Subtarget.hasEGPR() &&
+Subtarget.useInlineAsmGPR32()

FreddyLeaf wrote:

[e752556](https://github.com/llvm/llvm-project/pull/92338/commits/e752556c06ac25d905c6e642bdcb5e9244db5da3)

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


[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)

2024-05-29 Thread Freddy Ye via cfe-commits




FreddyLeaf wrote:

[e752556](https://github.com/llvm/llvm-project/pull/92338/commits/e752556c06ac25d905c6e642bdcb5e9244db5da3)

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


[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)

2024-05-29 Thread Freddy Ye via cfe-commits




FreddyLeaf wrote:

[e752556](https://github.com/llvm/llvm-project/pull/92338/commits/e752556c06ac25d905c6e642bdcb5e9244db5da3)

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


[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)

2024-05-29 Thread Freddy Ye via cfe-commits


@@ -0,0 +1,25 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: not llc -mtriple=x86_64 < %s | FileCheck %s
+; RUN: not llc -mtriple=x86_64 -mattr=+egpr < %s | FileCheck %s

FreddyLeaf wrote:

[e752556](https://github.com/llvm/llvm-project/pull/92338/commits/e752556c06ac25d905c6e642bdcb5e9244db5da3)

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


[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)

2024-05-29 Thread Freddy Ye via cfe-commits

https://github.com/FreddyLeaf updated 
https://github.com/llvm/llvm-project/pull/92338

>From 41fbc18c7a4a26b11bc4b772bbe2e384ad9d9dbc Mon Sep 17 00:00:00 2001
From: Freddy Ye 
Date: Fri, 10 May 2024 16:29:55 +0800
Subject: [PATCH 01/13] [X86] Support EGPR for inline assembly.

"jR": explictly enables EGPR
"r": enables/disables EGPR w/wo -mapx-inline-asm-use-gpr32
-mapx-inline-asm-use-gpr32 will also define a new Macro:
__APX_INLINE_ASM_USE_GPR32__
---
 clang/include/clang/Driver/Options.td |  2 +
 clang/lib/Basic/Targets/X86.cpp   | 26 +
 clang/lib/Basic/Targets/X86.h |  1 +
 clang/lib/Driver/ToolChains/Arch/X86.cpp  |  2 +
 .../Driver/x86-apx-inline-asm-use-gpr32.cpp   |  3 +
 clang/test/Preprocessor/x86_target_features.c |  3 +
 llvm/lib/Target/X86/X86.td|  3 +
 llvm/lib/Target/X86/X86ISelLowering.cpp   | 57 +--
 .../CodeGen/X86/inline-asm-jR-constraint.ll   | 19 +++
 .../CodeGen/X86/inline-asm-r-constraint.ll| 16 ++
 10 files changed, 127 insertions(+), 5 deletions(-)
 create mode 100644 clang/test/Driver/x86-apx-inline-asm-use-gpr32.cpp
 create mode 100644 llvm/test/CodeGen/X86/inline-asm-jR-constraint.ll
 create mode 100644 llvm/test/CodeGen/X86/inline-asm-r-constraint.ll

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 73a2518480e9b..20a7c482bbf06 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6281,6 +6281,8 @@ def mno_apx_features_EQ : CommaJoined<["-"], 
"mno-apx-features=">, Group, Alias, 
AliasArgs<["egpr","push2pop2","ppx", "ndd"]>;
 def mno_apxf : Flag<["-"], "mno-apxf">, Alias, 
AliasArgs<["egpr","push2pop2","ppx","ndd"]>;
+def mapx_inline_asm_use_gpr32 : Flag<["-"], "mapx-inline-asm-use-gpr32">, 
Group,
+HelpText<"Enable use of GPR32 in inline 
assembly for APX">;
 } // let Flags = [TargetSpecific]
 
 // VE feature flags
diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index 67e2126cf766b..9e61b6e6d6441 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -450,6 +450,8 @@ bool 
X86TargetInfo::handleTargetFeatures(std::vector &Features,
   HasFullBFloat16 = true;
 } else if (Feature == "+egpr") {
   HasEGPR = true;
+} else if (Feature == "+inline-asm-use-gpr32") {
+  HasInlineAsmUseGPR32 = true;
 } else if (Feature == "+push2pop2") {
   HasPush2Pop2 = true;
 } else if (Feature == "+ppx") {
@@ -974,6 +976,8 @@ void X86TargetInfo::getTargetDefines(const LangOptions 
&Opts,
   // Condition here is aligned with the feature set of mapxf in Options.td
   if (HasEGPR && HasPush2Pop2 && HasPPX && HasNDD)
 Builder.defineMacro("__APX_F__");
+  if (HasInlineAsmUseGPR32)
+Builder.defineMacro("__APX_INLINE_ASM_USE_GPR32__");
 
   // Each case falls through to the previous one here.
   switch (SSELevel) {
@@ -1493,6 +1497,15 @@ bool X86TargetInfo::validateAsmConstraint(
   case 'C': // SSE floating point constant.
   case 'G': // x87 floating point constant.
 return true;
+  case 'j':
+Name++;
+switch (*Name) {
+default:
+  return false;
+case 'R':
+  Info.setAllowsRegister();
+  return true;
+}
   case '@':
 // CC condition changes.
 if (auto Len = matchAsmCCConstraint(Name)) {
@@ -1764,6 +1777,19 @@ std::string X86TargetInfo::convertConstraint(const char 
*&Constraint) const {
   // to the next constraint.
   return std::string("^") + std::string(Constraint++, 2);
 }
+  case 'j':
+switch (Constraint[1]) {
+default:
+  // Break from inner switch and fall through (copy single char),
+  // continue parsing after copying the current constraint into
+  // the return string.
+  break;
+case 'R':
+  // "^" hints llvm that this is a 2 letter constraint.
+  // "Constraint++" is used to promote the string iterator
+  // to the next constraint.
+  return std::string("^") + std::string(Constraint++, 2);
+}
 [[fallthrough]];
   default:
 return std::string(1, *Constraint);
diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h
index c14e4d5f433d8..69c68ee80f3ba 100644
--- a/clang/lib/Basic/Targets/X86.h
+++ b/clang/lib/Basic/Targets/X86.h
@@ -174,6 +174,7 @@ class LLVM_LIBRARY_VISIBILITY X86TargetInfo : public 
TargetInfo {
   bool HasNDD = false;
   bool HasCCMP = false;
   bool HasCF = false;
+  bool HasInlineAsmUseGPR32 = false;
 
 protected:
   llvm::X86::CPUKind CPU = llvm::X86::CK_None;
diff --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp 
b/clang/lib/Driver/ToolChains/Arch/X86.cpp
index 53e26a9f8e229..085ff4824a9b0 100644
--- a/clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -309,4 +309,6 @@ void x86::getX86TargetFeatures(const Driver &D, const 
llvm::Triple &Triple,
 Features.push_back("+prefer-no-gat

[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)

2024-05-29 Thread Freddy Ye via cfe-commits


@@ -1,21 +1,27 @@
 ; Check r16-r31 can not be used with 'q','r','l' constraint for backward 
compatibility.
-; RUN: not llc < %s -mtriple=x86_64-unknown-unknown -mattr=+egpr 2>&1 | 
FileCheck %s
+; RUN: not llc < %s -mtriple=x86_64-unknown-unknown -mattr=+egpr 2>&1 | 
FileCheck %s --check-prefix=ERR

FreddyLeaf wrote:

oh, I got your point. I messed with line 5

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


[clang] [OpenACC] Loop construct basic Sema and AST work (PR #93742)

2024-05-29 Thread Erich Keane via cfe-commits


@@ -0,0 +1,164 @@
+
+// RUN: %clang_cc1 %s -fopenacc -ast-dump | FileCheck %s
+
+// Test this with PCH.
+// RUN: %clang_cc1 %s -fopenacc -emit-pch -o %t %s
+// RUN: %clang_cc1 %s -fopenacc -include-pch %t -ast-dump-all | FileCheck %s
+
+#ifndef PCH_HELPER
+#define PCH_HELPER
+
+void NormalFunc() {
+  // CHECK-LABEL: NormalFunc
+  // CHECK-NEXT: CompoundStmt
+
+#pragma acc loop
+  for(;;);
+  // CHECK-NEXT: OpenACCLoopConstruct{{.*}} 
+  // CHECK-NEXT: ForStmt
+  // CHECK-NEXT: <<>>
+  // CHECK-NEXT: <<>>
+  // CHECK-NEXT: <<>>
+  // CHECK-NEXT: <<>>
+  // CHECK-NEXT: NullStmt
+
+  int array[5];
+  // CHECK-NEXT: DeclStmt
+  // CHECK-NEXT: VarDecl
+#pragma acc loop
+  for(auto x : array){}
+  // CHECK-NEXT: OpenACCLoopConstruct{{.*}} 
+  // CHECK-NEXT: CXXForRangeStmt
+  // CHECK: CompoundStmt
+
+#pragma acc parallel
+  // CHECK-NEXT: OpenACCComputeConstruct {{.*}}parallel
+  // CHECK-NEXT: CompoundStmt
+  {
+#pragma acc parallel
+// CHECK-NEXT: OpenACCComputeConstruct [[PAR_ADDR:[0-9a-fx]+]] 
{{.*}}parallel
+// CHECK-NEXT: CompoundStmt
+{
+#pragma acc loop
+  for(;;);
+// CHECK-NEXT: OpenACCLoopConstruct{{.*}} parent: [[PAR_ADDR]]
+// CHECK-NEXT: ForStmt
+// CHECK-NEXT: <<>>
+// CHECK-NEXT: <<>>
+// CHECK-NEXT: <<>>
+// CHECK-NEXT: <<>>
+// CHECK-NEXT: NullStmt
+}
+  }
+}
+
+template
+void TemplFunc() {
+  // CHECK-LABEL: FunctionTemplateDecl {{.*}}TemplFunc
+  // CHECK-NEXT: TemplateTypeParmDecl
+  // CHECK-NEXT: FunctionDecl{{.*}}TemplFunc
+  // CHECK-NEXT: CompoundStmt
+
+#pragma acc loop
+  // CHECK-NEXT: OpenACCLoopConstruct{{.*}} 
+  for(typename T::type t = 0; t < 5;++t) {
+  // CHECK-NEXT: ForStmt
+  // CHECK-NEXT: DeclStmt
+  // CHECK-NEXT: VarDecl{{.*}} referenced t 'typename T::type'
+  // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 0
+  // CHECK-NEXT: <<>
+  // CHECK-NEXT: BinaryOperator{{.*}} '' '<'
+  // CHECK-NEXT: DeclRefExpr {{.*}} 'typename T::type' lvalue Var
+  // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 5
+  // CHECK-NEXT: UnaryOperator{{.*}} '' lvalue prefix '++'
+  // CHECK-NEXT: DeclRefExpr {{.*}} 'typename T::type' lvalue Var
+  // CHECK-NEXT: CompoundStmt
+typename T::type I;
+  // CHECK-NEXT: DeclStmt
+  // CHECK-NEXT: VarDecl{{.*}} I 'typename T::type'
+
+  }
+
+#pragma acc parallel
+  {
+// CHECK-NEXT: OpenACCComputeConstruct {{.*}}parallel
+// CHECK-NEXT: CompoundStmt
+#pragma acc parallel
+{
+// CHECK-NEXT: OpenACCComputeConstruct [[PAR_ADDR_UNINST:[0-9a-fx]+]] 
{{.*}}parallel
+// CHECK-NEXT: CompoundStmt
+#pragma acc loop
+// CHECK-NEXT: OpenACCLoopConstruct{{.*}} parent: [[PAR_ADDR_UNINST]]

erichkeane wrote:

Note:  Need to make sure this works with 2 child loops and that the visitor 
doesn't give up after the 1st.

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


[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)

2024-05-29 Thread Freddy Ye via cfe-commits


@@ -0,0 +1,25 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: not llc -mtriple=x86_64 < %s | FileCheck %s
+; RUN: not llc -mtriple=x86_64 -mattr=+egpr < %s | FileCheck %s

FreddyLeaf wrote:

I'll try. If so, we can refine llvm/test/CodeGen/X86/apx/asm-constraint.ll as 
well.

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


[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)

2024-05-29 Thread Freddy Ye via cfe-commits


@@ -1,21 +1,27 @@
 ; Check r16-r31 can not be used with 'q','r','l' constraint for backward 
compatibility.
-; RUN: not llc < %s -mtriple=x86_64-unknown-unknown -mattr=+egpr 2>&1 | 
FileCheck %s
+; RUN: not llc < %s -mtriple=x86_64-unknown-unknown -mattr=+egpr 2>&1 | 
FileCheck %s --check-prefix=ERR

FreddyLeaf wrote:

no, it didn't add `2>&1`

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


[clang] [compiler-rt] [asan][windows] Eliminate the static asan runtime on windows (PR #93770)

2024-05-29 Thread Charlie Barto via cfe-commits

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


[clang] [llvm] Add option to generate additional debug info for expression dereferencing pointer to pointers. (PR #81545)

2024-05-29 Thread Matheus Izvekov via cfe-commits

mizvekov wrote:

I think the fix for the breakage is to just pin the new test to a fixed triple 
like so `-triple x86_64-linux-gnu`.

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


[clang] [compiler-rt] [asan][windows] Eliminate the static asan runtime on windows (PR #93770)

2024-05-29 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-platform-windows

Author: Charlie Barto (barcharcraz)


Changes

Originally #81677

That PR was reverted due to breaking the MSVC build. The breakage in question 
was just msvc not understanding the "optnone" attribute, which has been 
corrected.

---

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


56 Files Affected:

- (modified) clang/lib/Driver/SanitizerArgs.cpp (+10-4) 
- (modified) clang/lib/Driver/ToolChains/MSVC.cpp (+11-15) 
- (modified) clang/test/Driver/cl-link.c (+4-6) 
- (modified) compiler-rt/CMakeLists.txt (+6-2) 
- (modified) compiler-rt/lib/asan/CMakeLists.txt (+82-77) 
- (modified) compiler-rt/lib/asan/asan_flags.cpp (+85-11) 
- (modified) compiler-rt/lib/asan/asan_globals_win.cpp (+3-1) 
- (modified) compiler-rt/lib/asan/asan_malloc_win.cpp (+42-55) 
- (added) compiler-rt/lib/asan/asan_malloc_win_thunk.cpp (+229) 
- (added) compiler-rt/lib/asan/asan_win_common_runtime_thunk.cpp (+112) 
- (added) compiler-rt/lib/asan/asan_win_common_runtime_thunk.h (+38) 
- (removed) compiler-rt/lib/asan/asan_win_dll_thunk.cpp (-165) 
- (modified) compiler-rt/lib/asan/asan_win_dynamic_runtime_thunk.cpp (+14-90) 
- (added) compiler-rt/lib/asan/asan_win_static_runtime_thunk.cpp (+110) 
- (modified) compiler-rt/lib/asan/tests/CMakeLists.txt (+1-1) 
- (modified) compiler-rt/lib/profile/CMakeLists.txt (+6) 
- (modified) compiler-rt/lib/sanitizer_common/CMakeLists.txt (+11-44) 
- (modified) compiler-rt/lib/sanitizer_common/sanitizer_common_interface.inc 
(+6) 
- (removed) 
compiler-rt/lib/sanitizer_common/sanitizer_coverage_win_dll_thunk.cpp (-20) 
- (renamed) 
compiler-rt/lib/sanitizer_common/sanitizer_coverage_win_runtime_thunk.cpp 
(+12-9) 
- (removed) 
compiler-rt/lib/sanitizer_common/sanitizer_coverage_win_weak_interception.cpp 
(-23) 
- (removed) compiler-rt/lib/sanitizer_common/sanitizer_win_dll_thunk.cpp (-101) 
- (removed) compiler-rt/lib/sanitizer_common/sanitizer_win_dll_thunk.h (-181) 
- (removed) 
compiler-rt/lib/sanitizer_common/sanitizer_win_dynamic_runtime_thunk.cpp (-26) 
- (added) compiler-rt/lib/sanitizer_common/sanitizer_win_immortalize.h (+71) 
- (added) compiler-rt/lib/sanitizer_common/sanitizer_win_interception.cpp 
(+156) 
- (added) compiler-rt/lib/sanitizer_common/sanitizer_win_interception.h (+32) 
- (added) compiler-rt/lib/sanitizer_common/sanitizer_win_thunk_interception.cpp 
(+110) 
- (added) compiler-rt/lib/sanitizer_common/sanitizer_win_thunk_interception.h 
(+85) 
- (removed) 
compiler-rt/lib/sanitizer_common/sanitizer_win_weak_interception.cpp (-94) 
- (removed) compiler-rt/lib/sanitizer_common/sanitizer_win_weak_interception.h 
(-32) 
- (modified) compiler-rt/lib/ubsan/CMakeLists.txt (+3-24) 
- (removed) compiler-rt/lib/ubsan/ubsan_win_dll_thunk.cpp (-20) 
- (renamed) compiler-rt/lib/ubsan/ubsan_win_runtime_thunk.cpp (+7-4) 
- (removed) compiler-rt/lib/ubsan/ubsan_win_weak_interception.cpp (-23) 
- (modified) 
compiler-rt/test/asan/TestCases/Darwin/interface_symbols_darwin.cpp (+3) 
- (modified) compiler-rt/test/asan/TestCases/Linux/interface_symbols_linux.cpp 
(+3) 
- (modified) compiler-rt/test/asan/TestCases/Windows/double_free.cpp (+3-3) 
- (modified) compiler-rt/test/asan/TestCases/Windows/free_hook_realloc.cpp (-3) 
- (modified) compiler-rt/test/asan/TestCases/Windows/malloc_left_oob.cpp (+1-1) 
- (modified) compiler-rt/test/asan/TestCases/Windows/malloc_right_oob.cpp 
(+1-1) 
- (modified) compiler-rt/test/asan/TestCases/Windows/malloc_uaf.cpp (+2-2) 
- (modified) compiler-rt/test/asan/TestCases/Windows/msvc/dll_and_lib.cpp 
(+2-3) 
- (modified) 
compiler-rt/test/asan/TestCases/Windows/msvc/dll_large_function.cpp (+1-2) 
- (modified) compiler-rt/test/asan/TestCases/Windows/realloc_left_oob.cpp 
(+1-1) 
- (modified) compiler-rt/test/asan/TestCases/Windows/realloc_right_oob.cpp 
(+1-1) 
- (modified) compiler-rt/test/asan/TestCases/Windows/realloc_uaf.cpp (+2-2) 
- (modified) compiler-rt/test/asan/TestCases/Windows/symbols_path.cpp (+1-1) 
- (modified) compiler-rt/test/asan/TestCases/Windows/unsymbolized.cpp (+1-1) 
- (modified) compiler-rt/test/asan/TestCases/Windows/use_after_realloc.cpp 
(+2-2) 
- (modified) compiler-rt/test/asan/TestCases/debug_double_free.cpp (-3) 
- (modified) compiler-rt/test/asan/TestCases/debug_report.cpp (-3) 
- (modified) compiler-rt/test/asan/TestCases/default_options.cpp (-4) 
- (modified) compiler-rt/test/asan/TestCases/on_error_callback.cpp (-3) 
- (modified) compiler-rt/test/asan/TestCases/report_error_summary.cpp (-3) 
- (modified) compiler-rt/test/asan/lit.cfg.py (+21-2) 


``diff
diff --git a/clang/lib/Driver/SanitizerArgs.cpp 
b/clang/lib/Driver/SanitizerArgs.cpp
index 273f215ca94a8..7b7fd2d9d4742 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -909,10 +909,16 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
 DiagnoseErrors);
   }
 
-  SharedRuntime =
-  Args.

[clang] [llvm] Add option to generate additional debug info for expression dereferencing pointer to pointers. (PR #81545)

2024-05-29 Thread Mehdi Amini via cfe-commits

joker-eph wrote:

Reverted in 7d4a45d98275e669bda40410f064891beb3480ce ; test is failing like 
this on Windows:

```
# RUN: at line 3
c:\ws\buildbot\premerge-monolithic-windows\build\bin\clang.exe -cc1 
-internal-isystem 
C:\ws\buildbot\premerge-monolithic-windows\build\lib\clang\19\include 
-nostdsysteminc 
C:\ws\buildbot\premerge-monolithic-windows\llvm-project\clang\test\CodeGenCXX\debug-info-ptr-to-ptr.cpp
 -fdebug-info-for-profiling -debug-info-kind=constructor -emit-llvm -o - | 
c:\ws\buildbot\premerge-monolithic-windows\build\bin\filecheck.exe 
C:\ws\buildbot\premerge-monolithic-windows\llvm-project\clang\test\CodeGenCXX\debug-info-ptr-to-ptr.cpp
# executed command: 
'c:\ws\buildbot\premerge-monolithic-windows\build\bin\clang.exe' -cc1 
-internal-isystem 
'C:\ws\buildbot\premerge-monolithic-windows\build\lib\clang\19\include' 
-nostdsysteminc 
'C:\ws\buildbot\premerge-monolithic-windows\llvm-project\clang\test\CodeGenCXX\debug-info-ptr-to-ptr.cpp'
 -fdebug-info-for-profiling -debug-info-kind=constructor -emit-llvm -o -
# executed command: 
'c:\ws\buildbot\premerge-monolithic-windows\build\bin\filecheck.exe' 
'C:\ws\buildbot\premerge-monolithic-windows\llvm-project\clang\test\CodeGenCXX\debug-info-ptr-to-ptr.cpp'
# .---command stderr
# | 
C:\ws\buildbot\premerge-monolithic-windows\llvm-project\clang\test\CodeGenCXX\debug-info-ptr-to-ptr.cpp:60:17:
 error: CHECK-LABEL: expected string not found in input
# | // CHECK-LABEL: define dso_local noundef signext i8 @{{.*}}func4{{.*}}(
# | ^
# | :48:54: note: scanning from here
# | define dso_local noundef i32 @"?func3@@YAHPEAVB@@@Z"(ptr noundef %b) #0 
!dbg !45 {
# |  ^
# | :66:1: note: possible intended match here
# | define dso_local noundef i8 @"?func4@@YADPEAVC@@@Z"(ptr noundef %c) #0 !dbg 
!55 {
# | ^
# | 
```



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


[clang] [clang] Lower _BitInt(129+) to a different type in LLVM IR (PR #91364)

2024-05-29 Thread Eli Friedman via cfe-commits


@@ -5348,18 +5348,8 @@ Value *ScalarExprEmitter::VisitVAArgExpr(VAArgExpr *VE) {
 return llvm::UndefValue::get(ArgTy);
   }
 
-  // FIXME Volatility.
-  llvm::Value *Val = Builder.CreateLoad(ArgPtr);
-
-  // If EmitVAArg promoted the type, we must truncate it.
-  if (ArgTy != Val->getType()) {
-if (ArgTy->isPointerTy() && !Val->getType()->isPointerTy())
-  Val = Builder.CreateIntToPtr(Val, ArgTy);
-else
-  Val = Builder.CreateTrunc(Val, ArgTy);
-  }
-
-  return Val;
+  return CGF.EmitLoadOfScalar(ArgPtr, Ty.isVolatileQualified(), Ty,
+  VE->getExprLoc());

efriedma-quic wrote:

> That seems like it'd be wrong on big-endian targets if the variadic argument 
> was promoted.

I don't think we actually depend on this behavior anymore; we either adjust the 
pointer to point to the correct bytes, or store the value in a temporary.

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


[clang] 7d4a45d - Revert "Add option to generate additional debug info for expression dereferencing pointer to pointers. (#81545)"

2024-05-29 Thread Mehdi Amini via cfe-commits

Author: Mehdi Amini
Date: 2024-05-29T21:56:59-07:00
New Revision: 7d4a45d98275e669bda40410f064891beb3480ce

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

LOG: Revert "Add option to generate additional debug info for expression 
dereferencing pointer to pointers. (#81545)"

This reverts commit aeccfee348c717165541d8d895b9b0cdfe31415c, and dependents:

Revert "[NFC] Fix PPC buildbot failure 
https://lab.llvm.org/buildbot/#/builders/230/builds/29066";
This reverts commit 2b1d1c51f6e321267cc86e9db7808298c59caf0e.

Revert "Fix test - remove unnecessary/incorrect `-S`, in favor of `-emit-llvm`"
This reverts commit ea1ecb50fa831583241fc531153bd2c072955d29.

The test is failing on MacOs and Windows

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDebugInfo.h
clang/lib/CodeGen/CGExprScalar.cpp

Removed: 
clang/test/CodeGenCXX/debug-info-ptr-to-ptr.cpp



diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 9d7107abf8a6f..fac278f0e20a4 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -5737,90 +5737,6 @@ void 
CGDebugInfo::EmitExternalVariable(llvm::GlobalVariable *Var,
   Var->addDebugInfo(GVE);
 }
 
-void CGDebugInfo::EmitPseudoVariable(CGBuilderTy &Builder,
- llvm::Instruction *Value, QualType Ty) {
-  // Only when -g2 or above is specified, debug info for variables will be
-  // generated.
-  if (CGM.getCodeGenOpts().getDebugInfo() <=
-  llvm::codegenoptions::DebugLineTablesOnly)
-return;
-
-  llvm::DebugLoc SaveDebugLoc = Builder.getCurrentDebugLocation();
-  if (!SaveDebugLoc.get())
-return;
-
-  llvm::DIFile *Unit = SaveDebugLoc->getFile();
-  llvm::DIType *Type = getOrCreateType(Ty, Unit);
-
-  // Check if Value is already a declared variable and has debug info, in this
-  // case we have nothing to do. Clang emits declared variable as alloca, and
-  // it is loaded upon use, so we identify such pattern here.
-  if (llvm::LoadInst *Load = dyn_cast(Value)) {
-llvm::Value *Var = Load->getPointerOperand();
-if (llvm::Metadata *MDValue = llvm::ValueAsMetadata::getIfExists(Var)) {
-  if (llvm::Value *DbgValue = llvm::MetadataAsValue::getIfExists(
-  CGM.getLLVMContext(), MDValue)) {
-for (llvm::User *U : DbgValue->users()) {
-  if (llvm::CallInst *DbgDeclare = dyn_cast(U)) {
-if (DbgDeclare->getCalledFunction()->getIntrinsicID() ==
-llvm::Intrinsic::dbg_declare &&
-DbgDeclare->getArgOperand(0) == DbgValue) {
-  // There can be implicit type cast applied on a variable if it is
-  // an opaque ptr, in this case its debug info may not match the
-  // actual type of object being used as in the next instruction, 
so
-  // we will need to emit a pseudo variable for type-casted value.
-  llvm::DILocalVariable *MDNode = cast(
-  cast(DbgDeclare->getOperand(1))
-  ->getMetadata());
-  if (MDNode->getType() == Type)
-return;
-}
-  }
-}
-  }
-}
-  }
-
-  // Find the correct location to insert a sequence of instructions to
-  // materialize Value on the stack.
-  auto SaveInsertionPoint = Builder.saveIP();
-  if (llvm::InvokeInst *Invoke = dyn_cast(Value))
-Builder.SetInsertPoint(Invoke->getNormalDest()->begin());
-  else if (llvm::Instruction *Next = Value->getIterator()->getNextNode())
-Builder.SetInsertPoint(Next);
-  else
-Builder.SetInsertPoint(Value->getParent());
-  llvm::DebugLoc DL = Value->getDebugLoc();
-  if (DL.get())
-Builder.SetCurrentDebugLocation(DL);
-  else if (!Builder.getCurrentDebugLocation().get())
-Builder.SetCurrentDebugLocation(SaveDebugLoc);
-
-  llvm::AllocaInst *PseudoVar = Builder.CreateAlloca(Value->getType());
-  Address PseudoVarAddr(PseudoVar, Value->getType(),
-CharUnits::fromQuantity(PseudoVar->getAlign()));
-  llvm::LoadInst *Load = Builder.CreateLoad(PseudoVarAddr);
-  Value->replaceAllUsesWith(Load);
-  Builder.SetInsertPoint(Load);
-  Builder.CreateStore(Value, PseudoVarAddr);
-
-  // Emit debug info for materialized Value.
-  unsigned Line = Builder.getCurrentDebugLocation().getLine();
-  unsigned Column = Builder.getCurrentDebugLocation().getCol();
-  llvm::DILocalVariable *D = DBuilder.createAutoVariable(
-  LexicalBlockStack.back(), "", nullptr, 0, Type, false,
-  llvm::DINode::FlagArtificial);
-  llvm::DILocation *DIL =
-  llvm::DILocation::get(CGM.getLLVMContext(), Line, Column,
-LexicalBlockStack.back(), CurInlinedAt);
-  SmallVector Expr;
-  DBuilder.insertDeclar

[clang] [HLSL] Default and Relaxed Availability Diagnostics (PR #92704)

2024-05-29 Thread Helena Kotas via cfe-commits

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


[clang] 8890209 - [HLSL] Default and Relaxed Availability Diagnostics (#92704)

2024-05-29 Thread via cfe-commits

Author: Helena Kotas
Date: 2024-05-29T21:52:20-07:00
New Revision: 8890209ead2246461985f49c4c9c01cc2371ac09

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

LOG: [HLSL] Default and Relaxed Availability Diagnostics (#92704)

Implements HLSL availability diagnostics' default and relaxed mode.

HLSL availability diagnostics emits errors or warning when unavailable
shader APIs are used. Unavailable shader APIs are APIs that are exposed
in HLSL code but are not available in the target shader stage or shader
model version.

In the default mode the compiler emits an error when an unavailable API
is found in a code that is reachable from the shader entry point
function. In the future this check will also extended to exported
library functions (#92073). The relaxed diagnostic mode is the same
except the compiler emits a warning. This mode is enabled by
``-Wno-error=hlsl-availability``.

See HLSL Availability Diagnostics design doc
[here](https://github.com/llvm/llvm-project/blob/main/clang/docs/HLSL/AvailabilityDiagnostics.rst)
for more details.

Fixes #90095

Added: 
clang/test/SemaHLSL/Availability/avail-diag-default-compute.hlsl
clang/test/SemaHLSL/Availability/avail-diag-default-lib.hlsl
clang/test/SemaHLSL/Availability/avail-diag-relaxed-compute.hlsl
clang/test/SemaHLSL/Availability/avail-diag-relaxed-lib.hlsl
clang/test/SemaHLSL/Availability/avail-lib-multiple-stages.hlsl

Modified: 
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/SemaHLSL.h
clang/lib/AST/DeclBase.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaAvailability.cpp
clang/lib/Sema/SemaHLSL.cpp
clang/test/SemaHLSL/Availability/attr-availability-compute.hlsl
clang/test/SemaHLSL/Availability/attr-availability-mesh.hlsl
clang/test/SemaHLSL/Availability/attr-availability-pixel.hlsl
clang/test/SemaHLSL/WaveBuiltinAvailability.hlsl

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index ef9df1e9d8b4a..2665b7353ca4a 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -1060,18 +1060,10 @@ static llvm::StringRef 
canonicalizePlatformName(llvm::StringRef Platform) {
  .Case("ShaderModel", "shadermodel")
  .Default(Platform);
 }
-static llvm::StringRef getPrettyEnviromentName(llvm::StringRef Environment) {
-return llvm::StringSwitch(Environment)
- .Case("pixel", "pixel shader")
- .Case("vertex", "vertex shader")
- .Case("geometry", "geometry shader")
- .Case("hull", "hull shader")
- .Case("domain", "domain shader")
- .Case("compute", "compute shader")
- .Case("mesh", "mesh shader")
- .Case("amplification", "amplification shader")
- .Case("library", "shader library")
- .Default(Environment);
+static llvm::StringRef getPrettyEnviromentName(llvm::Triple::EnvironmentType 
EnvironmentType) {
+  if (EnvironmentType >= llvm::Triple::Pixel && EnvironmentType <= 
llvm::Triple::Amplification)
+return llvm::Triple::getEnvironmentTypeName(EnvironmentType);
+  return "";
 }
 static llvm::Triple::EnvironmentType getEnvironmentType(llvm::StringRef 
Environment) {
 return llvm::StringSwitch(Environment)
@@ -1081,6 +1073,12 @@ static llvm::Triple::EnvironmentType 
getEnvironmentType(llvm::StringRef Environm
  .Case("hull", llvm::Triple::Hull)
  .Case("domain", llvm::Triple::Domain)
  .Case("compute", llvm::Triple::Compute)
+ .Case("raygeneration", llvm::Triple::RayGeneration)
+ .Case("intersection", llvm::Triple::Intersection)
+ .Case("anyhit", llvm::Triple::AnyHit)
+ .Case("closesthit", llvm::Triple::ClosestHit)
+ .Case("miss", llvm::Triple::Miss)
+ .Case("callable", llvm::Triple::Callable)
  .Case("mesh", llvm::Triple::Mesh)
  .Case("amplification", llvm::Triple::Amplification)
  .Case("library", llvm::Triple::Library)
@@ -4480,6 +4478,29 @@ def HLSLShader : InheritableAttr {
   "Miss", "Callable", "Mesh", "Amplification"]>
   ];
   let Documentation = [HLSLSV_ShaderTypeAttrDocs];
+  let AdditionalMembers =
+[{
+  static const unsigned ShaderTypeMaxValue = 
(unsigned)HLSLShaderAttr::Amplification;
+
+  static llvm::Triple::EnvironmentType 
getTypeAsEnvironment(HLSLShaderAttr::ShaderType ShaderType) {
+switch (ShaderType) {
+  case HLSLShaderAttr::Pixel: return llvm::Triple::Pixel;
+  case HLSLShaderAttr::Vertex:return llvm::Triple::Vertex;
+  case HLSLSha

[clang] Revert "[DebugInfo] Add flag to only emit referenced member functions" (PR #93767)

2024-05-29 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-debuginfo

@llvm/pr-subscribers-clang-codegen

Author: Mehdi Amini (joker-eph)


Changes

Reverts llvm/llvm-project#87018

MacOS and Windows bots are broken.

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


6 Files Affected:

- (modified) clang/include/clang/Basic/DebugOptions.def (-2) 
- (modified) clang/include/clang/Driver/Options.td (-4) 
- (modified) clang/lib/CodeGen/CGDebugInfo.cpp (+1-1) 
- (modified) clang/lib/Driver/ToolChains/Clang.cpp (-15) 
- (removed) clang/test/CodeGenCXX/debug-info-incomplete-types.cpp (-12) 
- (modified) clang/test/Driver/debug-options.c (-8) 


``diff
diff --git a/clang/include/clang/Basic/DebugOptions.def 
b/clang/include/clang/Basic/DebugOptions.def
index bc96d5dfdf890..b94f6aef9ac60 100644
--- a/clang/include/clang/Basic/DebugOptions.def
+++ b/clang/include/clang/Basic/DebugOptions.def
@@ -68,8 +68,6 @@ BENIGN_DEBUGOPT(NoInlineLineTables, 1, 0) ///< Whether debug 
info should contain
   ///< inline line tables.
 
 DEBUGOPT(DebugStrictDwarf, 1, 1) ///< Whether or not to use strict DWARF info.
-DEBUGOPT(DebugOmitUnreferencedMethods, 1, 0) ///< Omit unreferenced member
-///< functions in type debug info.
 
 /// Control the Assignment Tracking debug info feature.
 BENIGN_ENUM_DEBUGOPT(AssignmentTrackingMode, AssignmentTrackingOpts, 2,
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index f64d7c60783e9..4119e69c85540 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4345,10 +4345,6 @@ defm strict_dwarf : BoolOption<"g", "strict-dwarf",
   "the specified version, avoiding features from later versions.">,
   NegFlag, BothFlags<[], [ClangOption, CLOption, DXCOption]>>,
   Group;
-defm omit_unreferenced_methods : BoolGOption<"omit-unreferenced-methods",
-  CodeGenOpts<"DebugOmitUnreferencedMethods">, DefaultFalse,
-  NegFlag,
-  PosFlag, BothFlags<[], [ClangOption, CLOption, 
DXCOption]>>;
 defm column_info : BoolOption<"g", "column-info",
   CodeGenOpts<"DebugColumnInfo">, DefaultTrue,
   NegFlag,
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 5f6f911c7a6d6..9d7107abf8a6f 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2836,7 +2836,7 @@ CGDebugInfo::CreateTypeDefinition(const RecordType *Ty) {
 
   // Collect data fields (including static variables and any initializers).
   CollectRecordFields(RD, DefUnit, EltTys, FwdDecl);
-  if (CXXDecl && !CGM.getCodeGenOpts().DebugOmitUnreferencedMethods)
+  if (CXXDecl)
 CollectCXXMemberFunctions(CXXDecl, DefUnit, EltTys, FwdDecl);
 
   LexicalBlockStack.pop_back();
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 4e1c52462e584..97e451cfe2acb 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -45,7 +45,6 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/BinaryFormat/Magic.h"
 #include "llvm/Config/llvm-config.h"
-#include "llvm/Frontend/Debug/Options.h"
 #include "llvm/Object/ObjectFile.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/CodeGen.h"
@@ -4643,7 +4642,6 @@ renderDebugOptions(const ToolChain &TC, const Driver &D, 
const llvm::Triple &T,
   Args.addOptInFlag(CmdArgs, options::OPT_fforce_dwarf_frame,
 options::OPT_fno_force_dwarf_frame);
 
-  bool EnableTypeUnits = false;
   if (Args.hasFlag(options::OPT_fdebug_types_section,
options::OPT_fno_debug_types_section, false)) {
 if (!(T.isOSBinFormatELF() || T.isOSBinFormatWasm())) {
@@ -4654,24 +4652,11 @@ renderDebugOptions(const ToolChain &TC, const Driver 
&D, const llvm::Triple &T,
 } else if (checkDebugInfoOption(
Args.getLastArg(options::OPT_fdebug_types_section), Args, D,
TC)) {
-  EnableTypeUnits = true;
   CmdArgs.push_back("-mllvm");
   CmdArgs.push_back("-generate-type-units");
 }
   }
 
-  if (const Arg *A =
-  Args.getLastArg(options::OPT_gomit_unreferenced_methods,
-  options::OPT_gno_omit_unreferenced_methods))
-(void)checkDebugInfoOption(A, Args, D, TC);
-  if (Args.hasFlag(options::OPT_gomit_unreferenced_methods,
-   options::OPT_gno_omit_unreferenced_methods, false) &&
-  (DebugInfoKind == llvm::codegenoptions::DebugInfoConstructor ||
-   DebugInfoKind == llvm::codegenoptions::LimitedDebugInfo) &&
-  !EnableTypeUnits) {
-CmdArgs.push_back("-gomit-unreferenced-methods");
-  }
-
   // To avoid join/split of directory+filename, the integrated assembler 
prefers
   // the directory form of .file on all DWARF versions. GNU as doesn't allow 
the
   // form before DWARF v5.
diff --git a/clang/test/CodeGenCXX/debug-info-incomplete-types.cpp 
b/clang/test/Co

[clang] Revert "[DebugInfo] Add flag to only emit referenced member functions" (PR #93767)

2024-05-29 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Mehdi Amini (joker-eph)


Changes

Reverts llvm/llvm-project#87018

MacOS and Windows bots are broken.

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


6 Files Affected:

- (modified) clang/include/clang/Basic/DebugOptions.def (-2) 
- (modified) clang/include/clang/Driver/Options.td (-4) 
- (modified) clang/lib/CodeGen/CGDebugInfo.cpp (+1-1) 
- (modified) clang/lib/Driver/ToolChains/Clang.cpp (-15) 
- (removed) clang/test/CodeGenCXX/debug-info-incomplete-types.cpp (-12) 
- (modified) clang/test/Driver/debug-options.c (-8) 


``diff
diff --git a/clang/include/clang/Basic/DebugOptions.def 
b/clang/include/clang/Basic/DebugOptions.def
index bc96d5dfdf890..b94f6aef9ac60 100644
--- a/clang/include/clang/Basic/DebugOptions.def
+++ b/clang/include/clang/Basic/DebugOptions.def
@@ -68,8 +68,6 @@ BENIGN_DEBUGOPT(NoInlineLineTables, 1, 0) ///< Whether debug 
info should contain
   ///< inline line tables.
 
 DEBUGOPT(DebugStrictDwarf, 1, 1) ///< Whether or not to use strict DWARF info.
-DEBUGOPT(DebugOmitUnreferencedMethods, 1, 0) ///< Omit unreferenced member
-///< functions in type debug info.
 
 /// Control the Assignment Tracking debug info feature.
 BENIGN_ENUM_DEBUGOPT(AssignmentTrackingMode, AssignmentTrackingOpts, 2,
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index f64d7c60783e9..4119e69c85540 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4345,10 +4345,6 @@ defm strict_dwarf : BoolOption<"g", "strict-dwarf",
   "the specified version, avoiding features from later versions.">,
   NegFlag, BothFlags<[], [ClangOption, CLOption, DXCOption]>>,
   Group;
-defm omit_unreferenced_methods : BoolGOption<"omit-unreferenced-methods",
-  CodeGenOpts<"DebugOmitUnreferencedMethods">, DefaultFalse,
-  NegFlag,
-  PosFlag, BothFlags<[], [ClangOption, CLOption, 
DXCOption]>>;
 defm column_info : BoolOption<"g", "column-info",
   CodeGenOpts<"DebugColumnInfo">, DefaultTrue,
   NegFlag,
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 5f6f911c7a6d6..9d7107abf8a6f 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2836,7 +2836,7 @@ CGDebugInfo::CreateTypeDefinition(const RecordType *Ty) {
 
   // Collect data fields (including static variables and any initializers).
   CollectRecordFields(RD, DefUnit, EltTys, FwdDecl);
-  if (CXXDecl && !CGM.getCodeGenOpts().DebugOmitUnreferencedMethods)
+  if (CXXDecl)
 CollectCXXMemberFunctions(CXXDecl, DefUnit, EltTys, FwdDecl);
 
   LexicalBlockStack.pop_back();
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 4e1c52462e584..97e451cfe2acb 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -45,7 +45,6 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/BinaryFormat/Magic.h"
 #include "llvm/Config/llvm-config.h"
-#include "llvm/Frontend/Debug/Options.h"
 #include "llvm/Object/ObjectFile.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/CodeGen.h"
@@ -4643,7 +4642,6 @@ renderDebugOptions(const ToolChain &TC, const Driver &D, 
const llvm::Triple &T,
   Args.addOptInFlag(CmdArgs, options::OPT_fforce_dwarf_frame,
 options::OPT_fno_force_dwarf_frame);
 
-  bool EnableTypeUnits = false;
   if (Args.hasFlag(options::OPT_fdebug_types_section,
options::OPT_fno_debug_types_section, false)) {
 if (!(T.isOSBinFormatELF() || T.isOSBinFormatWasm())) {
@@ -4654,24 +4652,11 @@ renderDebugOptions(const ToolChain &TC, const Driver 
&D, const llvm::Triple &T,
 } else if (checkDebugInfoOption(
Args.getLastArg(options::OPT_fdebug_types_section), Args, D,
TC)) {
-  EnableTypeUnits = true;
   CmdArgs.push_back("-mllvm");
   CmdArgs.push_back("-generate-type-units");
 }
   }
 
-  if (const Arg *A =
-  Args.getLastArg(options::OPT_gomit_unreferenced_methods,
-  options::OPT_gno_omit_unreferenced_methods))
-(void)checkDebugInfoOption(A, Args, D, TC);
-  if (Args.hasFlag(options::OPT_gomit_unreferenced_methods,
-   options::OPT_gno_omit_unreferenced_methods, false) &&
-  (DebugInfoKind == llvm::codegenoptions::DebugInfoConstructor ||
-   DebugInfoKind == llvm::codegenoptions::LimitedDebugInfo) &&
-  !EnableTypeUnits) {
-CmdArgs.push_back("-gomit-unreferenced-methods");
-  }
-
   // To avoid join/split of directory+filename, the integrated assembler 
prefers
   // the directory form of .file on all DWARF versions. GNU as doesn't allow 
the
   // form before DWARF v5.
diff --git a/clang/test/CodeGenCXX/debug-info-incomplete-types.cpp 
b/clang/test/CodeGenCXX/debug-info-incomplete-types.cp

[clang] [DebugInfo] Add flag to only emit referenced member functions (PR #87018)

2024-05-29 Thread Mehdi Amini via cfe-commits

joker-eph wrote:

Reverted in https://github.com/llvm/llvm-project/pull/93767

(maybe it's just a missing explicit triple in the test?)

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


[clang] Revert "[DebugInfo] Add flag to only emit referenced member functions" (PR #93767)

2024-05-29 Thread Mehdi Amini via cfe-commits

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


[clang] 02c6845 - Revert "[DebugInfo] Add flag to only emit referenced member functions" (#93767)

2024-05-29 Thread via cfe-commits

Author: Mehdi Amini
Date: 2024-05-29T22:48:15-06:00
New Revision: 02c6845c762dfd0a19d4a2f997990e160f392dae

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

LOG: Revert "[DebugInfo] Add flag to only emit referenced member functions" 
(#93767)

Reverts llvm/llvm-project#87018

MacOS and Windows bots are broken.

Added: 


Modified: 
clang/include/clang/Basic/DebugOptions.def
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/debug-options.c

Removed: 
clang/test/CodeGenCXX/debug-info-incomplete-types.cpp



diff  --git a/clang/include/clang/Basic/DebugOptions.def 
b/clang/include/clang/Basic/DebugOptions.def
index bc96d5dfdf890..b94f6aef9ac60 100644
--- a/clang/include/clang/Basic/DebugOptions.def
+++ b/clang/include/clang/Basic/DebugOptions.def
@@ -68,8 +68,6 @@ BENIGN_DEBUGOPT(NoInlineLineTables, 1, 0) ///< Whether debug 
info should contain
   ///< inline line tables.
 
 DEBUGOPT(DebugStrictDwarf, 1, 1) ///< Whether or not to use strict DWARF info.
-DEBUGOPT(DebugOmitUnreferencedMethods, 1, 0) ///< Omit unreferenced member
-///< functions in type debug info.
 
 /// Control the Assignment Tracking debug info feature.
 BENIGN_ENUM_DEBUGOPT(AssignmentTrackingMode, AssignmentTrackingOpts, 2,

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index f64d7c60783e9..4119e69c85540 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4345,10 +4345,6 @@ defm strict_dwarf : BoolOption<"g", "strict-dwarf",
   "the specified version, avoiding features from later versions.">,
   NegFlag, BothFlags<[], [ClangOption, CLOption, DXCOption]>>,
   Group;
-defm omit_unreferenced_methods : BoolGOption<"omit-unreferenced-methods",
-  CodeGenOpts<"DebugOmitUnreferencedMethods">, DefaultFalse,
-  NegFlag,
-  PosFlag, BothFlags<[], [ClangOption, CLOption, 
DXCOption]>>;
 defm column_info : BoolOption<"g", "column-info",
   CodeGenOpts<"DebugColumnInfo">, DefaultTrue,
   NegFlag,

diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 5f6f911c7a6d6..9d7107abf8a6f 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2836,7 +2836,7 @@ CGDebugInfo::CreateTypeDefinition(const RecordType *Ty) {
 
   // Collect data fields (including static variables and any initializers).
   CollectRecordFields(RD, DefUnit, EltTys, FwdDecl);
-  if (CXXDecl && !CGM.getCodeGenOpts().DebugOmitUnreferencedMethods)
+  if (CXXDecl)
 CollectCXXMemberFunctions(CXXDecl, DefUnit, EltTys, FwdDecl);
 
   LexicalBlockStack.pop_back();

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 4e1c52462e584..97e451cfe2acb 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -45,7 +45,6 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/BinaryFormat/Magic.h"
 #include "llvm/Config/llvm-config.h"
-#include "llvm/Frontend/Debug/Options.h"
 #include "llvm/Object/ObjectFile.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/CodeGen.h"
@@ -4643,7 +4642,6 @@ renderDebugOptions(const ToolChain &TC, const Driver &D, 
const llvm::Triple &T,
   Args.addOptInFlag(CmdArgs, options::OPT_fforce_dwarf_frame,
 options::OPT_fno_force_dwarf_frame);
 
-  bool EnableTypeUnits = false;
   if (Args.hasFlag(options::OPT_fdebug_types_section,
options::OPT_fno_debug_types_section, false)) {
 if (!(T.isOSBinFormatELF() || T.isOSBinFormatWasm())) {
@@ -4654,24 +4652,11 @@ renderDebugOptions(const ToolChain &TC, const Driver 
&D, const llvm::Triple &T,
 } else if (checkDebugInfoOption(
Args.getLastArg(options::OPT_fdebug_types_section), Args, D,
TC)) {
-  EnableTypeUnits = true;
   CmdArgs.push_back("-mllvm");
   CmdArgs.push_back("-generate-type-units");
 }
   }
 
-  if (const Arg *A =
-  Args.getLastArg(options::OPT_gomit_unreferenced_methods,
-  options::OPT_gno_omit_unreferenced_methods))
-(void)checkDebugInfoOption(A, Args, D, TC);
-  if (Args.hasFlag(options::OPT_gomit_unreferenced_methods,
-   options::OPT_gno_omit_unreferenced_methods, false) &&
-  (DebugInfoKind == llvm::codegenoptions::DebugInfoConstructor ||
-   DebugInfoKind == llvm::codegenoptions::LimitedDebugInfo) &&
-  !EnableTypeUnits) {
-CmdArgs.push_back("-gomit-unreferenced-methods");
-  }
-
   // To avoid join/split of directory+filename, the integrated assembler 
prefers
   // the di

[clang] Revert "[DebugInfo] Add flag to only emit referenced member functions" (PR #93767)

2024-05-29 Thread Mehdi Amini via cfe-commits

https://github.com/joker-eph created 
https://github.com/llvm/llvm-project/pull/93767

Reverts llvm/llvm-project#87018

MacOS and Windows bots are broken.

>From a35c320e18ba2abad17eab0ed162c4115601a828 Mon Sep 17 00:00:00 2001
From: Mehdi Amini 
Date: Wed, 29 May 2024 22:47:35 -0600
Subject: [PATCH] Revert "[DebugInfo] Add flag to only emit referenced member
 functions (#87018)"

This reverts commit bfabc958c7c0d7ddc15f23383d9da836e8c6093f.
---
 clang/include/clang/Basic/DebugOptions.def|  2 --
 clang/include/clang/Driver/Options.td |  4 
 clang/lib/CodeGen/CGDebugInfo.cpp |  2 +-
 clang/lib/Driver/ToolChains/Clang.cpp | 15 ---
 .../CodeGenCXX/debug-info-incomplete-types.cpp| 12 
 clang/test/Driver/debug-options.c |  8 
 6 files changed, 1 insertion(+), 42 deletions(-)
 delete mode 100644 clang/test/CodeGenCXX/debug-info-incomplete-types.cpp

diff --git a/clang/include/clang/Basic/DebugOptions.def 
b/clang/include/clang/Basic/DebugOptions.def
index bc96d5dfdf890..b94f6aef9ac60 100644
--- a/clang/include/clang/Basic/DebugOptions.def
+++ b/clang/include/clang/Basic/DebugOptions.def
@@ -68,8 +68,6 @@ BENIGN_DEBUGOPT(NoInlineLineTables, 1, 0) ///< Whether debug 
info should contain
   ///< inline line tables.
 
 DEBUGOPT(DebugStrictDwarf, 1, 1) ///< Whether or not to use strict DWARF info.
-DEBUGOPT(DebugOmitUnreferencedMethods, 1, 0) ///< Omit unreferenced member
-///< functions in type debug info.
 
 /// Control the Assignment Tracking debug info feature.
 BENIGN_ENUM_DEBUGOPT(AssignmentTrackingMode, AssignmentTrackingOpts, 2,
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index f64d7c60783e9..4119e69c85540 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4345,10 +4345,6 @@ defm strict_dwarf : BoolOption<"g", "strict-dwarf",
   "the specified version, avoiding features from later versions.">,
   NegFlag, BothFlags<[], [ClangOption, CLOption, DXCOption]>>,
   Group;
-defm omit_unreferenced_methods : BoolGOption<"omit-unreferenced-methods",
-  CodeGenOpts<"DebugOmitUnreferencedMethods">, DefaultFalse,
-  NegFlag,
-  PosFlag, BothFlags<[], [ClangOption, CLOption, 
DXCOption]>>;
 defm column_info : BoolOption<"g", "column-info",
   CodeGenOpts<"DebugColumnInfo">, DefaultTrue,
   NegFlag,
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 5f6f911c7a6d6..9d7107abf8a6f 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2836,7 +2836,7 @@ CGDebugInfo::CreateTypeDefinition(const RecordType *Ty) {
 
   // Collect data fields (including static variables and any initializers).
   CollectRecordFields(RD, DefUnit, EltTys, FwdDecl);
-  if (CXXDecl && !CGM.getCodeGenOpts().DebugOmitUnreferencedMethods)
+  if (CXXDecl)
 CollectCXXMemberFunctions(CXXDecl, DefUnit, EltTys, FwdDecl);
 
   LexicalBlockStack.pop_back();
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 4e1c52462e584..97e451cfe2acb 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -45,7 +45,6 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/BinaryFormat/Magic.h"
 #include "llvm/Config/llvm-config.h"
-#include "llvm/Frontend/Debug/Options.h"
 #include "llvm/Object/ObjectFile.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Support/CodeGen.h"
@@ -4643,7 +4642,6 @@ renderDebugOptions(const ToolChain &TC, const Driver &D, 
const llvm::Triple &T,
   Args.addOptInFlag(CmdArgs, options::OPT_fforce_dwarf_frame,
 options::OPT_fno_force_dwarf_frame);
 
-  bool EnableTypeUnits = false;
   if (Args.hasFlag(options::OPT_fdebug_types_section,
options::OPT_fno_debug_types_section, false)) {
 if (!(T.isOSBinFormatELF() || T.isOSBinFormatWasm())) {
@@ -4654,24 +4652,11 @@ renderDebugOptions(const ToolChain &TC, const Driver 
&D, const llvm::Triple &T,
 } else if (checkDebugInfoOption(
Args.getLastArg(options::OPT_fdebug_types_section), Args, D,
TC)) {
-  EnableTypeUnits = true;
   CmdArgs.push_back("-mllvm");
   CmdArgs.push_back("-generate-type-units");
 }
   }
 
-  if (const Arg *A =
-  Args.getLastArg(options::OPT_gomit_unreferenced_methods,
-  options::OPT_gno_omit_unreferenced_methods))
-(void)checkDebugInfoOption(A, Args, D, TC);
-  if (Args.hasFlag(options::OPT_gomit_unreferenced_methods,
-   options::OPT_gno_omit_unreferenced_methods, false) &&
-  (DebugInfoKind == llvm::codegenoptions::DebugInfoConstructor ||
-   DebugInfoKind == llvm::codegenoptions::LimitedDebugInfo) &&
-  !EnableTypeUnits) {
-CmdArgs.push_back("-gomit-unreferenc

[clang] [DebugInfo] Add flag to only emit referenced member functions (PR #87018)

2024-05-29 Thread Mehdi Amini via cfe-commits

joker-eph wrote:

It also fails on Windows: 
https://lab.llvm.org/buildbot/#/builders/271/builds/8095

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


[clang] [llvm] [PowerPC] Diagnose musttail instead of crash inside backend (PR #93267)

2024-05-29 Thread Eli Friedman via cfe-commits


@@ -743,6 +743,20 @@ bool Sema::checkMustTailAttr(const Stmt *St, const Attr 
&MTA) {
 CallerType.Func = CallerDecl->getType()->getAs();
   }
 
+  if (Context.getTargetInfo().getTriple().isPPC()) {
+if (Context.getTargetInfo().getTriple().isOSAIX())
+  return Diag(St->getBeginLoc(), diag::err_aix_musttail_unsupported);
+else if (!Context.getTargetInfo().hasFeature("pcrelative-memops")) {
+  if (Context.getTargetInfo().hasFeature("longcall"))
+return Diag(St->getBeginLoc(), diag::err_ppc_impossible_musttail) << 0;
+  else if (!CE->getDirectCallee())
+return Diag(St->getBeginLoc(), diag::err_ppc_impossible_musttail) << 1;
+  else if (isa_and_nonnull(CE->getCalleeDecl()) &&

efriedma-quic wrote:

For the weak definitions, you can look at GVALinkage or something like that, 
yes.

For the ordering issue, you probably need to do the analysis at the end of the 
translation unit, or something like that.

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


[clang] 3db1f31 - [clang-format] Fix a regression in annotating class decl braces (#93657)

2024-05-29 Thread via cfe-commits

Author: Owen Pan
Date: 2024-05-29T21:05:32-07:00
New Revision: 3db1f3110e714ad24f7d72114b3a2c14f6c63651

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

LOG: [clang-format] Fix a regression in annotating class decl braces (#93657)

Fixes #93604.

Added: 


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

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index b6f7567adc140..bf89def05bb2d 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -4026,6 +4026,9 @@ void UnwrappedLineParser::parseRecord(bool ParseAsExpr) {
   if (AngleNestingLevel == 0) {
 if (FormatTok->is(tok::colon)) {
   IsDerived = true;
+} else if (FormatTok->is(tok::identifier) &&
+   FormatTok->Previous->is(tok::coloncolon)) {
+  ClassName = FormatTok;
 } else if (FormatTok->is(tok::l_paren) &&
IsNonMacroIdentifier(FormatTok->Previous)) {
   break;

diff  --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index 6ea9c4a241dc5..3339a749df3a5 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -2914,6 +2914,11 @@ TEST_F(TokenAnnotatorTest, BraceKind) {
   EXPECT_BRACE_KIND(Tokens[5], BK_Block);
   EXPECT_BRACE_KIND(Tokens[6], BK_Block);
 
+  Tokens = annotate("struct Foo::Bar {};");
+  ASSERT_EQ(Tokens.size(), 11u) << Tokens;
+  EXPECT_BRACE_KIND(Tokens[7], BK_Block);
+  EXPECT_BRACE_KIND(Tokens[8], BK_Block);
+
   Tokens = annotate("struct Foo : Base {};");
   ASSERT_EQ(Tokens.size(), 11u) << Tokens;
   EXPECT_BRACE_KIND(Tokens[7], BK_Block);



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


[clang] [clang-format] Fix a regression in annotating class decl braces (PR #93657)

2024-05-29 Thread Owen Pan via cfe-commits

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


[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)

2024-05-29 Thread Shengchen Kan via cfe-commits

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


[clang] [C++20] [Modules] [Itanium ABI] Generate the vtable in the module unit of dynamic classes (PR #75912)

2024-05-29 Thread Chuanqi Xu via cfe-commits


@@ -1802,6 +1802,12 @@ void ItaniumCXXABI::emitVTableDefinitions(CodeGenVTables 
&CGVT,
   if (VTable->hasInitializer())
 return;
 
+  // If the class is attached to a C++ named module other than the one
+  // we're currently compiling, the vtable should be defined there.
+  if (Module *M = RD->getOwningModule();
+  M && M->isNamedModule() && M != CGM.getContext().getCurrentNamedModule())

ChuanqiXu9 wrote:

If we feel this is too long, I can wrap them into a member function of Decl in 
a following patch.

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


[clang] [C++20] [Modules] [Itanium ABI] Generate the vtable in the module unit of dynamic classes (PR #75912)

2024-05-29 Thread Chuanqi Xu via cfe-commits


@@ -1180,6 +1185,21 @@ bool CodeGenVTables::isVTableExternal(const 
CXXRecordDecl *RD) {
   TSK == TSK_ExplicitInstantiationDefinition)
 return false;
 
+  // Itanium C++ ABI [5.2.3]:
+  // Virtual tables for dynamic classes are emitted as follows:
+  //
+  // - If the class is templated, the tables are emitted in every object that
+  // references any of them.
+  // - Otherwise, if the class is attached to a module, the tables are uniquely
+  // emitted in the object for the module unit in which it is defined.
+  // - Otherwise, if the class has a key function (see below), the tables are
+  // emitted in the object for the translation unit containing the definition 
of
+  // the key function. This is unique if the key function is not inline.
+  // - Otherwise, the tables are emitted in every object that references any of
+  // them.
+  if (Module *M = RD->getOwningModule(); M && M->isNamedModule())

ChuanqiXu9 wrote:

Maybe it is not strictly correct to use `hasExternalDefinitions()` since it 
can't handle the global module case. I mean, from the current wording, the 
class in the global module should follow the old ABI rules (key functions). But 
`hasExternalDefinitions()`  won't make that clear.

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


[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)

2024-05-29 Thread Shengchen Kan via cfe-commits

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


[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)

2024-05-29 Thread Shengchen Kan via cfe-commits


@@ -0,0 +1,25 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: not llc -mtriple=x86_64 < %s | FileCheck %s
+; RUN: not llc -mtriple=x86_64 -mattr=+egpr < %s | FileCheck %s

KanRobert wrote:

You can use sth like
```
not llc -mtriple=x86_64 -mattr=+egpr < %s >%t1 2>%t2
FileCheck %s %t1
FileCheck %s %t2 --check-prefix=ERR
```

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


[clang] [llvm] Add option to generate additional debug info for expression dereferencing pointer to pointers. (PR #81545)

2024-05-29 Thread via cfe-commits

dyung wrote:

Hi, the test debug-info-ptr-to-ptr.cpp is still failing on a Mac bot. Can you 
take a look? 

https://lab.llvm.org/buildbot/#/builders/280/builds/4515

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


[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)

2024-05-29 Thread Shengchen Kan via cfe-commits


@@ -1,21 +1,27 @@
 ; Check r16-r31 can not be used with 'q','r','l' constraint for backward 
compatibility.
-; RUN: not llc < %s -mtriple=x86_64-unknown-unknown -mattr=+egpr 2>&1 | 
FileCheck %s
+; RUN: not llc < %s -mtriple=x86_64-unknown-unknown -mattr=+egpr 2>&1 | 
FileCheck %s --check-prefix=ERR

KanRobert wrote:

Really? IMO, line 4 is checking stderr too.

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


[clang] [DebugInfo] Add flag to only emit referenced member functions (PR #87018)

2024-05-29 Thread via cfe-commits

dyung wrote:

Hi @dwblaikie the test debug-options.c is failing on the macOS build bot. Can 
you take a look?

https://lab.llvm.org/buildbot/#/builders/280/builds/4510

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


[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)

2024-05-29 Thread Freddy Ye via cfe-commits

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


[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)

2024-05-29 Thread Freddy Ye via cfe-commits


@@ -1,21 +1,27 @@
 ; Check r16-r31 can not be used with 'q','r','l' constraint for backward 
compatibility.
-; RUN: not llc < %s -mtriple=x86_64-unknown-unknown -mattr=+egpr 2>&1 | 
FileCheck %s
+; RUN: not llc < %s -mtriple=x86_64-unknown-unknown -mattr=+egpr 2>&1 | 
FileCheck %s --check-prefix=ERR

FreddyLeaf wrote:

line 2 is to check stderr, line 4 is to check stdout, I don't have a good way 
to check them both in on RUN line. Any idea?

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


[clang] [clang-format] add an option to insert a space only for non-code block empty braces, not for empty parentheses (PR #93634)

2024-05-29 Thread Kohei Asano via cfe-commits

https://github.com/khei4 updated https://github.com/llvm/llvm-project/pull/93634

>From 0b41025a9ba677caf694f65620ce4a7b9aae2265 Mon Sep 17 00:00:00 2001
From: Kohei Asano 
Date: Wed, 29 May 2024 11:40:39 +0900
Subject: [PATCH] [clang-format] add an option to insert a space only for empty
 braces
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Co-authored-by: Björn Schäpers 
---
 clang/docs/ClangFormatStyleOptions.rst | 14 +-
 clang/include/clang/Format/Format.h| 21 +
 clang/lib/Format/Format.cpp|  4 
 clang/lib/Format/TokenAnnotator.cpp|  5 +
 clang/unittests/Format/ConfigParseTest.cpp | 21 +
 clang/unittests/Format/FormatTest.cpp  | 10 ++
 6 files changed, 62 insertions(+), 13 deletions(-)

diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 6d092219877f9..a1944eec8582b 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -6237,18 +6237,30 @@ the configuration (without a prefix: ``Auto``).
true:  false:
x = ( int32 )y vs. x = (int32)y
 
-  * ``bool InEmptyParentheses`` Put a space in parentheses only if the 
parentheses are empty i.e. '()'
+  * ``bool InEmptyParentheses`` Put a space in parentheses and braces only if 
they are empty i.e. '()' or '{}'
 
 .. code-block:: c++
 
true:false:
void f( ) {vs.   void f() {
  int x[] = {foo( ), bar( )};  int x[] = {foo(), bar()};
+ T a = { };   T a = {};
  if (true) {  if (true) {
f( );f();
  }}
}}
 
+  * ``bool InEmptyBraces`` Put a space in *only* braces, not for parentheses, 
only if the braces are empty i.e. '{}'
+
+.. code-block:: c++
+
+   true:false:
+   void f() { vs.   void f() {
+ T x = {};T x = { };
+ g(x, {});g(x, { });
+   }}
+
+
   * ``bool Other`` Put a space in parentheses not covered by preceding options.
 
 .. code-block:: c++
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 274b45d1bc586..4482f7fb49788 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -4673,6 +4673,17 @@ struct FormatStyle {
 ///}}
 /// \endcode
 bool InEmptyParentheses;
+/// Put a space in brackets only if the parentheses are empty i.e. '()'
+/// \code
+///true:false:
+///void f( ) {vs.   void f() {
+///  int x[] = {foo( ), bar( )};  int x[] = {foo(), bar()};
+///  if (true) {  if (true) {
+///f( );f();
+///  }}
+///}}
+/// \endcode
+bool InEmptyBraces;
 /// Put a space in parentheses not covered by preceding options.
 /// \code
 ///true:  false:
@@ -4682,18 +4693,20 @@ struct FormatStyle {
 
 SpacesInParensCustom()
 : InConditionalStatements(false), InCStyleCasts(false),
-  InEmptyParentheses(false), Other(false) {}
+  InEmptyParentheses(false), InEmptyBraces(false), Other(false) {}
 
 SpacesInParensCustom(bool InConditionalStatements, bool InCStyleCasts,
- bool InEmptyParentheses, bool Other)
+ bool InEmptyParentheses, bool InEmptyBraces,
+ bool Other)
 : InConditionalStatements(InConditionalStatements),
   InCStyleCasts(InCStyleCasts), InEmptyParentheses(InEmptyParentheses),
-  Other(Other) {}
+  InEmptyBraces(InEmptyBraces), Other(Other) {}
 
 bool operator==(const SpacesInParensCustom &R) const {
   return InConditionalStatements == R.InConditionalStatements &&
  InCStyleCasts == R.InCStyleCasts &&
- InEmptyParentheses == R.InEmptyParentheses && Other == R.Other;
+ InEmptyParentheses == R.InEmptyParentheses &&
+ InEmptyBraces == R.InEmptyBraces && Other == R.Other;
 }
 bool operator!=(const SpacesInParensCustom &R) const {
   return !(*this == R);
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 9cba0c2614eef..453a87745642d 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -723,6 +723,7 @@ template <> struct 

[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)

2024-05-29 Thread Shengchen Kan via cfe-commits




KanRobert wrote:

Nits: Rename this file to llvm/test/CodeGen/X86/apx/asm-constraint-jr.ll to 
align with existing one

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


[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)

2024-05-29 Thread Shengchen Kan via cfe-commits




KanRobert wrote:

Nits: Rename this file to llvm/test/CodeGen/X86/apx/asm-constraint-jR.ll to 
align with existing one

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


[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)

2024-05-29 Thread Shengchen Kan via cfe-commits


@@ -57999,13 +58020,25 @@ X86TargetLowering::getRegForInlineAsmConstraint(const 
TargetRegisterInfo *TRI,
 case 'q':   // GENERAL_REGS in 64-bit mode, Q_REGS in 32-bit mode.
   if (Subtarget.is64Bit()) {
 if (VT == MVT::i8 || VT == MVT::i1)
-  return std::make_pair(0U, &X86::GR8_NOREX2RegClass);
+  return std::make_pair(0U, Subtarget.hasEGPR() &&
+Subtarget.useInlineAsmGPR32()

KanRobert wrote:

Define a local helper for `Subtarget.hasEGPR() && 
Subtarget.useInlineAsmGPR32()`?

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


[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)

2024-05-29 Thread Shengchen Kan via cfe-commits


@@ -1,21 +1,27 @@
 ; Check r16-r31 can not be used with 'q','r','l' constraint for backward 
compatibility.
-; RUN: not llc < %s -mtriple=x86_64-unknown-unknown -mattr=+egpr 2>&1 | 
FileCheck %s
+; RUN: not llc < %s -mtriple=x86_64-unknown-unknown -mattr=+egpr 2>&1 | 
FileCheck %s --check-prefix=ERR

KanRobert wrote:

Is line 2 same as line 4? If so, remove line 2.

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


[clang] [llvm] [Inliner] Propagate more attributes to params when inlining (PR #91101)

2024-05-29 Thread via cfe-commits

goldsteinn wrote:

rebased

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


[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)

2024-05-29 Thread Freddy Ye via cfe-commits

https://github.com/FreddyLeaf updated 
https://github.com/llvm/llvm-project/pull/92338

>From 41fbc18c7a4a26b11bc4b772bbe2e384ad9d9dbc Mon Sep 17 00:00:00 2001
From: Freddy Ye 
Date: Fri, 10 May 2024 16:29:55 +0800
Subject: [PATCH 01/12] [X86] Support EGPR for inline assembly.

"jR": explictly enables EGPR
"r": enables/disables EGPR w/wo -mapx-inline-asm-use-gpr32
-mapx-inline-asm-use-gpr32 will also define a new Macro:
__APX_INLINE_ASM_USE_GPR32__
---
 clang/include/clang/Driver/Options.td |  2 +
 clang/lib/Basic/Targets/X86.cpp   | 26 +
 clang/lib/Basic/Targets/X86.h |  1 +
 clang/lib/Driver/ToolChains/Arch/X86.cpp  |  2 +
 .../Driver/x86-apx-inline-asm-use-gpr32.cpp   |  3 +
 clang/test/Preprocessor/x86_target_features.c |  3 +
 llvm/lib/Target/X86/X86.td|  3 +
 llvm/lib/Target/X86/X86ISelLowering.cpp   | 57 +--
 .../CodeGen/X86/inline-asm-jR-constraint.ll   | 19 +++
 .../CodeGen/X86/inline-asm-r-constraint.ll| 16 ++
 10 files changed, 127 insertions(+), 5 deletions(-)
 create mode 100644 clang/test/Driver/x86-apx-inline-asm-use-gpr32.cpp
 create mode 100644 llvm/test/CodeGen/X86/inline-asm-jR-constraint.ll
 create mode 100644 llvm/test/CodeGen/X86/inline-asm-r-constraint.ll

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 73a2518480e9b..20a7c482bbf06 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6281,6 +6281,8 @@ def mno_apx_features_EQ : CommaJoined<["-"], 
"mno-apx-features=">, Group, Alias, 
AliasArgs<["egpr","push2pop2","ppx", "ndd"]>;
 def mno_apxf : Flag<["-"], "mno-apxf">, Alias, 
AliasArgs<["egpr","push2pop2","ppx","ndd"]>;
+def mapx_inline_asm_use_gpr32 : Flag<["-"], "mapx-inline-asm-use-gpr32">, 
Group,
+HelpText<"Enable use of GPR32 in inline 
assembly for APX">;
 } // let Flags = [TargetSpecific]
 
 // VE feature flags
diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index 67e2126cf766b..9e61b6e6d6441 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -450,6 +450,8 @@ bool 
X86TargetInfo::handleTargetFeatures(std::vector &Features,
   HasFullBFloat16 = true;
 } else if (Feature == "+egpr") {
   HasEGPR = true;
+} else if (Feature == "+inline-asm-use-gpr32") {
+  HasInlineAsmUseGPR32 = true;
 } else if (Feature == "+push2pop2") {
   HasPush2Pop2 = true;
 } else if (Feature == "+ppx") {
@@ -974,6 +976,8 @@ void X86TargetInfo::getTargetDefines(const LangOptions 
&Opts,
   // Condition here is aligned with the feature set of mapxf in Options.td
   if (HasEGPR && HasPush2Pop2 && HasPPX && HasNDD)
 Builder.defineMacro("__APX_F__");
+  if (HasInlineAsmUseGPR32)
+Builder.defineMacro("__APX_INLINE_ASM_USE_GPR32__");
 
   // Each case falls through to the previous one here.
   switch (SSELevel) {
@@ -1493,6 +1497,15 @@ bool X86TargetInfo::validateAsmConstraint(
   case 'C': // SSE floating point constant.
   case 'G': // x87 floating point constant.
 return true;
+  case 'j':
+Name++;
+switch (*Name) {
+default:
+  return false;
+case 'R':
+  Info.setAllowsRegister();
+  return true;
+}
   case '@':
 // CC condition changes.
 if (auto Len = matchAsmCCConstraint(Name)) {
@@ -1764,6 +1777,19 @@ std::string X86TargetInfo::convertConstraint(const char 
*&Constraint) const {
   // to the next constraint.
   return std::string("^") + std::string(Constraint++, 2);
 }
+  case 'j':
+switch (Constraint[1]) {
+default:
+  // Break from inner switch and fall through (copy single char),
+  // continue parsing after copying the current constraint into
+  // the return string.
+  break;
+case 'R':
+  // "^" hints llvm that this is a 2 letter constraint.
+  // "Constraint++" is used to promote the string iterator
+  // to the next constraint.
+  return std::string("^") + std::string(Constraint++, 2);
+}
 [[fallthrough]];
   default:
 return std::string(1, *Constraint);
diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h
index c14e4d5f433d8..69c68ee80f3ba 100644
--- a/clang/lib/Basic/Targets/X86.h
+++ b/clang/lib/Basic/Targets/X86.h
@@ -174,6 +174,7 @@ class LLVM_LIBRARY_VISIBILITY X86TargetInfo : public 
TargetInfo {
   bool HasNDD = false;
   bool HasCCMP = false;
   bool HasCF = false;
+  bool HasInlineAsmUseGPR32 = false;
 
 protected:
   llvm::X86::CPUKind CPU = llvm::X86::CK_None;
diff --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp 
b/clang/lib/Driver/ToolChains/Arch/X86.cpp
index 53e26a9f8e229..085ff4824a9b0 100644
--- a/clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -309,4 +309,6 @@ void x86::getX86TargetFeatures(const Driver &D, const 
llvm::Triple &Triple,
 Features.push_back("+prefer-no-gat

[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)

2024-05-29 Thread Freddy Ye via cfe-commits


@@ -0,0 +1,16 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: not llc -mtriple=x86_64 %s 2>&1 | FileCheck %s --check-prefix=ERR
+; RUN: llc -mtriple=x86_64 -mattr=+egpr < %s | FileCheck %s
+; RUN: llc -mtriple=x86_64 -mattr=+egpr,+inline-asm-use-gpr32 < %s | FileCheck 
%s

FreddyLeaf wrote:

81f58b6

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


[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)

2024-05-29 Thread Freddy Ye via cfe-commits




FreddyLeaf wrote:

81f58b6, pls review if I understand correctly.

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


[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)

2024-05-29 Thread Freddy Ye via cfe-commits




FreddyLeaf wrote:

81f58b6

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


[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)

2024-05-29 Thread Freddy Ye via cfe-commits


@@ -5394,10 +5394,12 @@ X86:
 - ``Z``: An immediate 32-bit unsigned integer.
 - ``q``: An 8, 16, 32, or 64-bit register which can be accessed as an 8-bit
   ``l`` integer register. On X86-32, this is the ``a``, ``b``, ``c``, and ``d``
-  registers, and on X86-64, it is all of the integer registers.
+  registers, and on X86-64, it is all of the integer registers. When feature
+  `egpr` and `inline-asm-use-gpr32` are both on, they will be extended to EGPR.
 - ``Q``: An 8, 16, 32, or 64-bit register which can be accessed as an 8-bit
   ``h`` integer register. This is the ``a``, ``b``, ``c``, and ``d`` registers.
-- ``r`` or ``l``: An 8, 16, 32, or 64-bit integer register.
+- ``r`` or ``l``: An 8, 16, 32, or 64-bit integer register. When feature
+  `egpr` and `inline-asm-use-gpr32` are both on, they will be extended to EGPR.

FreddyLeaf wrote:

81f58b6

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


[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)

2024-05-29 Thread Freddy Ye via cfe-commits


@@ -5394,10 +5394,12 @@ X86:
 - ``Z``: An immediate 32-bit unsigned integer.
 - ``q``: An 8, 16, 32, or 64-bit register which can be accessed as an 8-bit
   ``l`` integer register. On X86-32, this is the ``a``, ``b``, ``c``, and ``d``
-  registers, and on X86-64, it is all of the integer registers.
+  registers, and on X86-64, it is all of the integer registers. When feature
+  `egpr` and `inline-asm-use-gpr32` are both on, they will be extended to EGPR.

FreddyLeaf wrote:

81f58b6

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


[clang] [clang][analyzer] Improved PointerSubChecker (PR #93676)

2024-05-29 Thread Donát Nagy via cfe-commits


@@ -0,0 +1,74 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.core.PointerSub -verify %s
+
+void f1(void) {
+  int x, y, z[10];
+  int d = &y - &x; // expected-warning{{Subtraction of two pointers that do 
not point into the same array is undefined behavior}}
+  d = z - &y; // expected-warning{{Subtraction of two pointers that do not 
point into the same array is undefined behavior}}
+  d = &x - &x; // expected-warning{{Subtraction of two pointers that do not 
point into the same array is undefined behavior}}

NagyDonat wrote:

This corner case is explicitly allowed by the standard: non-array variables act 
as if they were single-element arrays and it's valid to do (trivial) pointer 
arithmetic on them.

Even calculating the past-the-end pointer of a non-array object (e.g. `&x + 1`) 
is a valid (but unusual) operation; however the [description on 
cppreference](https://en.cppreference.com/w/cpp/language/operator_arithmetic) 
suggests that it's UB to take the difference `(&x+1)-&x`. You should probably 
look this up in the standard itself if you want to be accurate.



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


[clang] [clang][analyzer] Improved PointerSubChecker (PR #93676)

2024-05-29 Thread Donát Nagy via cfe-commits

https://github.com/NagyDonat commented:

It's nice to see that you're working on this checker; but unfortunately the 
language standard is very complicated in this area, so you'll need more complex 
code to cover it properly.

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


[clang] [clang][analyzer] Improved PointerSubChecker (PR #93676)

2024-05-29 Thread Donát Nagy via cfe-commits


@@ -44,24 +44,30 @@ void PointerSubChecker::checkPreStmt(const BinaryOperator 
*B,
 
   const MemRegion *LR = LV.getAsRegion();
   const MemRegion *RR = RV.getAsRegion();
-
-  if (!(LR && RR))
-return;
-
-  const MemRegion *BaseLR = LR->getBaseRegion();
-  const MemRegion *BaseRR = RR->getBaseRegion();
-
-  if (BaseLR == BaseRR)
+  if (!LR || !RR)
 return;
 
-  // Allow arithmetic on different symbolic regions.
-  if (isa(BaseLR) || isa(BaseRR))
-return;
+  const auto *ElemLR = dyn_cast(LR);
+  const auto *ElemRR = dyn_cast(RR);
+  // FIXME: We want to verify that these are elements of an array.
+  // Because behavior of ElementRegion it may be confused with a cast.
+  // There is not a simple way to distinguish it from array element (check the
+  // types?). Because this missing check a warning is missing in the rare case
+  // when two casted pointers to the same region (variable) are subtracted.

NagyDonat wrote:

If two pointers point to the same variable, it's valid to subtract them.

By the way, it's also valid to declare a `long long` variable, point a `char *` 
pointer at it (`char *` may point anywhere) and use it to iterate over the 
memory region of the `long long` as if it was a `char[8]`. (By the way in this 
case you have `ElementRegion`s and your code behaves correctly.)

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


[clang] [clang][analyzer] Improved PointerSubChecker (PR #93676)

2024-05-29 Thread Donát Nagy via cfe-commits

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


[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)

2024-05-29 Thread Freddy Ye via cfe-commits

https://github.com/FreddyLeaf updated 
https://github.com/llvm/llvm-project/pull/92338

>From 41fbc18c7a4a26b11bc4b772bbe2e384ad9d9dbc Mon Sep 17 00:00:00 2001
From: Freddy Ye 
Date: Fri, 10 May 2024 16:29:55 +0800
Subject: [PATCH 01/11] [X86] Support EGPR for inline assembly.

"jR": explictly enables EGPR
"r": enables/disables EGPR w/wo -mapx-inline-asm-use-gpr32
-mapx-inline-asm-use-gpr32 will also define a new Macro:
__APX_INLINE_ASM_USE_GPR32__
---
 clang/include/clang/Driver/Options.td |  2 +
 clang/lib/Basic/Targets/X86.cpp   | 26 +
 clang/lib/Basic/Targets/X86.h |  1 +
 clang/lib/Driver/ToolChains/Arch/X86.cpp  |  2 +
 .../Driver/x86-apx-inline-asm-use-gpr32.cpp   |  3 +
 clang/test/Preprocessor/x86_target_features.c |  3 +
 llvm/lib/Target/X86/X86.td|  3 +
 llvm/lib/Target/X86/X86ISelLowering.cpp   | 57 +--
 .../CodeGen/X86/inline-asm-jR-constraint.ll   | 19 +++
 .../CodeGen/X86/inline-asm-r-constraint.ll| 16 ++
 10 files changed, 127 insertions(+), 5 deletions(-)
 create mode 100644 clang/test/Driver/x86-apx-inline-asm-use-gpr32.cpp
 create mode 100644 llvm/test/CodeGen/X86/inline-asm-jR-constraint.ll
 create mode 100644 llvm/test/CodeGen/X86/inline-asm-r-constraint.ll

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 73a2518480e9b..20a7c482bbf06 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6281,6 +6281,8 @@ def mno_apx_features_EQ : CommaJoined<["-"], 
"mno-apx-features=">, Group, Alias, 
AliasArgs<["egpr","push2pop2","ppx", "ndd"]>;
 def mno_apxf : Flag<["-"], "mno-apxf">, Alias, 
AliasArgs<["egpr","push2pop2","ppx","ndd"]>;
+def mapx_inline_asm_use_gpr32 : Flag<["-"], "mapx-inline-asm-use-gpr32">, 
Group,
+HelpText<"Enable use of GPR32 in inline 
assembly for APX">;
 } // let Flags = [TargetSpecific]
 
 // VE feature flags
diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index 67e2126cf766b..9e61b6e6d6441 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -450,6 +450,8 @@ bool 
X86TargetInfo::handleTargetFeatures(std::vector &Features,
   HasFullBFloat16 = true;
 } else if (Feature == "+egpr") {
   HasEGPR = true;
+} else if (Feature == "+inline-asm-use-gpr32") {
+  HasInlineAsmUseGPR32 = true;
 } else if (Feature == "+push2pop2") {
   HasPush2Pop2 = true;
 } else if (Feature == "+ppx") {
@@ -974,6 +976,8 @@ void X86TargetInfo::getTargetDefines(const LangOptions 
&Opts,
   // Condition here is aligned with the feature set of mapxf in Options.td
   if (HasEGPR && HasPush2Pop2 && HasPPX && HasNDD)
 Builder.defineMacro("__APX_F__");
+  if (HasInlineAsmUseGPR32)
+Builder.defineMacro("__APX_INLINE_ASM_USE_GPR32__");
 
   // Each case falls through to the previous one here.
   switch (SSELevel) {
@@ -1493,6 +1497,15 @@ bool X86TargetInfo::validateAsmConstraint(
   case 'C': // SSE floating point constant.
   case 'G': // x87 floating point constant.
 return true;
+  case 'j':
+Name++;
+switch (*Name) {
+default:
+  return false;
+case 'R':
+  Info.setAllowsRegister();
+  return true;
+}
   case '@':
 // CC condition changes.
 if (auto Len = matchAsmCCConstraint(Name)) {
@@ -1764,6 +1777,19 @@ std::string X86TargetInfo::convertConstraint(const char 
*&Constraint) const {
   // to the next constraint.
   return std::string("^") + std::string(Constraint++, 2);
 }
+  case 'j':
+switch (Constraint[1]) {
+default:
+  // Break from inner switch and fall through (copy single char),
+  // continue parsing after copying the current constraint into
+  // the return string.
+  break;
+case 'R':
+  // "^" hints llvm that this is a 2 letter constraint.
+  // "Constraint++" is used to promote the string iterator
+  // to the next constraint.
+  return std::string("^") + std::string(Constraint++, 2);
+}
 [[fallthrough]];
   default:
 return std::string(1, *Constraint);
diff --git a/clang/lib/Basic/Targets/X86.h b/clang/lib/Basic/Targets/X86.h
index c14e4d5f433d8..69c68ee80f3ba 100644
--- a/clang/lib/Basic/Targets/X86.h
+++ b/clang/lib/Basic/Targets/X86.h
@@ -174,6 +174,7 @@ class LLVM_LIBRARY_VISIBILITY X86TargetInfo : public 
TargetInfo {
   bool HasNDD = false;
   bool HasCCMP = false;
   bool HasCF = false;
+  bool HasInlineAsmUseGPR32 = false;
 
 protected:
   llvm::X86::CPUKind CPU = llvm::X86::CK_None;
diff --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp 
b/clang/lib/Driver/ToolChains/Arch/X86.cpp
index 53e26a9f8e229..085ff4824a9b0 100644
--- a/clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -309,4 +309,6 @@ void x86::getX86TargetFeatures(const Driver &D, const 
llvm::Triple &Triple,
 Features.push_back("+prefer-no-gat

[clang] [llvm] [Inliner] Propagate more attributes to params when inlining (PR #91101)

2024-05-29 Thread via cfe-commits

https://github.com/goldsteinn updated 
https://github.com/llvm/llvm-project/pull/91101

>From 362157ff823b9c79a5c069fcc574d01e3af23de0 Mon Sep 17 00:00:00 2001
From: Noah Goldstein 
Date: Sat, 4 May 2024 18:12:34 -0500
Subject: [PATCH 1/3] [Inliner] Add tests for propagating more parameter
 attributes; NFC

---
 .../Inline/access-attributes-prop.ll  | 166 +-
 1 file changed, 159 insertions(+), 7 deletions(-)

diff --git a/llvm/test/Transforms/Inline/access-attributes-prop.ll 
b/llvm/test/Transforms/Inline/access-attributes-prop.ll
index 48665e9bbafd1..8d4af9f909644 100644
--- a/llvm/test/Transforms/Inline/access-attributes-prop.ll
+++ b/llvm/test/Transforms/Inline/access-attributes-prop.ll
@@ -47,7 +47,6 @@ define dso_local void @foo3_writable(ptr %p) {
   ret void
 }
 
-
 define dso_local void @foo1_bar_aligned64_deref512(ptr %p) {
 ; CHECK-LABEL: define {{[^@]+}}@foo1_bar_aligned64_deref512
 ; CHECK-SAME: (ptr [[P:%.*]]) {
@@ -189,9 +188,10 @@ define dso_local void @foo2_through_obj(ptr %p, ptr %p2) {
 
 define dso_local void @foo_byval_readonly(ptr readonly %p) {
 ; CHECK-LABEL: define {{[^@]+}}@foo_byval_readonly
-; CHECK-SAME: (ptr readonly [[P:%.*]])
-; CHECK-NEXT:   call void @bar4(ptr byval([4 x i32]) [[P]])
-; CHECK-NEXT:   ret void
+; CHECK-SAME: (ptr readonly [[P:%.*]]) {
+; CHECK-NEXT:call void @bar4(ptr byval([4 x i32]) [[P]])
+; CHECK-NEXT:ret void
+;
   call void @bar4(ptr byval([4 x i32]) %p)
   ret void
 }
@@ -332,6 +332,16 @@ define void @prop_param_nonnull_and_align(ptr %p) {
   ret void
 }
 
+define void @prop_param_nofree_and_align(ptr %p) {
+; CHECK-LABEL: define {{[^@]+}}@prop_param_nofree_and_align
+; CHECK-SAME: (ptr [[P:%.*]]) {
+; CHECK-NEXT:call void @bar1(ptr [[P]])
+; CHECK-NEXT:ret void
+;
+  call void @foo1(ptr nofree align 32 %p)
+  ret void
+}
+
 define void @prop_param_deref_align_no_update(ptr %p) {
 ; CHECK-LABEL: define {{[^@]+}}@prop_param_deref_align_no_update
 ; CHECK-SAME: (ptr [[P:%.*]]) {
@@ -538,7 +548,6 @@ define void @prop_no_conflict_writable(ptr %p) {
   ret void
 }
 
-
 define void @prop_no_conflict_writable2(ptr %p) {
 ; CHECK-LABEL: define {{[^@]+}}@prop_no_conflict_writable2
 ; CHECK-SAME: (ptr [[P:%.*]]) {
@@ -552,8 +561,151 @@ define void @prop_no_conflict_writable2(ptr %p) {
 define void @prop_byval_readonly(ptr %p) {
 ; CHECK-LABEL: define {{[^@]+}}@prop_byval_readonly
 ; CHECK-SAME: (ptr [[P:%.*]]) {
-; CHECK-NEXT:   call void @bar4(ptr byval([4 x i32]) [[P]])
-; CHECK-NEXT:   ret void
+; CHECK-NEXT:call void @bar4(ptr byval([4 x i32]) [[P]])
+; CHECK-NEXT:ret void
+;
   call void @foo_byval_readonly(ptr %p)
   ret void
 }
+
+declare void @bar5(i32)
+
+define dso_local void @foo4_range_0_10(i32 %v) {
+; CHECK-LABEL: define {{[^@]+}}@foo4_range_0_10
+; CHECK-SAME: (i32 [[V:%.*]]) {
+; CHECK-NEXT:call void @bar5(i32 range(i32 0, 10) [[V]])
+; CHECK-NEXT:ret void
+;
+  call void @bar5(i32 range(i32 0, 10) %v)
+  ret void
+}
+
+define dso_local void @foo4_range_10_40(i32 %v) {
+; CHECK-LABEL: define {{[^@]+}}@foo4_range_10_40
+; CHECK-SAME: (i32 [[V:%.*]]) {
+; CHECK-NEXT:call void @bar5(i32 range(i32 10, 40) [[V]])
+; CHECK-NEXT:ret void
+;
+  call void @bar5(i32 range(i32 10, 40) %v)
+  ret void
+}
+
+define dso_local void @foo4_2_range_0_10(i32 range(i32 0, 10) %v) {
+; CHECK-LABEL: define {{[^@]+}}@foo4_2_range_0_10
+; CHECK-SAME: (i32 range(i32 0, 10) [[V:%.*]]) {
+; CHECK-NEXT:call void @bar5(i32 [[V]])
+; CHECK-NEXT:ret void
+;
+  call void @bar5(i32 %v)
+  ret void
+}
+
+define dso_local void @foo4(i32 %v) {
+; CHECK-LABEL: define {{[^@]+}}@foo4
+; CHECK-SAME: (i32 [[V:%.*]]) {
+; CHECK-NEXT:call void @bar5(i32 [[V]])
+; CHECK-NEXT:ret void
+;
+  call void @bar5(i32 %v)
+  ret void
+}
+
+define void @prop_range_empty_intersect(i32 %v) {
+; CHECK-LABEL: define {{[^@]+}}@prop_range_empty_intersect
+; CHECK-SAME: (i32 [[V:%.*]]) {
+; CHECK-NEXT:call void @bar5(i32 range(i32 0, 10) [[V]])
+; CHECK-NEXT:ret void
+;
+  call void @foo4_range_0_10(i32 range(i32 11, 50) %v)
+  ret void
+}
+
+define void @prop_range_empty(i32 %v) {
+; CHECK-LABEL: define {{[^@]+}}@prop_range_empty
+; CHECK-SAME: (i32 [[V:%.*]]) {
+; CHECK-NEXT:call void @bar5(i32 [[V]])
+; CHECK-NEXT:ret void
+;
+  call void @foo4(i32 range(i32 1, 0) %v)
+  ret void
+}
+
+define void @prop_range_empty_with_intersect(i32 %v) {
+; CHECK-LABEL: define {{[^@]+}}@prop_range_empty_with_intersect
+; CHECK-SAME: (i32 [[V:%.*]]) {
+; CHECK-NEXT:call void @bar5(i32 range(i32 0, 10) [[V]])
+; CHECK-NEXT:ret void
+;
+  call void @foo4_range_0_10(i32 range(i32 1, 0) %v)
+  ret void
+}
+
+define void @prop_range_intersect1(i32 %v) {
+; CHECK-LABEL: define {{[^@]+}}@prop_range_intersect1
+; CHECK-SAME: (i32 [[V:%.*]]) {
+; CHECK-NEXT:call void @bar5(i32 range(i32 0, 10) [[V]])
+; CHECK-NEXT:ret void
+;
+  call void @foo4_range_0_10(i32 range(i32 0, 9) %v)
+  ret void
+}
+
+define void @prop_r

[clang] [llvm] [PowerPC] Diagnose musttail instead of crash inside backend (PR #93267)

2024-05-29 Thread Chen Zheng via cfe-commits


@@ -743,6 +743,20 @@ bool Sema::checkMustTailAttr(const Stmt *St, const Attr 
&MTA) {
 CallerType.Func = CallerDecl->getType()->getAs();
   }
 
+  if (Context.getTargetInfo().getTriple().isPPC()) {
+if (Context.getTargetInfo().getTriple().isOSAIX())
+  return Diag(St->getBeginLoc(), diag::err_aix_musttail_unsupported);
+else if (!Context.getTargetInfo().hasFeature("pcrelative-memops")) {
+  if (Context.getTargetInfo().hasFeature("longcall"))
+return Diag(St->getBeginLoc(), diag::err_ppc_impossible_musttail) << 0;
+  else if (!CE->getDirectCallee())
+return Diag(St->getBeginLoc(), diag::err_ppc_impossible_musttail) << 1;
+  else if (isa_and_nonnull(CE->getCalleeDecl()) &&

chenzheng1030 wrote:

`2.c` can be detected by checking the callee definition is weak.

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


[clang] [llvm] [PowerPC] Diagnose musttail instead of crash inside backend (PR #93267)

2024-05-29 Thread Chen Zheng via cfe-commits


@@ -743,6 +743,20 @@ bool Sema::checkMustTailAttr(const Stmt *St, const Attr 
&MTA) {
 CallerType.Func = CallerDecl->getType()->getAs();
   }
 
+  if (Context.getTargetInfo().getTriple().isPPC()) {
+if (Context.getTargetInfo().getTriple().isOSAIX())
+  return Diag(St->getBeginLoc(), diag::err_aix_musttail_unsupported);
+else if (!Context.getTargetInfo().hasFeature("pcrelative-memops")) {
+  if (Context.getTargetInfo().hasFeature("longcall"))
+return Diag(St->getBeginLoc(), diag::err_ppc_impossible_musttail) << 0;
+  else if (!CE->getDirectCallee())
+return Diag(St->getBeginLoc(), diag::err_ppc_impossible_musttail) << 1;
+  else if (isa_and_nonnull(CE->getCalleeDecl()) &&

chenzheng1030 wrote:

Thanks for comments. @efriedma-quic 

I tried below two cases, 
```
$ cat 1.c
int func2(int i);
int external_call2(int i) {
  [[clang::musttail]] return func2(i);
}

int func2(int i) {
  return 0;
}
$ cat 2.c

__attribute__((weak)) int func2(int i) {
  return 0;
}
int external_call2(int i) {
  [[clang::musttail]] return func2(i);
}
```

- `1.c` is good to compile without this patch, but now it is mistakenly 
reported as invalid to do tail call because the callee is treated as 
undefined...
- `2.c` can not be detected by this patch.

Will try to fix this. If you have any idea to fix these two issues in your 
mind, please let me know!

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


[clang] [clang-format] add an option to insert a space only for non-code block empty braces, not for empty parentheses (PR #93634)

2024-05-29 Thread Kohei Asano via cfe-commits

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


[clang] [clang-format] add an option to insert a space only for non-code block empty braces, not for empty parentheses (PR #93634)

2024-05-29 Thread Kohei Asano via cfe-commits

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


[clang] [clang-format] add an option to insert a space only for non-code block empty braces, not for empty parentheses (PR #93634)

2024-05-29 Thread Kohei Asano via cfe-commits


@@ -4682,18 +4693,20 @@ struct FormatStyle {
 
 SpacesInParensCustom()

khei4 wrote:

Thanks for a good catch! I think more correspondence with [`.clang-format` 
](https://github.com/WebKit/WebKit/blob/main/.clang-format) and `basedOnStyle: 
WebKit`, and WebKit style checker script requires more fixes, I may update 
other things later ;)

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


[clang] [clang-format] add an option to insert a space only for non-code block empty braces, not for empty parentheses (PR #93634)

2024-05-29 Thread Kohei Asano via cfe-commits


@@ -14027,6 +14027,11 @@ TEST_F(FormatTest, LayoutCxx11BraceInitializers) {
   SpaceBetweenBraces.SpacesInParens = FormatStyle::SIPO_Custom;
   SpaceBetweenBraces.SpacesInParensOptions.InEmptyParentheses = true;
   verifyFormat("vector< int > x{ };", SpaceBetweenBraces);
+  SpaceBetweenBraces.SpacesInParens = FormatStyle::SIPO_Custom;
+  SpaceBetweenBraces.SpacesInParensOptions.InEmptyParentheses = false;
+  SpaceBetweenBraces.SpacesInParensOptions.Other = false;
+  SpaceBetweenBraces.SpacesInParensOptions.InEmptyBraces = true;
+  verifyFormat("T x = { };\nf(x, { });\ng();", SpaceBetweenBraces);
 }

khei4 wrote:

Sounds reasonable, I replace `f(x, { });` with `toImpl(listenerRef)->use({ 
});\n` and drop a comment, thanks!

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


[clang] [analyzer] New optin.taint.TaintAlloc checker for catching unbounded memory allocation calls (PR #92420)

2024-05-29 Thread Donát Nagy via cfe-commits

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

LGTM, thanks for the update!

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


[clang] [clang-format] add an option to insert a space only for non-code block empty braces, not for empty parentheses (PR #93634)

2024-05-29 Thread Kohei Asano via cfe-commits

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


[clang] [clang-format] add an option to insert a space only for non-code block empty braces, not for empty parentheses (PR #93634)

2024-05-29 Thread via cfe-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff 203232ffbd80e9f4631213a3876f14dde155a92d 
d75153bb6777aacf4f08c2c08eca27646bb08727 -- clang/include/clang/Format/Format.h 
clang/lib/Format/Format.cpp clang/lib/Format/TokenAnnotator.cpp 
clang/unittests/Format/ConfigParseTest.cpp clang/unittests/Format/FormatTest.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 7909f8175b..c72bb25b4b 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -14033,7 +14033,8 @@ TEST_F(FormatTest, LayoutCxx11BraceInitializers) {
   SpaceBetweenBraces.SpacesInParensOptions.InEmptyBraces = true;
   verifyFormat("T x = { };\n"
"f(x, { });\n"
-   "g();", SpaceBetweenBraces);
+   "g();",
+   SpaceBetweenBraces);
 }
 
 TEST_F(FormatTest, FormatsBracedListsInColumnLayout) {

``




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


[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)

2024-05-29 Thread Freddy Ye via cfe-commits


@@ -57581,6 +57581,14 @@ X86TargetLowering::getConstraintType(StringRef 
Constraint) const {
   case '2':
 return C_RegisterClass;
   }
+case 'j':
+  switch (Constraint[1]) {
+  default:
+break;
+  case 'r':
+  case 'R':
+return C_RegisterClass;

FreddyLeaf wrote:

relate assertion:
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:9938: void 
llvm::SelectionDAGBuilder::visitInlineAsm(const llvm::CallBase&, const 
llvm::BasicBlock*): Assertion `(OpIn
fo.ConstraintType == TargetLowering::C_RegisterClass || OpInfo.ConstraintType 
== TargetLowering::C_Register) && "Unknown constraint type!"' failed.

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


[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)

2024-05-29 Thread Freddy Ye via cfe-commits


@@ -57660,6 +57668,19 @@ X86TargetLowering::getSingleConstraintMatchWeight(
   break;
 }
 break;
+  case 'j':
+if (StringRef(Constraint).size() != 2)
+  break;
+switch (Constraint[1]) {
+default:
+  return CW_Invalid;
+case 'r':
+case 'R':
+  if (CallOperandVal->getType()->isIntegerTy())
+Wt = CW_SpecificReg;

FreddyLeaf wrote:

ditto

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


[clang] [clang-format] add an option to insert a space only for non-code block empty braces, not for empty parentheses (PR #93634)

2024-05-29 Thread Kohei Asano via cfe-commits

https://github.com/khei4 updated https://github.com/llvm/llvm-project/pull/93634

>From f9022ddba4dd26dea5d04dbcd3c256d2d42b3bad Mon Sep 17 00:00:00 2001
From: Kohei Asano 
Date: Wed, 29 May 2024 11:40:39 +0900
Subject: [PATCH 1/2] [clang-format] add an option to insert a space only for
 empty braces

---
 clang/docs/ClangFormatStyleOptions.rst | 14 +-
 clang/include/clang/Format/Format.h| 21 +
 clang/lib/Format/Format.cpp|  1 +
 clang/lib/Format/TokenAnnotator.cpp|  5 +
 clang/unittests/Format/ConfigParseTest.cpp | 21 +
 clang/unittests/Format/FormatTest.cpp  |  5 +
 6 files changed, 54 insertions(+), 13 deletions(-)

diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 6d092219877f9..a1944eec8582b 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -6237,18 +6237,30 @@ the configuration (without a prefix: ``Auto``).
true:  false:
x = ( int32 )y vs. x = (int32)y
 
-  * ``bool InEmptyParentheses`` Put a space in parentheses only if the 
parentheses are empty i.e. '()'
+  * ``bool InEmptyParentheses`` Put a space in parentheses and braces only if 
they are empty i.e. '()' or '{}'
 
 .. code-block:: c++
 
true:false:
void f( ) {vs.   void f() {
  int x[] = {foo( ), bar( )};  int x[] = {foo(), bar()};
+ T a = { };   T a = {};
  if (true) {  if (true) {
f( );f();
  }}
}}
 
+  * ``bool InEmptyBraces`` Put a space in *only* braces, not for parentheses, 
only if the braces are empty i.e. '{}'
+
+.. code-block:: c++
+
+   true:false:
+   void f() { vs.   void f() {
+ T x = {};T x = { };
+ g(x, {});g(x, { });
+   }}
+
+
   * ``bool Other`` Put a space in parentheses not covered by preceding options.
 
 .. code-block:: c++
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 274b45d1bc586..4482f7fb49788 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -4673,6 +4673,17 @@ struct FormatStyle {
 ///}}
 /// \endcode
 bool InEmptyParentheses;
+/// Put a space in brackets only if the parentheses are empty i.e. '()'
+/// \code
+///true:false:
+///void f( ) {vs.   void f() {
+///  int x[] = {foo( ), bar( )};  int x[] = {foo(), bar()};
+///  if (true) {  if (true) {
+///f( );f();
+///  }}
+///}}
+/// \endcode
+bool InEmptyBraces;
 /// Put a space in parentheses not covered by preceding options.
 /// \code
 ///true:  false:
@@ -4682,18 +4693,20 @@ struct FormatStyle {
 
 SpacesInParensCustom()
 : InConditionalStatements(false), InCStyleCasts(false),
-  InEmptyParentheses(false), Other(false) {}
+  InEmptyParentheses(false), InEmptyBraces(false), Other(false) {}
 
 SpacesInParensCustom(bool InConditionalStatements, bool InCStyleCasts,
- bool InEmptyParentheses, bool Other)
+ bool InEmptyParentheses, bool InEmptyBraces,
+ bool Other)
 : InConditionalStatements(InConditionalStatements),
   InCStyleCasts(InCStyleCasts), InEmptyParentheses(InEmptyParentheses),
-  Other(Other) {}
+  InEmptyBraces(InEmptyBraces), Other(Other) {}
 
 bool operator==(const SpacesInParensCustom &R) const {
   return InConditionalStatements == R.InConditionalStatements &&
  InCStyleCasts == R.InCStyleCasts &&
- InEmptyParentheses == R.InEmptyParentheses && Other == R.Other;
+ InEmptyParentheses == R.InEmptyParentheses &&
+ InEmptyBraces == R.InEmptyBraces && Other == R.Other;
 }
 bool operator!=(const SpacesInParensCustom &R) const {
   return !(*this == R);
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 9cba0c2614eef..efcc48b910718 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -723,6 +723,7 @@ template <> struct 
MappingTraits {
 IO.mapOptional("InCStyleCasts", Spaces.InCStyleCasts);
 IO.mapOptional("InConditionalStatements", Spa

[clang] [llvm] [X86] Support EGPR for inline assembly. (PR #92338)

2024-05-29 Thread Freddy Ye via cfe-commits


@@ -57581,6 +57581,14 @@ X86TargetLowering::getConstraintType(StringRef 
Constraint) const {
   case '2':
 return C_RegisterClass;
   }
+case 'j':
+  switch (Constraint[1]) {
+  default:
+break;
+  case 'r':
+  case 'R':
+return C_RegisterClass;

FreddyLeaf wrote:

`r` is handled at TargetLowering::getConstraintType

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


[clang] [llvm] [PowerPC] Diagnose musttail instead of crash inside backend (PR #93267)

2024-05-29 Thread Chen Zheng via cfe-commits

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


  1   2   3   4   >