[clang] [Clang] Add support for [[msvc::noinline]] attribute. (PR #91720)

2024-05-10 Thread Xu Zhang via cfe-commits

https://github.com/simonzgx created 
https://github.com/llvm/llvm-project/pull/91720

None

>From d0cde98f5e933c6f88703a55986f6cc508721fdc Mon Sep 17 00:00:00 2001
From: Xu Zhang 
Date: Fri, 10 May 2024 01:24:24 +0800
Subject: [PATCH 1/2] [Clang] Add support for [[msvc::noinline]] attribute.
 (#90941)

---
 clang/include/clang/Basic/Attr.td   | 5 -
 clang/include/clang/Basic/AttrDocs.td   | 2 ++
 clang/test/CodeGen/attr-ms-noinline.cpp | 0
 clang/test/Sema/attr-ms-noinline.cpp| 0
 4 files changed, 6 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/CodeGen/attr-ms-noinline.cpp
 create mode 100644 clang/test/Sema/attr-ms-noinline.cpp

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 0225598cbbe8a..2c7a238f61764 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -1997,9 +1997,12 @@ def Convergent : InheritableAttr {
 def NoInline : DeclOrStmtAttr {
   let Spellings = [CustomKeyword<"__noinline__">, GCC<"noinline">,
CXX11<"clang", "noinline">, C23<"clang", "noinline">,
+   CXX11<"msvc", "noinline">, C23<"msvc", "noinline">,
Declspec<"noinline">];
   let Accessors = [Accessor<"isClangNoInline", [CXX11<"clang", "noinline">,
-C23<"clang", "noinline">]>];
+C23<"clang", "noinline">,
+CXX11<"msvc", "noinline">,
+C23<"msvc", "noinline">]>];
   let Documentation = [NoInlineDocs];
   let Subjects = SubjectList<[Function, Stmt], WarnDiag,
  "functions and statements">;
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 8e6faabfae647..0ef636f716be5 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -597,6 +597,8 @@ spellings of the attribute are not supported on statements. 
If a statement is
 marked ``[[clang::noinline]]`` and contains calls, those calls inside the
 statement will not be inlined by the compiler.
 
+``[[msvc::noinline]]`` 
+
 ``__noinline__`` can be used as a keyword in CUDA/HIP languages. This is to
 avoid diagnostics due to usage of ``__attribute__((__noinline__))``
 with ``__noinline__`` defined as a macro as ``__attribute__((noinline))``.
diff --git a/clang/test/CodeGen/attr-ms-noinline.cpp 
b/clang/test/CodeGen/attr-ms-noinline.cpp
new file mode 100644
index 0..e69de29bb2d1d
diff --git a/clang/test/Sema/attr-ms-noinline.cpp 
b/clang/test/Sema/attr-ms-noinline.cpp
new file mode 100644
index 0..e69de29bb2d1d

>From 1d7973be6024c2fef083960cb2602e95d91985d8 Mon Sep 17 00:00:00 2001
From: Xu Zhang 
Date: Fri, 10 May 2024 17:43:33 +0800
Subject: [PATCH 2/2] add unit test

---
 clang/include/clang/Basic/AttrDocs.td   |  2 -
 clang/test/CodeGen/attr-ms-noinline.cpp | 53 
 clang/test/Sema/attr-ms-noinline.cpp| 66 +
 3 files changed, 119 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 0ef636f716be5..8e6faabfae647 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -597,8 +597,6 @@ spellings of the attribute are not supported on statements. 
If a statement is
 marked ``[[clang::noinline]]`` and contains calls, those calls inside the
 statement will not be inlined by the compiler.
 
-``[[msvc::noinline]]`` 
-
 ``__noinline__`` can be used as a keyword in CUDA/HIP languages. This is to
 avoid diagnostics due to usage of ``__attribute__((__noinline__))``
 with ``__noinline__`` defined as a macro as ``__attribute__((noinline))``.
diff --git a/clang/test/CodeGen/attr-ms-noinline.cpp 
b/clang/test/CodeGen/attr-ms-noinline.cpp
index e69de29bb2d1d..99b0a05af715d 100644
--- a/clang/test/CodeGen/attr-ms-noinline.cpp
+++ b/clang/test/CodeGen/attr-ms-noinline.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -emit-llvm %s -triple x86_64-unknown-linux-gnu -o - | 
FileCheck %s
+
+bool bar();
+void f(bool, bool);
+void g(bool);
+
+static int baz(int x) {
+return x * 10;
+}
+
+[[msvc::noinline]] bool noi() { }
+
+void foo(int i) {
+  [[msvc::noinline]] bar();
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR:[0-9]+]]
+  [[msvc::noinline]] i = baz(i);
+// CHECK: call noundef i32 @_ZL3bazi({{.*}}) #[[NOINLINEATTR]]
+  [[msvc::noinline]] (i = 4, bar());
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
+  [[msvc::noinline]] (void)(bar());
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
+  [[msvc::noinline]] f(bar(), bar());
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
+// CHECK: call void @_Z1fbb({{.*}}) #[[NOINLINEATTR]]
+  [[msvc::noinline]] [] { ba

[clang] [Clang] Add support for [[msvc::noinline]] attribute. (PR #91720)

2024-05-10 Thread Xu Zhang via cfe-commits

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


[clang] [Clang] Add support for [[msvc::noinline]] attribute. (PR #91720)

2024-05-10 Thread Xu Zhang via cfe-commits

https://github.com/simonzgx updated 
https://github.com/llvm/llvm-project/pull/91720

>From d0cde98f5e933c6f88703a55986f6cc508721fdc Mon Sep 17 00:00:00 2001
From: Xu Zhang 
Date: Fri, 10 May 2024 01:24:24 +0800
Subject: [PATCH 1/2] [Clang] Add support for [[msvc::noinline]] attribute.
 (#90941)

---
 clang/include/clang/Basic/Attr.td   | 5 -
 clang/include/clang/Basic/AttrDocs.td   | 2 ++
 clang/test/CodeGen/attr-ms-noinline.cpp | 0
 clang/test/Sema/attr-ms-noinline.cpp| 0
 4 files changed, 6 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/CodeGen/attr-ms-noinline.cpp
 create mode 100644 clang/test/Sema/attr-ms-noinline.cpp

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 0225598cbbe8a..2c7a238f61764 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -1997,9 +1997,12 @@ def Convergent : InheritableAttr {
 def NoInline : DeclOrStmtAttr {
   let Spellings = [CustomKeyword<"__noinline__">, GCC<"noinline">,
CXX11<"clang", "noinline">, C23<"clang", "noinline">,
+   CXX11<"msvc", "noinline">, C23<"msvc", "noinline">,
Declspec<"noinline">];
   let Accessors = [Accessor<"isClangNoInline", [CXX11<"clang", "noinline">,
-C23<"clang", "noinline">]>];
+C23<"clang", "noinline">,
+CXX11<"msvc", "noinline">,
+C23<"msvc", "noinline">]>];
   let Documentation = [NoInlineDocs];
   let Subjects = SubjectList<[Function, Stmt], WarnDiag,
  "functions and statements">;
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 8e6faabfae647..0ef636f716be5 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -597,6 +597,8 @@ spellings of the attribute are not supported on statements. 
If a statement is
 marked ``[[clang::noinline]]`` and contains calls, those calls inside the
 statement will not be inlined by the compiler.
 
+``[[msvc::noinline]]`` 
+
 ``__noinline__`` can be used as a keyword in CUDA/HIP languages. This is to
 avoid diagnostics due to usage of ``__attribute__((__noinline__))``
 with ``__noinline__`` defined as a macro as ``__attribute__((noinline))``.
diff --git a/clang/test/CodeGen/attr-ms-noinline.cpp 
b/clang/test/CodeGen/attr-ms-noinline.cpp
new file mode 100644
index 0..e69de29bb2d1d
diff --git a/clang/test/Sema/attr-ms-noinline.cpp 
b/clang/test/Sema/attr-ms-noinline.cpp
new file mode 100644
index 0..e69de29bb2d1d

>From e17ba55102457f2d37bdea9adb49b47edddad115 Mon Sep 17 00:00:00 2001
From: Xu Zhang 
Date: Fri, 10 May 2024 17:46:40 +0800
Subject: [PATCH 2/2] add unit test

---
 clang/include/clang/Basic/AttrDocs.td   |  2 -
 clang/test/CodeGen/attr-ms-noinline.cpp | 53 
 clang/test/Sema/attr-ms-noinline.cpp| 66 +
 3 files changed, 119 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 0ef636f716be5..8e6faabfae647 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -597,8 +597,6 @@ spellings of the attribute are not supported on statements. 
If a statement is
 marked ``[[clang::noinline]]`` and contains calls, those calls inside the
 statement will not be inlined by the compiler.
 
-``[[msvc::noinline]]`` 
-
 ``__noinline__`` can be used as a keyword in CUDA/HIP languages. This is to
 avoid diagnostics due to usage of ``__attribute__((__noinline__))``
 with ``__noinline__`` defined as a macro as ``__attribute__((noinline))``.
diff --git a/clang/test/CodeGen/attr-ms-noinline.cpp 
b/clang/test/CodeGen/attr-ms-noinline.cpp
index e69de29bb2d1d..99b0a05af715d 100644
--- a/clang/test/CodeGen/attr-ms-noinline.cpp
+++ b/clang/test/CodeGen/attr-ms-noinline.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -emit-llvm %s -triple x86_64-unknown-linux-gnu -o - | 
FileCheck %s
+
+bool bar();
+void f(bool, bool);
+void g(bool);
+
+static int baz(int x) {
+return x * 10;
+}
+
+[[msvc::noinline]] bool noi() { }
+
+void foo(int i) {
+  [[msvc::noinline]] bar();
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR:[0-9]+]]
+  [[msvc::noinline]] i = baz(i);
+// CHECK: call noundef i32 @_ZL3bazi({{.*}}) #[[NOINLINEATTR]]
+  [[msvc::noinline]] (i = 4, bar());
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
+  [[msvc::noinline]] (void)(bar());
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
+  [[msvc::noinline]] f(bar(), bar());
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
+// CHECK: call void @_Z1fbb({{.*}}) #[[NOINLINEATTR]]
+  [[msvc::noinline]] [] { bar(); b

[clang] [Clang] Add support for [[msvc::noinline]] attribute. (PR #91720)

2024-05-10 Thread Xu Zhang via cfe-commits

https://github.com/simonzgx updated 
https://github.com/llvm/llvm-project/pull/91720

>From 2dd3d3385642d88d538bc37673018f1231a56b14 Mon Sep 17 00:00:00 2001
From: Xu Zhang 
Date: Fri, 10 May 2024 01:24:24 +0800
Subject: [PATCH 1/2] [Clang] Add support for [[msvc::noinline]] attribute.
 (#90941)

---
 clang/include/clang/Basic/Attr.td   | 5 -
 clang/include/clang/Basic/AttrDocs.td   | 2 ++
 clang/test/CodeGen/attr-ms-noinline.cpp | 0
 clang/test/Sema/attr-ms-noinline.cpp| 0
 4 files changed, 6 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/CodeGen/attr-ms-noinline.cpp
 create mode 100644 clang/test/Sema/attr-ms-noinline.cpp

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 52552ba488560..81fcb8aba04f3 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -1997,9 +1997,12 @@ def Convergent : InheritableAttr {
 def NoInline : DeclOrStmtAttr {
   let Spellings = [CustomKeyword<"__noinline__">, GCC<"noinline">,
CXX11<"clang", "noinline">, C23<"clang", "noinline">,
+   CXX11<"msvc", "noinline">, C23<"msvc", "noinline">,
Declspec<"noinline">];
   let Accessors = [Accessor<"isClangNoInline", [CXX11<"clang", "noinline">,
-C23<"clang", "noinline">]>];
+C23<"clang", "noinline">,
+CXX11<"msvc", "noinline">,
+C23<"msvc", "noinline">]>];
   let Documentation = [NoInlineDocs];
   let Subjects = SubjectList<[Function, Stmt], WarnDiag,
  "functions and statements">;
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index f351822ac74bd..d5540f70ac927 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -597,6 +597,8 @@ spellings of the attribute are not supported on statements. 
If a statement is
 marked ``[[clang::noinline]]`` and contains calls, those calls inside the
 statement will not be inlined by the compiler.
 
+``[[msvc::noinline]]`` 
+
 ``__noinline__`` can be used as a keyword in CUDA/HIP languages. This is to
 avoid diagnostics due to usage of ``__attribute__((__noinline__))``
 with ``__noinline__`` defined as a macro as ``__attribute__((noinline))``.
diff --git a/clang/test/CodeGen/attr-ms-noinline.cpp 
b/clang/test/CodeGen/attr-ms-noinline.cpp
new file mode 100644
index 0..e69de29bb2d1d
diff --git a/clang/test/Sema/attr-ms-noinline.cpp 
b/clang/test/Sema/attr-ms-noinline.cpp
new file mode 100644
index 0..e69de29bb2d1d

>From 2029279c3c8fe13920f92547ddc2a5db305f Mon Sep 17 00:00:00 2001
From: Xu Zhang 
Date: Fri, 10 May 2024 17:46:40 +0800
Subject: [PATCH 2/2] add unit test

---
 clang/include/clang/Basic/AttrDocs.td   |  2 -
 clang/test/CodeGen/attr-ms-noinline.cpp | 53 
 clang/test/Sema/attr-ms-noinline.cpp| 66 +
 3 files changed, 119 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index d5540f70ac927..f351822ac74bd 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -597,8 +597,6 @@ spellings of the attribute are not supported on statements. 
If a statement is
 marked ``[[clang::noinline]]`` and contains calls, those calls inside the
 statement will not be inlined by the compiler.
 
-``[[msvc::noinline]]`` 
-
 ``__noinline__`` can be used as a keyword in CUDA/HIP languages. This is to
 avoid diagnostics due to usage of ``__attribute__((__noinline__))``
 with ``__noinline__`` defined as a macro as ``__attribute__((noinline))``.
diff --git a/clang/test/CodeGen/attr-ms-noinline.cpp 
b/clang/test/CodeGen/attr-ms-noinline.cpp
index e69de29bb2d1d..99b0a05af715d 100644
--- a/clang/test/CodeGen/attr-ms-noinline.cpp
+++ b/clang/test/CodeGen/attr-ms-noinline.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -emit-llvm %s -triple x86_64-unknown-linux-gnu -o - | 
FileCheck %s
+
+bool bar();
+void f(bool, bool);
+void g(bool);
+
+static int baz(int x) {
+return x * 10;
+}
+
+[[msvc::noinline]] bool noi() { }
+
+void foo(int i) {
+  [[msvc::noinline]] bar();
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR:[0-9]+]]
+  [[msvc::noinline]] i = baz(i);
+// CHECK: call noundef i32 @_ZL3bazi({{.*}}) #[[NOINLINEATTR]]
+  [[msvc::noinline]] (i = 4, bar());
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
+  [[msvc::noinline]] (void)(bar());
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
+  [[msvc::noinline]] f(bar(), bar());
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
+// CHECK: call void @_Z1fbb({{.*}}) #[[NOINLINEATTR]]
+  [[msvc::noinline]] [] { bar(); b

[clang] [Clang] Add support for [[msvc::noinline]] attribute. (PR #91720)

2024-05-11 Thread Xu Zhang via cfe-commits

https://github.com/simonzgx updated 
https://github.com/llvm/llvm-project/pull/91720

>From 2dd3d3385642d88d538bc37673018f1231a56b14 Mon Sep 17 00:00:00 2001
From: Xu Zhang 
Date: Fri, 10 May 2024 01:24:24 +0800
Subject: [PATCH 1/3] [Clang] Add support for [[msvc::noinline]] attribute.
 (#90941)

---
 clang/include/clang/Basic/Attr.td   | 5 -
 clang/include/clang/Basic/AttrDocs.td   | 2 ++
 clang/test/CodeGen/attr-ms-noinline.cpp | 0
 clang/test/Sema/attr-ms-noinline.cpp| 0
 4 files changed, 6 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/CodeGen/attr-ms-noinline.cpp
 create mode 100644 clang/test/Sema/attr-ms-noinline.cpp

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 52552ba488560..81fcb8aba04f3 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -1997,9 +1997,12 @@ def Convergent : InheritableAttr {
 def NoInline : DeclOrStmtAttr {
   let Spellings = [CustomKeyword<"__noinline__">, GCC<"noinline">,
CXX11<"clang", "noinline">, C23<"clang", "noinline">,
+   CXX11<"msvc", "noinline">, C23<"msvc", "noinline">,
Declspec<"noinline">];
   let Accessors = [Accessor<"isClangNoInline", [CXX11<"clang", "noinline">,
-C23<"clang", "noinline">]>];
+C23<"clang", "noinline">,
+CXX11<"msvc", "noinline">,
+C23<"msvc", "noinline">]>];
   let Documentation = [NoInlineDocs];
   let Subjects = SubjectList<[Function, Stmt], WarnDiag,
  "functions and statements">;
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index f351822ac74bd..d5540f70ac927 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -597,6 +597,8 @@ spellings of the attribute are not supported on statements. 
If a statement is
 marked ``[[clang::noinline]]`` and contains calls, those calls inside the
 statement will not be inlined by the compiler.
 
+``[[msvc::noinline]]`` 
+
 ``__noinline__`` can be used as a keyword in CUDA/HIP languages. This is to
 avoid diagnostics due to usage of ``__attribute__((__noinline__))``
 with ``__noinline__`` defined as a macro as ``__attribute__((noinline))``.
diff --git a/clang/test/CodeGen/attr-ms-noinline.cpp 
b/clang/test/CodeGen/attr-ms-noinline.cpp
new file mode 100644
index 0..e69de29bb2d1d
diff --git a/clang/test/Sema/attr-ms-noinline.cpp 
b/clang/test/Sema/attr-ms-noinline.cpp
new file mode 100644
index 0..e69de29bb2d1d

>From 2029279c3c8fe13920f92547ddc2a5db305f Mon Sep 17 00:00:00 2001
From: Xu Zhang 
Date: Fri, 10 May 2024 17:46:40 +0800
Subject: [PATCH 2/3] add unit test

---
 clang/include/clang/Basic/AttrDocs.td   |  2 -
 clang/test/CodeGen/attr-ms-noinline.cpp | 53 
 clang/test/Sema/attr-ms-noinline.cpp| 66 +
 3 files changed, 119 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index d5540f70ac927..f351822ac74bd 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -597,8 +597,6 @@ spellings of the attribute are not supported on statements. 
If a statement is
 marked ``[[clang::noinline]]`` and contains calls, those calls inside the
 statement will not be inlined by the compiler.
 
-``[[msvc::noinline]]`` 
-
 ``__noinline__`` can be used as a keyword in CUDA/HIP languages. This is to
 avoid diagnostics due to usage of ``__attribute__((__noinline__))``
 with ``__noinline__`` defined as a macro as ``__attribute__((noinline))``.
diff --git a/clang/test/CodeGen/attr-ms-noinline.cpp 
b/clang/test/CodeGen/attr-ms-noinline.cpp
index e69de29bb2d1d..99b0a05af715d 100644
--- a/clang/test/CodeGen/attr-ms-noinline.cpp
+++ b/clang/test/CodeGen/attr-ms-noinline.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -emit-llvm %s -triple x86_64-unknown-linux-gnu -o - | 
FileCheck %s
+
+bool bar();
+void f(bool, bool);
+void g(bool);
+
+static int baz(int x) {
+return x * 10;
+}
+
+[[msvc::noinline]] bool noi() { }
+
+void foo(int i) {
+  [[msvc::noinline]] bar();
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR:[0-9]+]]
+  [[msvc::noinline]] i = baz(i);
+// CHECK: call noundef i32 @_ZL3bazi({{.*}}) #[[NOINLINEATTR]]
+  [[msvc::noinline]] (i = 4, bar());
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
+  [[msvc::noinline]] (void)(bar());
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
+  [[msvc::noinline]] f(bar(), bar());
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
+// CHECK: call void @_Z1fbb({{.*}}) #[[NOINLINEATTR]]
+  [[msvc::noinline]] [] { bar(); b

[clang] [Clang] Add support for [[msvc::noinline]] attribute. (PR #91720)

2024-05-11 Thread Xu Zhang via cfe-commits

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


[clang] [Clang] Add support for [[msvc::noinline]] attribute. (PR #91720)

2024-05-11 Thread Xu Zhang via cfe-commits

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


[clang] [Clang] Add support for [[msvc::noinline]] attribute. (PR #91720)

2024-05-11 Thread Xu Zhang via cfe-commits

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


[clang] [Clang] Add support for [[msvc::noinline]] attribute. (PR #91720)

2024-05-13 Thread Xu Zhang via cfe-commits

simonzgx wrote:

 Hi @cor3ntin, could you please help review this patch?

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


[clang] [Clang] Add support for [[msvc::noinline]] attribute. (PR #91720)

2024-05-17 Thread Xu Zhang via cfe-commits

simonzgx wrote:

Hi @cor3ntin , this is just a gentle reminder to confirm if it is still 
convenient for you to review this patch, or if you could assist in inviting 
other appropriate reviewers? Thank you.

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


[clang] [Clang] Add support for [[msvc::noinline]] attribute. (PR #91720)

2024-05-17 Thread Xu Zhang via cfe-commits


@@ -0,0 +1,72 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s -Wno-c++17-extensions

simonzgx wrote:

Okay, will fix.

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


[clang] [Clang] Add support for [[msvc::noinline]] attribute. (PR #91720)

2024-05-17 Thread Xu Zhang via cfe-commits


@@ -1997,9 +1997,12 @@ def Convergent : InheritableAttr {
 def NoInline : DeclOrStmtAttr {
   let Spellings = [CustomKeyword<"__noinline__">, GCC<"noinline">,
CXX11<"clang", "noinline">, C23<"clang", "noinline">,
+   CXX11<"msvc", "noinline">, C23<"msvc", "noinline">,
Declspec<"noinline">];
   let Accessors = [Accessor<"isClangNoInline", [CXX11<"clang", "noinline">,

simonzgx wrote:

Do you mean to add a new accessors and name it `isStmtNoInline`?

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


[clang] [Clang] Add support for [[msvc::noinline]] attribute. (PR #91720)

2024-05-17 Thread Xu Zhang via cfe-commits


@@ -1997,9 +1997,12 @@ def Convergent : InheritableAttr {
 def NoInline : DeclOrStmtAttr {
   let Spellings = [CustomKeyword<"__noinline__">, GCC<"noinline">,
CXX11<"clang", "noinline">, C23<"clang", "noinline">,
+   CXX11<"msvc", "noinline">, C23<"msvc", "noinline">,
Declspec<"noinline">];
   let Accessors = [Accessor<"isClangNoInline", [CXX11<"clang", "noinline">,

simonzgx wrote:

okay, got it.

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


[clang] [Clang] Add support for [[msvc::noinline]] attribute. (PR #91720)

2024-05-19 Thread Xu Zhang via cfe-commits

https://github.com/simonzgx updated 
https://github.com/llvm/llvm-project/pull/91720

>From 54b69712d2ffc3536d41d56194e67da802b92049 Mon Sep 17 00:00:00 2001
From: Xu Zhang 
Date: Fri, 10 May 2024 01:24:24 +0800
Subject: [PATCH 1/3] [Clang] Add support for [[msvc::noinline]] attribute.
 (#90941)

---
 clang/include/clang/Basic/Attr.td   | 5 -
 clang/include/clang/Basic/AttrDocs.td   | 2 ++
 clang/test/CodeGen/attr-ms-noinline.cpp | 0
 clang/test/Sema/attr-ms-noinline.cpp| 0
 4 files changed, 6 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/CodeGen/attr-ms-noinline.cpp
 create mode 100644 clang/test/Sema/attr-ms-noinline.cpp

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 7a7721239a28f..8532e5c47fe47 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -1997,9 +1997,12 @@ def Convergent : InheritableAttr {
 def NoInline : DeclOrStmtAttr {
   let Spellings = [CustomKeyword<"__noinline__">, GCC<"noinline">,
CXX11<"clang", "noinline">, C23<"clang", "noinline">,
+   CXX11<"msvc", "noinline">, C23<"msvc", "noinline">,
Declspec<"noinline">];
   let Accessors = [Accessor<"isClangNoInline", [CXX11<"clang", "noinline">,
-C23<"clang", "noinline">]>];
+C23<"clang", "noinline">,
+CXX11<"msvc", "noinline">,
+C23<"msvc", "noinline">]>];
   let Documentation = [NoInlineDocs];
   let Subjects = SubjectList<[Function, Stmt], WarnDiag,
  "functions and statements">;
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index b48aaf65558ac..7442f7e828462 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -597,6 +597,8 @@ spellings of the attribute are not supported on statements. 
If a statement is
 marked ``[[clang::noinline]]`` and contains calls, those calls inside the
 statement will not be inlined by the compiler.
 
+``[[msvc::noinline]]`` 
+
 ``__noinline__`` can be used as a keyword in CUDA/HIP languages. This is to
 avoid diagnostics due to usage of ``__attribute__((__noinline__))``
 with ``__noinline__`` defined as a macro as ``__attribute__((noinline))``.
diff --git a/clang/test/CodeGen/attr-ms-noinline.cpp 
b/clang/test/CodeGen/attr-ms-noinline.cpp
new file mode 100644
index 0..e69de29bb2d1d
diff --git a/clang/test/Sema/attr-ms-noinline.cpp 
b/clang/test/Sema/attr-ms-noinline.cpp
new file mode 100644
index 0..e69de29bb2d1d

>From bbc27cb48f616a98d4d379b8ac72e0c408c8ca64 Mon Sep 17 00:00:00 2001
From: Xu Zhang 
Date: Fri, 10 May 2024 17:46:40 +0800
Subject: [PATCH 2/3] add unit test

---
 clang/include/clang/Basic/AttrDocs.td   |  2 -
 clang/test/CodeGen/attr-ms-noinline.cpp | 53 
 clang/test/Sema/attr-ms-noinline.cpp| 66 +
 3 files changed, 119 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 7442f7e828462..b48aaf65558ac 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -597,8 +597,6 @@ spellings of the attribute are not supported on statements. 
If a statement is
 marked ``[[clang::noinline]]`` and contains calls, those calls inside the
 statement will not be inlined by the compiler.
 
-``[[msvc::noinline]]`` 
-
 ``__noinline__`` can be used as a keyword in CUDA/HIP languages. This is to
 avoid diagnostics due to usage of ``__attribute__((__noinline__))``
 with ``__noinline__`` defined as a macro as ``__attribute__((noinline))``.
diff --git a/clang/test/CodeGen/attr-ms-noinline.cpp 
b/clang/test/CodeGen/attr-ms-noinline.cpp
index e69de29bb2d1d..99b0a05af715d 100644
--- a/clang/test/CodeGen/attr-ms-noinline.cpp
+++ b/clang/test/CodeGen/attr-ms-noinline.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -emit-llvm %s -triple x86_64-unknown-linux-gnu -o - | 
FileCheck %s
+
+bool bar();
+void f(bool, bool);
+void g(bool);
+
+static int baz(int x) {
+return x * 10;
+}
+
+[[msvc::noinline]] bool noi() { }
+
+void foo(int i) {
+  [[msvc::noinline]] bar();
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR:[0-9]+]]
+  [[msvc::noinline]] i = baz(i);
+// CHECK: call noundef i32 @_ZL3bazi({{.*}}) #[[NOINLINEATTR]]
+  [[msvc::noinline]] (i = 4, bar());
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
+  [[msvc::noinline]] (void)(bar());
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
+  [[msvc::noinline]] f(bar(), bar());
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
+// CHECK: call void @_Z1fbb({{.*}}) #[[NOINLINEATTR]]
+  [[msvc::noinline]] [] { bar(); b

[clang] [Clang] Add support for [[msvc::noinline]] attribute. (PR #91720)

2024-05-19 Thread Xu Zhang via cfe-commits

https://github.com/simonzgx updated 
https://github.com/llvm/llvm-project/pull/91720

>From 54b69712d2ffc3536d41d56194e67da802b92049 Mon Sep 17 00:00:00 2001
From: Xu Zhang 
Date: Fri, 10 May 2024 01:24:24 +0800
Subject: [PATCH 1/4] [Clang] Add support for [[msvc::noinline]] attribute.
 (#90941)

---
 clang/include/clang/Basic/Attr.td   | 5 -
 clang/include/clang/Basic/AttrDocs.td   | 2 ++
 clang/test/CodeGen/attr-ms-noinline.cpp | 0
 clang/test/Sema/attr-ms-noinline.cpp| 0
 4 files changed, 6 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/CodeGen/attr-ms-noinline.cpp
 create mode 100644 clang/test/Sema/attr-ms-noinline.cpp

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 7a7721239a28f..8532e5c47fe47 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -1997,9 +1997,12 @@ def Convergent : InheritableAttr {
 def NoInline : DeclOrStmtAttr {
   let Spellings = [CustomKeyword<"__noinline__">, GCC<"noinline">,
CXX11<"clang", "noinline">, C23<"clang", "noinline">,
+   CXX11<"msvc", "noinline">, C23<"msvc", "noinline">,
Declspec<"noinline">];
   let Accessors = [Accessor<"isClangNoInline", [CXX11<"clang", "noinline">,
-C23<"clang", "noinline">]>];
+C23<"clang", "noinline">,
+CXX11<"msvc", "noinline">,
+C23<"msvc", "noinline">]>];
   let Documentation = [NoInlineDocs];
   let Subjects = SubjectList<[Function, Stmt], WarnDiag,
  "functions and statements">;
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index b48aaf65558ac..7442f7e828462 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -597,6 +597,8 @@ spellings of the attribute are not supported on statements. 
If a statement is
 marked ``[[clang::noinline]]`` and contains calls, those calls inside the
 statement will not be inlined by the compiler.
 
+``[[msvc::noinline]]`` 
+
 ``__noinline__`` can be used as a keyword in CUDA/HIP languages. This is to
 avoid diagnostics due to usage of ``__attribute__((__noinline__))``
 with ``__noinline__`` defined as a macro as ``__attribute__((noinline))``.
diff --git a/clang/test/CodeGen/attr-ms-noinline.cpp 
b/clang/test/CodeGen/attr-ms-noinline.cpp
new file mode 100644
index 0..e69de29bb2d1d
diff --git a/clang/test/Sema/attr-ms-noinline.cpp 
b/clang/test/Sema/attr-ms-noinline.cpp
new file mode 100644
index 0..e69de29bb2d1d

>From bbc27cb48f616a98d4d379b8ac72e0c408c8ca64 Mon Sep 17 00:00:00 2001
From: Xu Zhang 
Date: Fri, 10 May 2024 17:46:40 +0800
Subject: [PATCH 2/4] add unit test

---
 clang/include/clang/Basic/AttrDocs.td   |  2 -
 clang/test/CodeGen/attr-ms-noinline.cpp | 53 
 clang/test/Sema/attr-ms-noinline.cpp| 66 +
 3 files changed, 119 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 7442f7e828462..b48aaf65558ac 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -597,8 +597,6 @@ spellings of the attribute are not supported on statements. 
If a statement is
 marked ``[[clang::noinline]]`` and contains calls, those calls inside the
 statement will not be inlined by the compiler.
 
-``[[msvc::noinline]]`` 
-
 ``__noinline__`` can be used as a keyword in CUDA/HIP languages. This is to
 avoid diagnostics due to usage of ``__attribute__((__noinline__))``
 with ``__noinline__`` defined as a macro as ``__attribute__((noinline))``.
diff --git a/clang/test/CodeGen/attr-ms-noinline.cpp 
b/clang/test/CodeGen/attr-ms-noinline.cpp
index e69de29bb2d1d..99b0a05af715d 100644
--- a/clang/test/CodeGen/attr-ms-noinline.cpp
+++ b/clang/test/CodeGen/attr-ms-noinline.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -emit-llvm %s -triple x86_64-unknown-linux-gnu -o - | 
FileCheck %s
+
+bool bar();
+void f(bool, bool);
+void g(bool);
+
+static int baz(int x) {
+return x * 10;
+}
+
+[[msvc::noinline]] bool noi() { }
+
+void foo(int i) {
+  [[msvc::noinline]] bar();
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR:[0-9]+]]
+  [[msvc::noinline]] i = baz(i);
+// CHECK: call noundef i32 @_ZL3bazi({{.*}}) #[[NOINLINEATTR]]
+  [[msvc::noinline]] (i = 4, bar());
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
+  [[msvc::noinline]] (void)(bar());
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
+  [[msvc::noinline]] f(bar(), bar());
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
+// CHECK: call void @_Z1fbb({{.*}}) #[[NOINLINEATTR]]
+  [[msvc::noinline]] [] { bar(); b

[clang] [Clang] Add support for [[msvc::noinline]] attribute. (PR #91720)

2024-05-19 Thread Xu Zhang via cfe-commits


@@ -1997,9 +1997,12 @@ def Convergent : InheritableAttr {
 def NoInline : DeclOrStmtAttr {
   let Spellings = [CustomKeyword<"__noinline__">, GCC<"noinline">,
CXX11<"clang", "noinline">, C23<"clang", "noinline">,
+   CXX11<"msvc", "noinline">, C23<"msvc", "noinline">,
Declspec<"noinline">];
   let Accessors = [Accessor<"isClangNoInline", [CXX11<"clang", "noinline">,

simonzgx wrote:

`[[msvc::noinline]]` is just an alias of `[[clang::noinline]]`, and maybe we 
don't really need UT for it, so I just deleted the redundant test files. What 
do you think?

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


[clang] [Clang] Add support for [[msvc::noinline]] attribute. (PR #91720)

2024-05-19 Thread Xu Zhang via cfe-commits

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


[clang] [Clang] Add support for [[msvc::noinline]] attribute. (PR #91720)

2024-05-19 Thread Xu Zhang via cfe-commits


@@ -0,0 +1,72 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s -Wno-c++17-extensions

simonzgx wrote:

`[[msvc::noinline]]` is just an alias of `[[clang::noinline]]`, and maybe we 
don't really need UT for it, so I just deleted the redundant test files. What 
do you think?

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


[clang] [Clang] Add support for [[msvc::noinline]] attribute. (PR #91720)

2024-05-19 Thread Xu Zhang via cfe-commits

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


[clang] [Clang] Add support for [[msvc::noinline]] attribute. (PR #91720)

2024-05-19 Thread Xu Zhang via cfe-commits

https://github.com/simonzgx updated 
https://github.com/llvm/llvm-project/pull/91720

>From 54b69712d2ffc3536d41d56194e67da802b92049 Mon Sep 17 00:00:00 2001
From: Xu Zhang 
Date: Fri, 10 May 2024 01:24:24 +0800
Subject: [PATCH 1/4] [Clang] Add support for [[msvc::noinline]] attribute.
 (#90941)

---
 clang/include/clang/Basic/Attr.td   | 5 -
 clang/include/clang/Basic/AttrDocs.td   | 2 ++
 clang/test/CodeGen/attr-ms-noinline.cpp | 0
 clang/test/Sema/attr-ms-noinline.cpp| 0
 4 files changed, 6 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/CodeGen/attr-ms-noinline.cpp
 create mode 100644 clang/test/Sema/attr-ms-noinline.cpp

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 7a7721239a28f..8532e5c47fe47 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -1997,9 +1997,12 @@ def Convergent : InheritableAttr {
 def NoInline : DeclOrStmtAttr {
   let Spellings = [CustomKeyword<"__noinline__">, GCC<"noinline">,
CXX11<"clang", "noinline">, C23<"clang", "noinline">,
+   CXX11<"msvc", "noinline">, C23<"msvc", "noinline">,
Declspec<"noinline">];
   let Accessors = [Accessor<"isClangNoInline", [CXX11<"clang", "noinline">,
-C23<"clang", "noinline">]>];
+C23<"clang", "noinline">,
+CXX11<"msvc", "noinline">,
+C23<"msvc", "noinline">]>];
   let Documentation = [NoInlineDocs];
   let Subjects = SubjectList<[Function, Stmt], WarnDiag,
  "functions and statements">;
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index b48aaf65558ac..7442f7e828462 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -597,6 +597,8 @@ spellings of the attribute are not supported on statements. 
If a statement is
 marked ``[[clang::noinline]]`` and contains calls, those calls inside the
 statement will not be inlined by the compiler.
 
+``[[msvc::noinline]]`` 
+
 ``__noinline__`` can be used as a keyword in CUDA/HIP languages. This is to
 avoid diagnostics due to usage of ``__attribute__((__noinline__))``
 with ``__noinline__`` defined as a macro as ``__attribute__((noinline))``.
diff --git a/clang/test/CodeGen/attr-ms-noinline.cpp 
b/clang/test/CodeGen/attr-ms-noinline.cpp
new file mode 100644
index 0..e69de29bb2d1d
diff --git a/clang/test/Sema/attr-ms-noinline.cpp 
b/clang/test/Sema/attr-ms-noinline.cpp
new file mode 100644
index 0..e69de29bb2d1d

>From bbc27cb48f616a98d4d379b8ac72e0c408c8ca64 Mon Sep 17 00:00:00 2001
From: Xu Zhang 
Date: Fri, 10 May 2024 17:46:40 +0800
Subject: [PATCH 2/4] add unit test

---
 clang/include/clang/Basic/AttrDocs.td   |  2 -
 clang/test/CodeGen/attr-ms-noinline.cpp | 53 
 clang/test/Sema/attr-ms-noinline.cpp| 66 +
 3 files changed, 119 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 7442f7e828462..b48aaf65558ac 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -597,8 +597,6 @@ spellings of the attribute are not supported on statements. 
If a statement is
 marked ``[[clang::noinline]]`` and contains calls, those calls inside the
 statement will not be inlined by the compiler.
 
-``[[msvc::noinline]]`` 
-
 ``__noinline__`` can be used as a keyword in CUDA/HIP languages. This is to
 avoid diagnostics due to usage of ``__attribute__((__noinline__))``
 with ``__noinline__`` defined as a macro as ``__attribute__((noinline))``.
diff --git a/clang/test/CodeGen/attr-ms-noinline.cpp 
b/clang/test/CodeGen/attr-ms-noinline.cpp
index e69de29bb2d1d..99b0a05af715d 100644
--- a/clang/test/CodeGen/attr-ms-noinline.cpp
+++ b/clang/test/CodeGen/attr-ms-noinline.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -emit-llvm %s -triple x86_64-unknown-linux-gnu -o - | 
FileCheck %s
+
+bool bar();
+void f(bool, bool);
+void g(bool);
+
+static int baz(int x) {
+return x * 10;
+}
+
+[[msvc::noinline]] bool noi() { }
+
+void foo(int i) {
+  [[msvc::noinline]] bar();
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR:[0-9]+]]
+  [[msvc::noinline]] i = baz(i);
+// CHECK: call noundef i32 @_ZL3bazi({{.*}}) #[[NOINLINEATTR]]
+  [[msvc::noinline]] (i = 4, bar());
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
+  [[msvc::noinline]] (void)(bar());
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
+  [[msvc::noinline]] f(bar(), bar());
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
+// CHECK: call void @_Z1fbb({{.*}}) #[[NOINLINEATTR]]
+  [[msvc::noinline]] [] { bar(); b

[clang] [Clang] Add support for [[msvc::noinline]] attribute. (PR #91720)

2024-05-19 Thread Xu Zhang via cfe-commits


@@ -0,0 +1,72 @@
+// RUN: %clang_cc1 -verify -fsyntax-only %s -Wno-c++17-extensions

simonzgx wrote:

I removed the redundant unit tests, but no new test cases were added. I'm not 
sure if that's acceptable, because `[[msvc::noinline]]` is just an alias for 
`[[clang::noinline]]`. What do you think?

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


[clang] [Clang] Add support for [[msvc::noinline]] attribute. (PR #91720)

2024-05-19 Thread Xu Zhang via cfe-commits


@@ -1997,9 +1997,12 @@ def Convergent : InheritableAttr {
 def NoInline : DeclOrStmtAttr {
   let Spellings = [CustomKeyword<"__noinline__">, GCC<"noinline">,
CXX11<"clang", "noinline">, C23<"clang", "noinline">,
+   CXX11<"msvc", "noinline">, C23<"msvc", "noinline">,
Declspec<"noinline">];
   let Accessors = [Accessor<"isClangNoInline", [CXX11<"clang", "noinline">,

simonzgx wrote:

done

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


[clang] [Clang] Add support for [[msvc::noinline]] attribute. (PR #91720)

2024-05-21 Thread Xu Zhang via cfe-commits

https://github.com/simonzgx updated 
https://github.com/llvm/llvm-project/pull/91720

>From 54b69712d2ffc3536d41d56194e67da802b92049 Mon Sep 17 00:00:00 2001
From: Xu Zhang 
Date: Fri, 10 May 2024 01:24:24 +0800
Subject: [PATCH 1/5] [Clang] Add support for [[msvc::noinline]] attribute.
 (#90941)

---
 clang/include/clang/Basic/Attr.td   | 5 -
 clang/include/clang/Basic/AttrDocs.td   | 2 ++
 clang/test/CodeGen/attr-ms-noinline.cpp | 0
 clang/test/Sema/attr-ms-noinline.cpp| 0
 4 files changed, 6 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/CodeGen/attr-ms-noinline.cpp
 create mode 100644 clang/test/Sema/attr-ms-noinline.cpp

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 7a7721239a28f..8532e5c47fe47 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -1997,9 +1997,12 @@ def Convergent : InheritableAttr {
 def NoInline : DeclOrStmtAttr {
   let Spellings = [CustomKeyword<"__noinline__">, GCC<"noinline">,
CXX11<"clang", "noinline">, C23<"clang", "noinline">,
+   CXX11<"msvc", "noinline">, C23<"msvc", "noinline">,
Declspec<"noinline">];
   let Accessors = [Accessor<"isClangNoInline", [CXX11<"clang", "noinline">,
-C23<"clang", "noinline">]>];
+C23<"clang", "noinline">,
+CXX11<"msvc", "noinline">,
+C23<"msvc", "noinline">]>];
   let Documentation = [NoInlineDocs];
   let Subjects = SubjectList<[Function, Stmt], WarnDiag,
  "functions and statements">;
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index b48aaf65558ac..7442f7e828462 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -597,6 +597,8 @@ spellings of the attribute are not supported on statements. 
If a statement is
 marked ``[[clang::noinline]]`` and contains calls, those calls inside the
 statement will not be inlined by the compiler.
 
+``[[msvc::noinline]]`` 
+
 ``__noinline__`` can be used as a keyword in CUDA/HIP languages. This is to
 avoid diagnostics due to usage of ``__attribute__((__noinline__))``
 with ``__noinline__`` defined as a macro as ``__attribute__((noinline))``.
diff --git a/clang/test/CodeGen/attr-ms-noinline.cpp 
b/clang/test/CodeGen/attr-ms-noinline.cpp
new file mode 100644
index 0..e69de29bb2d1d
diff --git a/clang/test/Sema/attr-ms-noinline.cpp 
b/clang/test/Sema/attr-ms-noinline.cpp
new file mode 100644
index 0..e69de29bb2d1d

>From bbc27cb48f616a98d4d379b8ac72e0c408c8ca64 Mon Sep 17 00:00:00 2001
From: Xu Zhang 
Date: Fri, 10 May 2024 17:46:40 +0800
Subject: [PATCH 2/5] add unit test

---
 clang/include/clang/Basic/AttrDocs.td   |  2 -
 clang/test/CodeGen/attr-ms-noinline.cpp | 53 
 clang/test/Sema/attr-ms-noinline.cpp| 66 +
 3 files changed, 119 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 7442f7e828462..b48aaf65558ac 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -597,8 +597,6 @@ spellings of the attribute are not supported on statements. 
If a statement is
 marked ``[[clang::noinline]]`` and contains calls, those calls inside the
 statement will not be inlined by the compiler.
 
-``[[msvc::noinline]]`` 
-
 ``__noinline__`` can be used as a keyword in CUDA/HIP languages. This is to
 avoid diagnostics due to usage of ``__attribute__((__noinline__))``
 with ``__noinline__`` defined as a macro as ``__attribute__((noinline))``.
diff --git a/clang/test/CodeGen/attr-ms-noinline.cpp 
b/clang/test/CodeGen/attr-ms-noinline.cpp
index e69de29bb2d1d..99b0a05af715d 100644
--- a/clang/test/CodeGen/attr-ms-noinline.cpp
+++ b/clang/test/CodeGen/attr-ms-noinline.cpp
@@ -0,0 +1,53 @@
+// RUN: %clang_cc1 -emit-llvm %s -triple x86_64-unknown-linux-gnu -o - | 
FileCheck %s
+
+bool bar();
+void f(bool, bool);
+void g(bool);
+
+static int baz(int x) {
+return x * 10;
+}
+
+[[msvc::noinline]] bool noi() { }
+
+void foo(int i) {
+  [[msvc::noinline]] bar();
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR:[0-9]+]]
+  [[msvc::noinline]] i = baz(i);
+// CHECK: call noundef i32 @_ZL3bazi({{.*}}) #[[NOINLINEATTR]]
+  [[msvc::noinline]] (i = 4, bar());
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
+  [[msvc::noinline]] (void)(bar());
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
+  [[msvc::noinline]] f(bar(), bar());
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
+// CHECK: call noundef zeroext i1 @_Z3barv() #[[NOINLINEATTR]]
+// CHECK: call void @_Z1fbb({{.*}}) #[[NOINLINEATTR]]
+  [[msvc::noinline]] [] { bar(); b

[clang] [Clang] Add support for [[msvc::noinline]] attribute. (PR #91720)

2024-05-21 Thread Xu Zhang via cfe-commits

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


[clang] [Clang] Add support for [[msvc::noinline]] attribute. (PR #91720)

2024-05-21 Thread Xu Zhang via cfe-commits

simonzgx wrote:

> You seem to have lost the tests in the latest version of this commit.

Have already added.

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


[clang] [Clang] Add support for [[msvc::noinline]] attribute. (PR #91720)

2024-05-26 Thread Xu Zhang via cfe-commits

simonzgx wrote:

Hi @erichkeane , can this patch be merged? Or if there is anything else I need 
to do, please let me know.

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