[clang] [Clang][Driver] Warn about `-c/-S` with `-fsyntax-only` (PR #98607)

2024-07-22 Thread Dmitry Chestnykh via cfe-commits

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


[clang] [NFC][Clang] Remove unused arg (PR #101650)

2024-08-02 Thread Dmitry Chestnykh via cfe-commits

https://github.com/chestnykh created 
https://github.com/llvm/llvm-project/pull/101650

`BuiltinID` is not used inside `CheckBuiltinTargetInSupported`

>From 0f724e3aacde40f5d3d06c3e1082667dec36656b Mon Sep 17 00:00:00 2001
From: Dmitry Chestnykh 
Date: Fri, 2 Aug 2024 13:44:00 +0300
Subject: [PATCH] [NFC][Clang] Remove unused arg

BuiltinID is not used inside `CheckBuiltinTargetInSupported`
---
 clang/lib/Sema/SemaChecking.cpp | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index bb30b1e289a1c..eb816816d2d07 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -1862,7 +1862,7 @@ static bool CheckBuiltinTargetNotInUnsupported(
 // Emit an error and return true if the current architecture is not in the list
 // of supported architectures.
 static bool
-CheckBuiltinTargetInSupported(Sema &S, unsigned BuiltinID, CallExpr *TheCall,
+CheckBuiltinTargetInSupported(Sema &S, CallExpr *TheCall,
   ArrayRef SupportedArchs) 
{
   llvm::Triple::ArchType CurArch =
   S.getASTContext().getTargetInfo().getTriple().getArch();
@@ -2095,6 +2095,7 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, 
unsigned BuiltinID,
   }
 
   FPOptions FPO;
+
   switch (BuiltinID) {
   case Builtin::BI__builtin_cpu_supports:
   case Builtin::BI__builtin_cpu_is:
@@ -2151,7 +2152,7 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, 
unsigned BuiltinID,
   case Builtin::BI_interlockedbittestandreset_rel:
   case Builtin::BI_interlockedbittestandreset_nf:
 if (CheckBuiltinTargetInSupported(
-*this, BuiltinID, TheCall,
+*this, TheCall,
 {llvm::Triple::arm, llvm::Triple::thumb, llvm::Triple::aarch64}))
   return ExprError();
 break;
@@ -2164,7 +2165,7 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, 
unsigned BuiltinID,
   case Builtin::BI_interlockedbittestandreset64:
   case Builtin::BI_interlockedbittestandset64:
 if (CheckBuiltinTargetInSupported(
-*this, BuiltinID, TheCall,
+*this, TheCall,
 {llvm::Triple::x86_64, llvm::Triple::arm, llvm::Triple::thumb,
  llvm::Triple::aarch64, llvm::Triple::amdgcn}))
   return ExprError();
@@ -2172,7 +2173,7 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, 
unsigned BuiltinID,
 
   case Builtin::BI__builtin_set_flt_rounds:
 if (CheckBuiltinTargetInSupported(
-*this, BuiltinID, TheCall,
+*this, TheCall,
 {llvm::Triple::x86, llvm::Triple::x86_64, llvm::Triple::arm,
  llvm::Triple::thumb, llvm::Triple::aarch64, 
llvm::Triple::amdgcn}))
   return ExprError();

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


[clang] [NFC][Clang] Remove unused arg (PR #101650)

2024-08-02 Thread Dmitry Chestnykh via cfe-commits

https://github.com/chestnykh updated 
https://github.com/llvm/llvm-project/pull/101650

>From 0f724e3aacde40f5d3d06c3e1082667dec36656b Mon Sep 17 00:00:00 2001
From: Dmitry Chestnykh 
Date: Fri, 2 Aug 2024 13:44:00 +0300
Subject: [PATCH 1/2] [NFC][Clang] Remove unused arg

BuiltinID is not used inside `CheckBuiltinTargetInSupported`
---
 clang/lib/Sema/SemaChecking.cpp | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index bb30b1e289a1c..eb816816d2d07 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -1862,7 +1862,7 @@ static bool CheckBuiltinTargetNotInUnsupported(
 // Emit an error and return true if the current architecture is not in the list
 // of supported architectures.
 static bool
-CheckBuiltinTargetInSupported(Sema &S, unsigned BuiltinID, CallExpr *TheCall,
+CheckBuiltinTargetInSupported(Sema &S, CallExpr *TheCall,
   ArrayRef SupportedArchs) 
{
   llvm::Triple::ArchType CurArch =
   S.getASTContext().getTargetInfo().getTriple().getArch();
@@ -2095,6 +2095,7 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, 
unsigned BuiltinID,
   }
 
   FPOptions FPO;
+
   switch (BuiltinID) {
   case Builtin::BI__builtin_cpu_supports:
   case Builtin::BI__builtin_cpu_is:
@@ -2151,7 +2152,7 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, 
unsigned BuiltinID,
   case Builtin::BI_interlockedbittestandreset_rel:
   case Builtin::BI_interlockedbittestandreset_nf:
 if (CheckBuiltinTargetInSupported(
-*this, BuiltinID, TheCall,
+*this, TheCall,
 {llvm::Triple::arm, llvm::Triple::thumb, llvm::Triple::aarch64}))
   return ExprError();
 break;
@@ -2164,7 +2165,7 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, 
unsigned BuiltinID,
   case Builtin::BI_interlockedbittestandreset64:
   case Builtin::BI_interlockedbittestandset64:
 if (CheckBuiltinTargetInSupported(
-*this, BuiltinID, TheCall,
+*this, TheCall,
 {llvm::Triple::x86_64, llvm::Triple::arm, llvm::Triple::thumb,
  llvm::Triple::aarch64, llvm::Triple::amdgcn}))
   return ExprError();
@@ -2172,7 +2173,7 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, 
unsigned BuiltinID,
 
   case Builtin::BI__builtin_set_flt_rounds:
 if (CheckBuiltinTargetInSupported(
-*this, BuiltinID, TheCall,
+*this, TheCall,
 {llvm::Triple::x86, llvm::Triple::x86_64, llvm::Triple::arm,
  llvm::Triple::thumb, llvm::Triple::aarch64, 
llvm::Triple::amdgcn}))
   return ExprError();

>From 00158bc570838cff376af2794fb7fff07a4f31f6 Mon Sep 17 00:00:00 2001
From: Dmitry Chestnykh 
Date: Fri, 2 Aug 2024 13:47:24 +0300
Subject: [PATCH 2/2] [clang] Remove unneeded newline

---
 clang/lib/Sema/SemaChecking.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index eb816816d2d07..ed0eea9763b2a 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -2095,7 +2095,6 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, 
unsigned BuiltinID,
   }
 
   FPOptions FPO;
-
   switch (BuiltinID) {
   case Builtin::BI__builtin_cpu_supports:
   case Builtin::BI__builtin_cpu_is:

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


[clang] [NFC][Clang] Remove unused arg (PR #101650)

2024-08-02 Thread Dmitry Chestnykh via cfe-commits

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


[clang] [Clang] Adjust `exit()` builtin impl (PR #101689)

2024-08-02 Thread Dmitry Chestnykh via cfe-commits

https://github.com/chestnykh created 
https://github.com/llvm/llvm-project/pull/101689

- `_Exit` is an alias to `_exit` and `_exit` is declared in unistd.h header, so 
don't mix
`_Exit` and `exit`. Only `exit` decl placed in stdlib.h.
- Add `__builtin_` variants for exit functions like GC does

>From b83615c58c85f5723dff26e40f356473fb5d4eda Mon Sep 17 00:00:00 2001
From: Dmitry Chestnykh 
Date: Fri, 2 Aug 2024 18:28:38 +0300
Subject: [PATCH] [Clang] Adjust `exit()` builtin impl

- `_Exit` is an alias to `_exit` and `_exit`
is declared in unistd.h header, so don't mix
`_Exit` and `exit`. Only `exit` decl placed in stdlib.h.
- Add `__builtin_` variants for exit functions like GC does
---
 clang/include/clang/Basic/Builtins.td |  6 --
 clang/test/CodeGen/attributes.c   | 21 +
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index ccddeb9396284..bd0632c573412 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -2660,9 +2660,10 @@ def Calloc : LibBuiltin<"stdlib.h"> {
 }
 
 def Exit : LibBuiltin<"stdlib.h"> {
-  let Spellings = ["exit", "_Exit"];
+  let Spellings = ["exit"];
   let Attributes = [NoReturn];
   let Prototype = "void(int)";
+  let AddBuiltinPrefixedAlias = 1;
 }
 
 def Malloc : LibBuiltin<"stdlib.h"> {
@@ -3266,9 +3267,10 @@ def StrnCaseCmp : GNULibBuiltin<"strings.h"> {
 }
 
 def GNU_Exit : GNULibBuiltin<"unistd.h"> {
-  let Spellings = ["_exit"];
+  let Spellings = ["_exit", "_Exit"];
   let Attributes = [NoReturn];
   let Prototype = "void(int)";
+  let AddBuiltinPrefixedAlias = 1;
 }
 
 def VFork : LibBuiltin<"unistd.h"> {
diff --git a/clang/test/CodeGen/attributes.c b/clang/test/CodeGen/attributes.c
index 5afef72b747af..9fa43edbcf7c6 100644
--- a/clang/test/CodeGen/attributes.c
+++ b/clang/test/CodeGen/attributes.c
@@ -113,6 +113,27 @@ void t24(f_t f1) {
   (*p)();
 }
 
+// CHECK:define{{.*}} void @t25() [[NUW]] {
+// CHECK: call void @exit(i32 noundef 1)
+// CHECK-NEXT: unreachable
+void t25(void) {
+  __builtin_exit(1);
+}
+
+// CHECK:define{{.*}} void @t26() [[NUW]] {
+// CHECK: call void @_exit(i32 noundef 2)
+// CHECK-NEXT: unreachable
+void t26(void) {
+  __builtin__exit(2);
+}
+
+// CHECK:define{{.*}} void @t27() [[NUW]] {
+// CHECK: call void @_Exit(i32 noundef 3)
+// CHECK-NEXT: unreachable
+void t27(void) {
+  __builtin__Exit(3);
+}
+
 // CHECK: attributes [[NUW]] = { noinline nounwind{{.*}} }
 // CHECK: attributes [[NR]] = { noinline noreturn nounwind{{.*}} }
 // CHECK: attributes [[COLDDEF]] = { cold {{.*}}}

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


[clang] [Clang] Adjust `exit()` builtin impl (PR #101689)

2024-08-02 Thread Dmitry Chestnykh via cfe-commits

https://github.com/chestnykh updated 
https://github.com/llvm/llvm-project/pull/101689

>From ee010a25b0df1371647285af8faaffe694a02d28 Mon Sep 17 00:00:00 2001
From: Dmitry Chestnykh 
Date: Fri, 2 Aug 2024 18:28:38 +0300
Subject: [PATCH] [Clang] Adjust `exit()` builtin impl

- `_Exit` is an alias to `_exit` and `_exit`
is declared in unistd.h header, so don't mix
`_Exit` and `exit`. Only `exit` decl placed in stdlib.h.
- Add `__builtin_` variants for exit functions like GCC does
---
 clang/include/clang/Basic/Builtins.td |  6 --
 clang/test/CodeGen/attributes.c   | 21 +
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index ccddeb9396284..bd0632c573412 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -2660,9 +2660,10 @@ def Calloc : LibBuiltin<"stdlib.h"> {
 }
 
 def Exit : LibBuiltin<"stdlib.h"> {
-  let Spellings = ["exit", "_Exit"];
+  let Spellings = ["exit"];
   let Attributes = [NoReturn];
   let Prototype = "void(int)";
+  let AddBuiltinPrefixedAlias = 1;
 }
 
 def Malloc : LibBuiltin<"stdlib.h"> {
@@ -3266,9 +3267,10 @@ def StrnCaseCmp : GNULibBuiltin<"strings.h"> {
 }
 
 def GNU_Exit : GNULibBuiltin<"unistd.h"> {
-  let Spellings = ["_exit"];
+  let Spellings = ["_exit", "_Exit"];
   let Attributes = [NoReturn];
   let Prototype = "void(int)";
+  let AddBuiltinPrefixedAlias = 1;
 }
 
 def VFork : LibBuiltin<"unistd.h"> {
diff --git a/clang/test/CodeGen/attributes.c b/clang/test/CodeGen/attributes.c
index 5afef72b747af..9fa43edbcf7c6 100644
--- a/clang/test/CodeGen/attributes.c
+++ b/clang/test/CodeGen/attributes.c
@@ -113,6 +113,27 @@ void t24(f_t f1) {
   (*p)();
 }
 
+// CHECK:define{{.*}} void @t25() [[NUW]] {
+// CHECK: call void @exit(i32 noundef 1)
+// CHECK-NEXT: unreachable
+void t25(void) {
+  __builtin_exit(1);
+}
+
+// CHECK:define{{.*}} void @t26() [[NUW]] {
+// CHECK: call void @_exit(i32 noundef 2)
+// CHECK-NEXT: unreachable
+void t26(void) {
+  __builtin__exit(2);
+}
+
+// CHECK:define{{.*}} void @t27() [[NUW]] {
+// CHECK: call void @_Exit(i32 noundef 3)
+// CHECK-NEXT: unreachable
+void t27(void) {
+  __builtin__Exit(3);
+}
+
 // CHECK: attributes [[NUW]] = { noinline nounwind{{.*}} }
 // CHECK: attributes [[NR]] = { noinline noreturn nounwind{{.*}} }
 // CHECK: attributes [[COLDDEF]] = { cold {{.*}}}

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


[clang] [Clang] Adjust `exit()` builtin impl (PR #101689)

2024-08-02 Thread Dmitry Chestnykh via cfe-commits

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


[clang] [Clang] Adjust `exit()` builtin impl (PR #101689)

2024-08-03 Thread Dmitry Chestnykh via cfe-commits

chestnykh wrote:

> In #74803, the question of "why" came up and was never answered.

Okay, i can remove `let AddBuiltinPrefixedAlias = 1;`, but IMO that the rest of 
changes makes sense. What do you think? 

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


[libunwind] [Libunwind] Don't XFAIL tests with msan (PR #120013)

2024-12-16 Thread Dmitry Chestnykh via cfe-commits

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


[libunwind] [Libunwind] Try to fix msan failures (PR #120013)

2024-12-16 Thread Dmitry Chestnykh via cfe-commits

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


[libunwind] [Libunwind] Don't XFAIL tests with msan (PR #120013)

2024-12-15 Thread Dmitry Chestnykh via cfe-commits

https://github.com/chestnykh created 
https://github.com/llvm/llvm-project/pull/120013

None

>From 95d35c8d4f95d2a08845d8951eb0ea7e0d97ec97 Mon Sep 17 00:00:00 2001
From: Dmitry Chestnykh 
Date: Sun, 15 Dec 2024 21:18:23 +0300
Subject: [PATCH] [Libunwind] Don't XFAIL tests with msan

---
 libunwind/test/forceunwind.pass.cpp | 3 ---
 libunwind/test/libunwind_01.pass.cpp| 3 ---
 libunwind/test/libunwind_02.pass.cpp| 3 ---
 libunwind/test/signal_frame.pass.cpp| 3 ---
 libunwind/test/signal_unwind.pass.cpp   | 3 ---
 libunwind/test/unw_resume.pass.cpp  | 3 ---
 libunwind/test/unwind_leaffunction.pass.cpp | 3 ---
 7 files changed, 21 deletions(-)

diff --git a/libunwind/test/forceunwind.pass.cpp 
b/libunwind/test/forceunwind.pass.cpp
index 344034e1ea5f5e..e8333eb74a979a 100644
--- a/libunwind/test/forceunwind.pass.cpp
+++ b/libunwind/test/forceunwind.pass.cpp
@@ -9,9 +9,6 @@
 
 // REQUIRES: linux
 
-// TODO: Figure out why this fails with Memory Sanitizer.
-// XFAIL: msan
-
 // Basic test for _Unwind_ForcedUnwind.
 // See libcxxabi/test/forced_unwind* tests too.
 
diff --git a/libunwind/test/libunwind_01.pass.cpp 
b/libunwind/test/libunwind_01.pass.cpp
index 838df6b5897204..82fb66d665c259 100644
--- a/libunwind/test/libunwind_01.pass.cpp
+++ b/libunwind/test/libunwind_01.pass.cpp
@@ -10,9 +10,6 @@
 // TODO: Investigate this failure on x86_64 macOS back deployment
 // XFAIL: stdlib=system && 
target=x86_64-apple-macosx{{10.9|10.10|10.11|10.12|10.13|10.14|10.15|11.0|12.0}}
 
-// TODO: Figure out why this fails with Memory Sanitizer.
-// XFAIL: msan
-
 #include 
 #include 
 #include 
diff --git a/libunwind/test/libunwind_02.pass.cpp 
b/libunwind/test/libunwind_02.pass.cpp
index 9fd8e5d7159c96..5f2d2b43bddc1c 100644
--- a/libunwind/test/libunwind_02.pass.cpp
+++ b/libunwind/test/libunwind_02.pass.cpp
@@ -7,9 +7,6 @@
 //
 
//===--===//
 
-// TODO: Figure out why this fails with Memory Sanitizer.
-// XFAIL: msan
-
 // This test fails on older llvm, when built with picolibc.
 // XFAIL: clang-16 && LIBCXX-PICOLIBC-FIXME
 
diff --git a/libunwind/test/signal_frame.pass.cpp 
b/libunwind/test/signal_frame.pass.cpp
index 004029cfe1e90b..67b862c98fbfc7 100644
--- a/libunwind/test/signal_frame.pass.cpp
+++ b/libunwind/test/signal_frame.pass.cpp
@@ -12,9 +12,6 @@
 // TODO: Investigate this failure on Apple
 // XFAIL: target={{.+}}-apple-{{.+}}
 
-// TODO: Figure out why this fails with Memory Sanitizer.
-// XFAIL: msan
-
 // UNSUPPORTED: libunwind-arm-ehabi
 
 // The AIX assembler does not support CFI directives, which
diff --git a/libunwind/test/signal_unwind.pass.cpp 
b/libunwind/test/signal_unwind.pass.cpp
index 1c1566415a4d4b..8ba0c8b2859ac4 100644
--- a/libunwind/test/signal_unwind.pass.cpp
+++ b/libunwind/test/signal_unwind.pass.cpp
@@ -10,9 +10,6 @@
 // Ensure that the unwinder can cope with the signal handler.
 // REQUIRES: target={{(aarch64|riscv64|s390x|x86_64)-.+linux.*}}
 
-// TODO: Figure out why this fails with Memory Sanitizer.
-// XFAIL: msan
-
 // Note: this test fails on musl because:
 //
 //  (a) musl disables emission of unwind information for its build, and
diff --git a/libunwind/test/unw_resume.pass.cpp 
b/libunwind/test/unw_resume.pass.cpp
index 2b7470b5cad0eb..ca6068a828e0ac 100644
--- a/libunwind/test/unw_resume.pass.cpp
+++ b/libunwind/test/unw_resume.pass.cpp
@@ -10,9 +10,6 @@
 // Ensure that unw_resume() resumes execution at the stack frame identified by
 // cursor.
 
-// TODO: Figure out why this fails with Memory Sanitizer.
-// XFAIL: msan
-
 #include 
 
 __attribute__((noinline)) void test_unw_resume() {
diff --git a/libunwind/test/unwind_leaffunction.pass.cpp 
b/libunwind/test/unwind_leaffunction.pass.cpp
index 98de7dc43260c2..4259406cc493d1 100644
--- a/libunwind/test/unwind_leaffunction.pass.cpp
+++ b/libunwind/test/unwind_leaffunction.pass.cpp
@@ -10,9 +10,6 @@
 // Ensure that leaf function can be unwund.
 // REQUIRES: target={{(aarch64|riscv64|s390x|x86_64)-.+linux.*}}
 
-// TODO: Figure out why this fails with Memory Sanitizer.
-// XFAIL: msan
-
 // Note: this test fails on musl because:
 //
 //  (a) musl disables emission of unwind information for its build, and

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


[libunwind] [Libunwind] Don't XFAIL tests with msan (PR #120013)

2024-12-15 Thread Dmitry Chestnykh via cfe-commits

chestnykh wrote:

@ldionne i run these tests locally with msan (x86-64) and have no errors. Could 
you please tell on what architecture(s) the tests was failing?  

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


[libunwind] [Libunwind] Don't XFAIL tests with msan (PR #120013)

2024-12-16 Thread Dmitry Chestnykh via cfe-commits

https://github.com/chestnykh updated 
https://github.com/llvm/llvm-project/pull/120013

>From 9422b097ff80f5501dcf4fa3d41176b9439ab3f6 Mon Sep 17 00:00:00 2001
From: Dmitry Chestnykh 
Date: Sun, 15 Dec 2024 21:18:23 +0300
Subject: [PATCH] [Libunwind] Don't XFAIL tests with msan

---
 libunwind/test/forceunwind.pass.cpp | 3 ---
 libunwind/test/libunwind_01.pass.cpp| 3 ---
 libunwind/test/libunwind_02.pass.cpp| 3 ---
 libunwind/test/signal_frame.pass.cpp| 3 ---
 libunwind/test/signal_unwind.pass.cpp   | 3 ---
 libunwind/test/unw_resume.pass.cpp  | 3 ---
 libunwind/test/unwind_leaffunction.pass.cpp | 3 ---
 7 files changed, 21 deletions(-)

diff --git a/libunwind/test/forceunwind.pass.cpp 
b/libunwind/test/forceunwind.pass.cpp
index 344034e1ea5f5e..e8333eb74a979a 100644
--- a/libunwind/test/forceunwind.pass.cpp
+++ b/libunwind/test/forceunwind.pass.cpp
@@ -9,9 +9,6 @@
 
 // REQUIRES: linux
 
-// TODO: Figure out why this fails with Memory Sanitizer.
-// XFAIL: msan
-
 // Basic test for _Unwind_ForcedUnwind.
 // See libcxxabi/test/forced_unwind* tests too.
 
diff --git a/libunwind/test/libunwind_01.pass.cpp 
b/libunwind/test/libunwind_01.pass.cpp
index 838df6b5897204..82fb66d665c259 100644
--- a/libunwind/test/libunwind_01.pass.cpp
+++ b/libunwind/test/libunwind_01.pass.cpp
@@ -10,9 +10,6 @@
 // TODO: Investigate this failure on x86_64 macOS back deployment
 // XFAIL: stdlib=system && 
target=x86_64-apple-macosx{{10.9|10.10|10.11|10.12|10.13|10.14|10.15|11.0|12.0}}
 
-// TODO: Figure out why this fails with Memory Sanitizer.
-// XFAIL: msan
-
 #include 
 #include 
 #include 
diff --git a/libunwind/test/libunwind_02.pass.cpp 
b/libunwind/test/libunwind_02.pass.cpp
index 9fd8e5d7159c96..5f2d2b43bddc1c 100644
--- a/libunwind/test/libunwind_02.pass.cpp
+++ b/libunwind/test/libunwind_02.pass.cpp
@@ -7,9 +7,6 @@
 //
 
//===--===//
 
-// TODO: Figure out why this fails with Memory Sanitizer.
-// XFAIL: msan
-
 // This test fails on older llvm, when built with picolibc.
 // XFAIL: clang-16 && LIBCXX-PICOLIBC-FIXME
 
diff --git a/libunwind/test/signal_frame.pass.cpp 
b/libunwind/test/signal_frame.pass.cpp
index 004029cfe1e90b..67b862c98fbfc7 100644
--- a/libunwind/test/signal_frame.pass.cpp
+++ b/libunwind/test/signal_frame.pass.cpp
@@ -12,9 +12,6 @@
 // TODO: Investigate this failure on Apple
 // XFAIL: target={{.+}}-apple-{{.+}}
 
-// TODO: Figure out why this fails with Memory Sanitizer.
-// XFAIL: msan
-
 // UNSUPPORTED: libunwind-arm-ehabi
 
 // The AIX assembler does not support CFI directives, which
diff --git a/libunwind/test/signal_unwind.pass.cpp 
b/libunwind/test/signal_unwind.pass.cpp
index 1c1566415a4d4b..8ba0c8b2859ac4 100644
--- a/libunwind/test/signal_unwind.pass.cpp
+++ b/libunwind/test/signal_unwind.pass.cpp
@@ -10,9 +10,6 @@
 // Ensure that the unwinder can cope with the signal handler.
 // REQUIRES: target={{(aarch64|riscv64|s390x|x86_64)-.+linux.*}}
 
-// TODO: Figure out why this fails with Memory Sanitizer.
-// XFAIL: msan
-
 // Note: this test fails on musl because:
 //
 //  (a) musl disables emission of unwind information for its build, and
diff --git a/libunwind/test/unw_resume.pass.cpp 
b/libunwind/test/unw_resume.pass.cpp
index 2b7470b5cad0eb..ca6068a828e0ac 100644
--- a/libunwind/test/unw_resume.pass.cpp
+++ b/libunwind/test/unw_resume.pass.cpp
@@ -10,9 +10,6 @@
 // Ensure that unw_resume() resumes execution at the stack frame identified by
 // cursor.
 
-// TODO: Figure out why this fails with Memory Sanitizer.
-// XFAIL: msan
-
 #include 
 
 __attribute__((noinline)) void test_unw_resume() {
diff --git a/libunwind/test/unwind_leaffunction.pass.cpp 
b/libunwind/test/unwind_leaffunction.pass.cpp
index 98de7dc43260c2..4259406cc493d1 100644
--- a/libunwind/test/unwind_leaffunction.pass.cpp
+++ b/libunwind/test/unwind_leaffunction.pass.cpp
@@ -10,9 +10,6 @@
 // Ensure that leaf function can be unwund.
 // REQUIRES: target={{(aarch64|riscv64|s390x|x86_64)-.+linux.*}}
 
-// TODO: Figure out why this fails with Memory Sanitizer.
-// XFAIL: msan
-
 // Note: this test fails on musl because:
 //
 //  (a) musl disables emission of unwind information for its build, and

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


[libunwind] [Libunwind] Don't XFAIL tests with msan (PR #120013)

2024-12-16 Thread Dmitry Chestnykh via cfe-commits

chestnykh wrote:

All CI failures look unrelated

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


[libunwind] [Libunwind] Try to fix msan failures (PR #120013)

2024-12-16 Thread Dmitry Chestnykh via cfe-commits

chestnykh wrote:

Maybe load order breaks something:
With `-lunwind` passed explicitly:
```
linux-vdso.so.1 (0x700799647000)
libunwind.so.1 => /usr/lib/libunwind.so.1 (0x7007995fe000)
libatomic.so.1 => /usr/lib/libatomic.so.1 (0x7007995f3000)
libc++.so.1 => /usr/lib/libc++.so.1 (0x7007994ec000)
libc++abi.so.1 => /usr/lib/libc++abi.so.1 (0x7007949c)
libm.so.6 => /usr/lib/libm.so.6 (0x7007948d1000)
libresolv.so.2 => /usr/lib/libresolv.so.2 (0x7007948bf000)
libc.so.6 => /usr/lib/libc.so.6 (0x7007946ce000)
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x7007946a)
/lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 
(0x700799649000)
```

With only `-rtlib=compiler-rt -unwindlib=libunwind` (without explicit 
`-lunwind` in the driver cmdline)
```
linux-vdso.so.1 (0x77ed1ce4a000)
libunwind.so.1 => /usr/lib/libunwind.so.1 (0x77ed1ce01000)
libatomic.so.1 => /usr/lib/libatomic.so.1 (0x77ed1cdf6000)
libc++.so.1 => /usr/lib/libc++.so.1 (0x77ed1ccef000)
libc++abi.so.1 => /usr/lib/libc++abi.so.1 (0x77ed181c)
libm.so.6 => /usr/lib/libm.so.6 (0x77ed180d1000)
libresolv.so.2 => /usr/lib/libresolv.so.2 (0x77ed180bf000)
libc.so.6 => /usr/lib/libc.so.6 (0x77ed17ece000)
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x77ed17ea)
/lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 
(0x77ed1ce4c000)
```

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


[libunwind] [Libunwind] Try to fix msan failures (PR #120013)

2024-12-16 Thread Dmitry Chestnykh via cfe-commits

https://github.com/chestnykh updated 
https://github.com/llvm/llvm-project/pull/120013

>From 9422b097ff80f5501dcf4fa3d41176b9439ab3f6 Mon Sep 17 00:00:00 2001
From: Dmitry Chestnykh 
Date: Sun, 15 Dec 2024 21:18:23 +0300
Subject: [PATCH 1/2] [Libunwind] Don't XFAIL tests with msan

---
 libunwind/test/forceunwind.pass.cpp | 3 ---
 libunwind/test/libunwind_01.pass.cpp| 3 ---
 libunwind/test/libunwind_02.pass.cpp| 3 ---
 libunwind/test/signal_frame.pass.cpp| 3 ---
 libunwind/test/signal_unwind.pass.cpp   | 3 ---
 libunwind/test/unw_resume.pass.cpp  | 3 ---
 libunwind/test/unwind_leaffunction.pass.cpp | 3 ---
 7 files changed, 21 deletions(-)

diff --git a/libunwind/test/forceunwind.pass.cpp 
b/libunwind/test/forceunwind.pass.cpp
index 344034e1ea5f5e..e8333eb74a979a 100644
--- a/libunwind/test/forceunwind.pass.cpp
+++ b/libunwind/test/forceunwind.pass.cpp
@@ -9,9 +9,6 @@
 
 // REQUIRES: linux
 
-// TODO: Figure out why this fails with Memory Sanitizer.
-// XFAIL: msan
-
 // Basic test for _Unwind_ForcedUnwind.
 // See libcxxabi/test/forced_unwind* tests too.
 
diff --git a/libunwind/test/libunwind_01.pass.cpp 
b/libunwind/test/libunwind_01.pass.cpp
index 838df6b5897204..82fb66d665c259 100644
--- a/libunwind/test/libunwind_01.pass.cpp
+++ b/libunwind/test/libunwind_01.pass.cpp
@@ -10,9 +10,6 @@
 // TODO: Investigate this failure on x86_64 macOS back deployment
 // XFAIL: stdlib=system && 
target=x86_64-apple-macosx{{10.9|10.10|10.11|10.12|10.13|10.14|10.15|11.0|12.0}}
 
-// TODO: Figure out why this fails with Memory Sanitizer.
-// XFAIL: msan
-
 #include 
 #include 
 #include 
diff --git a/libunwind/test/libunwind_02.pass.cpp 
b/libunwind/test/libunwind_02.pass.cpp
index 9fd8e5d7159c96..5f2d2b43bddc1c 100644
--- a/libunwind/test/libunwind_02.pass.cpp
+++ b/libunwind/test/libunwind_02.pass.cpp
@@ -7,9 +7,6 @@
 //
 
//===--===//
 
-// TODO: Figure out why this fails with Memory Sanitizer.
-// XFAIL: msan
-
 // This test fails on older llvm, when built with picolibc.
 // XFAIL: clang-16 && LIBCXX-PICOLIBC-FIXME
 
diff --git a/libunwind/test/signal_frame.pass.cpp 
b/libunwind/test/signal_frame.pass.cpp
index 004029cfe1e90b..67b862c98fbfc7 100644
--- a/libunwind/test/signal_frame.pass.cpp
+++ b/libunwind/test/signal_frame.pass.cpp
@@ -12,9 +12,6 @@
 // TODO: Investigate this failure on Apple
 // XFAIL: target={{.+}}-apple-{{.+}}
 
-// TODO: Figure out why this fails with Memory Sanitizer.
-// XFAIL: msan
-
 // UNSUPPORTED: libunwind-arm-ehabi
 
 // The AIX assembler does not support CFI directives, which
diff --git a/libunwind/test/signal_unwind.pass.cpp 
b/libunwind/test/signal_unwind.pass.cpp
index 1c1566415a4d4b..8ba0c8b2859ac4 100644
--- a/libunwind/test/signal_unwind.pass.cpp
+++ b/libunwind/test/signal_unwind.pass.cpp
@@ -10,9 +10,6 @@
 // Ensure that the unwinder can cope with the signal handler.
 // REQUIRES: target={{(aarch64|riscv64|s390x|x86_64)-.+linux.*}}
 
-// TODO: Figure out why this fails with Memory Sanitizer.
-// XFAIL: msan
-
 // Note: this test fails on musl because:
 //
 //  (a) musl disables emission of unwind information for its build, and
diff --git a/libunwind/test/unw_resume.pass.cpp 
b/libunwind/test/unw_resume.pass.cpp
index 2b7470b5cad0eb..ca6068a828e0ac 100644
--- a/libunwind/test/unw_resume.pass.cpp
+++ b/libunwind/test/unw_resume.pass.cpp
@@ -10,9 +10,6 @@
 // Ensure that unw_resume() resumes execution at the stack frame identified by
 // cursor.
 
-// TODO: Figure out why this fails with Memory Sanitizer.
-// XFAIL: msan
-
 #include 
 
 __attribute__((noinline)) void test_unw_resume() {
diff --git a/libunwind/test/unwind_leaffunction.pass.cpp 
b/libunwind/test/unwind_leaffunction.pass.cpp
index 98de7dc43260c2..4259406cc493d1 100644
--- a/libunwind/test/unwind_leaffunction.pass.cpp
+++ b/libunwind/test/unwind_leaffunction.pass.cpp
@@ -10,9 +10,6 @@
 // Ensure that leaf function can be unwund.
 // REQUIRES: target={{(aarch64|riscv64|s390x|x86_64)-.+linux.*}}
 
-// TODO: Figure out why this fails with Memory Sanitizer.
-// XFAIL: msan
-
 // Note: this test fails on musl because:
 //
 //  (a) musl disables emission of unwind information for its build, and

>From 0a4a0e12d7b4daf72dd4461962fbf6cc5114347f Mon Sep 17 00:00:00 2001
From: Dmitry Chestnykh 
Date: Mon, 16 Dec 2024 21:40:46 +0300
Subject: [PATCH 2/2] Try to remove -lunwind from link flags

The possible reason why tests fail is that
MAYBE there are another libunwind on the testing host
which is loaded(?) instead of libunwind from llvm.
clang passes 'right' libunwind (-lunwind) to the linker
if -unwindlib=libunwind is passed to the driver
---
 libunwind/test/configs/llvm-libunwind-shared.cfg.in | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libunwind/test/configs/llvm-libunwind-shared.cfg.in 
b/libunwind/test/configs/llvm-libunwind-shared.cfg.in
index f3e40928b525da..256f8111948bd3 100644
--

[libunwind] [Libunwind] Try to fix msan failures (PR #120013)

2024-12-16 Thread Dmitry Chestnykh via cfe-commits

https://github.com/chestnykh updated 
https://github.com/llvm/llvm-project/pull/120013

>From 9422b097ff80f5501dcf4fa3d41176b9439ab3f6 Mon Sep 17 00:00:00 2001
From: Dmitry Chestnykh 
Date: Sun, 15 Dec 2024 21:18:23 +0300
Subject: [PATCH 1/3] [Libunwind] Don't XFAIL tests with msan

---
 libunwind/test/forceunwind.pass.cpp | 3 ---
 libunwind/test/libunwind_01.pass.cpp| 3 ---
 libunwind/test/libunwind_02.pass.cpp| 3 ---
 libunwind/test/signal_frame.pass.cpp| 3 ---
 libunwind/test/signal_unwind.pass.cpp   | 3 ---
 libunwind/test/unw_resume.pass.cpp  | 3 ---
 libunwind/test/unwind_leaffunction.pass.cpp | 3 ---
 7 files changed, 21 deletions(-)

diff --git a/libunwind/test/forceunwind.pass.cpp 
b/libunwind/test/forceunwind.pass.cpp
index 344034e1ea5f5e..e8333eb74a979a 100644
--- a/libunwind/test/forceunwind.pass.cpp
+++ b/libunwind/test/forceunwind.pass.cpp
@@ -9,9 +9,6 @@
 
 // REQUIRES: linux
 
-// TODO: Figure out why this fails with Memory Sanitizer.
-// XFAIL: msan
-
 // Basic test for _Unwind_ForcedUnwind.
 // See libcxxabi/test/forced_unwind* tests too.
 
diff --git a/libunwind/test/libunwind_01.pass.cpp 
b/libunwind/test/libunwind_01.pass.cpp
index 838df6b5897204..82fb66d665c259 100644
--- a/libunwind/test/libunwind_01.pass.cpp
+++ b/libunwind/test/libunwind_01.pass.cpp
@@ -10,9 +10,6 @@
 // TODO: Investigate this failure on x86_64 macOS back deployment
 // XFAIL: stdlib=system && 
target=x86_64-apple-macosx{{10.9|10.10|10.11|10.12|10.13|10.14|10.15|11.0|12.0}}
 
-// TODO: Figure out why this fails with Memory Sanitizer.
-// XFAIL: msan
-
 #include 
 #include 
 #include 
diff --git a/libunwind/test/libunwind_02.pass.cpp 
b/libunwind/test/libunwind_02.pass.cpp
index 9fd8e5d7159c96..5f2d2b43bddc1c 100644
--- a/libunwind/test/libunwind_02.pass.cpp
+++ b/libunwind/test/libunwind_02.pass.cpp
@@ -7,9 +7,6 @@
 //
 
//===--===//
 
-// TODO: Figure out why this fails with Memory Sanitizer.
-// XFAIL: msan
-
 // This test fails on older llvm, when built with picolibc.
 // XFAIL: clang-16 && LIBCXX-PICOLIBC-FIXME
 
diff --git a/libunwind/test/signal_frame.pass.cpp 
b/libunwind/test/signal_frame.pass.cpp
index 004029cfe1e90b..67b862c98fbfc7 100644
--- a/libunwind/test/signal_frame.pass.cpp
+++ b/libunwind/test/signal_frame.pass.cpp
@@ -12,9 +12,6 @@
 // TODO: Investigate this failure on Apple
 // XFAIL: target={{.+}}-apple-{{.+}}
 
-// TODO: Figure out why this fails with Memory Sanitizer.
-// XFAIL: msan
-
 // UNSUPPORTED: libunwind-arm-ehabi
 
 // The AIX assembler does not support CFI directives, which
diff --git a/libunwind/test/signal_unwind.pass.cpp 
b/libunwind/test/signal_unwind.pass.cpp
index 1c1566415a4d4b..8ba0c8b2859ac4 100644
--- a/libunwind/test/signal_unwind.pass.cpp
+++ b/libunwind/test/signal_unwind.pass.cpp
@@ -10,9 +10,6 @@
 // Ensure that the unwinder can cope with the signal handler.
 // REQUIRES: target={{(aarch64|riscv64|s390x|x86_64)-.+linux.*}}
 
-// TODO: Figure out why this fails with Memory Sanitizer.
-// XFAIL: msan
-
 // Note: this test fails on musl because:
 //
 //  (a) musl disables emission of unwind information for its build, and
diff --git a/libunwind/test/unw_resume.pass.cpp 
b/libunwind/test/unw_resume.pass.cpp
index 2b7470b5cad0eb..ca6068a828e0ac 100644
--- a/libunwind/test/unw_resume.pass.cpp
+++ b/libunwind/test/unw_resume.pass.cpp
@@ -10,9 +10,6 @@
 // Ensure that unw_resume() resumes execution at the stack frame identified by
 // cursor.
 
-// TODO: Figure out why this fails with Memory Sanitizer.
-// XFAIL: msan
-
 #include 
 
 __attribute__((noinline)) void test_unw_resume() {
diff --git a/libunwind/test/unwind_leaffunction.pass.cpp 
b/libunwind/test/unwind_leaffunction.pass.cpp
index 98de7dc43260c2..4259406cc493d1 100644
--- a/libunwind/test/unwind_leaffunction.pass.cpp
+++ b/libunwind/test/unwind_leaffunction.pass.cpp
@@ -10,9 +10,6 @@
 // Ensure that leaf function can be unwund.
 // REQUIRES: target={{(aarch64|riscv64|s390x|x86_64)-.+linux.*}}
 
-// TODO: Figure out why this fails with Memory Sanitizer.
-// XFAIL: msan
-
 // Note: this test fails on musl because:
 //
 //  (a) musl disables emission of unwind information for its build, and

>From 0a4a0e12d7b4daf72dd4461962fbf6cc5114347f Mon Sep 17 00:00:00 2001
From: Dmitry Chestnykh 
Date: Mon, 16 Dec 2024 21:40:46 +0300
Subject: [PATCH 2/3] Try to remove -lunwind from link flags

The possible reason why tests fail is that
MAYBE there are another libunwind on the testing host
which is loaded(?) instead of libunwind from llvm.
clang passes 'right' libunwind (-lunwind) to the linker
if -unwindlib=libunwind is passed to the driver
---
 libunwind/test/configs/llvm-libunwind-shared.cfg.in | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libunwind/test/configs/llvm-libunwind-shared.cfg.in 
b/libunwind/test/configs/llvm-libunwind-shared.cfg.in
index f3e40928b525da..256f8111948bd3 100644
--

[libunwind] [Libunwind] Try to fix msan failures (PR #120013)

2024-12-17 Thread Dmitry Chestnykh via cfe-commits

chestnykh wrote:

I've debugged msan errors. On CI there were stack overflows caused by 'wrong' 
msan reports and circular calls libunwind -> libmsan -> libunwind.

For example:
```
#4234 0x55587eb2 in __msan_warning_with_origin_noreturn () at 
/home/dima/work/llvm-project/compiler-rt/lib/msan/msan.cpp:422
#4235 0x77f7828e in libunwind::Registers_x86_64::getRegister 
(this=0x7fa07cc0, regNum=-1) at 
/home/dima/work/llvm-project/libunwind/src/Registers.hpp:412
#4236 0x77f72b5c in 
libunwind::UnwindCursor::getReg (this=0x7fa07cb0, regNum=-1)
at /home/dima/work/llvm-project/libunwind/src/UnwindCursor.hpp:1353
#4237 0x77f741a3 in 
libunwind::UnwindCursor::setInfoBasedOnIPRegister (this=0x7fa07cb0, 
isReturnAddress=false)
at /home/dima/work/llvm-project/libunwind/src/UnwindCursor.hpp:2561
#4238 0x77f6477f in __unw_init_local (cursor=0x7fa07cb0, 
context=0x7fa07c08) at 
/home/dima/work/llvm-project/libunwind/src/libunwind.cpp:91
#4239 0x77fb2f48 in _Unwind_Backtrace (callback=0x5561be20 
, ref=0x7fa07de8) at 
/home/dima/work/llvm-project/libunwind/src/UnwindLevel1-gcc-ext.c:137
#4240 0x5561bdcb in UnwindSlow () at 
/home/dima/work/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_unwind_linux_libcdep.cpp:130
#4241 0x55615455 in __sanitizer::BufferedStackTrace::Unwind(unsigned 
int, unsigned long, unsigned long, void*, unsigned long, unsigned long, bool) ()
at 
/home/dima/work/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_stacktrace_libcdep.cpp:158
#4242 0x55587985 in UnwindImpl () at 
/home/dima/work/llvm-project/compiler-rt/lib/msan/msan.cpp:342
#4243 0x55587578 in Unwind () at 
/home/dima/work/llvm-project/compiler-rt/lib/msan/../sanitizer_common/sanitizer_stacktrace.h:130
#4244 PrintWarningWithOrigin () at 
/home/dima/work/llvm-project/compiler-rt/lib/msan/msan.cpp:247
#4245 0x55587eb2 in __msan_warning_with_origin_noreturn () at 
/home/dima/work/llvm-project/compiler-rt/lib/msan/msan.cpp:422

```

There were also regular msan reports fixed by modifying tests srcs to add 
explicit initialization of unw_cursor_t and unw_context_t variables:

```
# .---command stderr
# | ==152363==WARNING: MemorySanitizer: use-of-uninitialized-value
# | #0 0x77fa6564  
(/home/dima/work/llvm-project/build/runtimes/runtimes-bins/libunwind/test-suite-install/lib/x86_64-unknown-linux-gnu/libunwind.so.1+0x6564)
# | #1 0x77fa6bee  
(/home/dima/work/llvm-project/build/runtimes/runtimes-bins/libunwind/test-suite-install/lib/x86_64-unknown-linux-gnu/libunwind.so.1+0x6bee)
# | #2 0x77fa28f9  
(/home/dima/work/llvm-project/build/runtimes/runtimes-bins/libunwind/test-suite-install/lib/x86_64-unknown-linux-gnu/libunwind.so.1+0x28f9)
# | #3 0x5562481d  
(/home/dima/work/llvm-project/build/runtimes/runtimes-bins/libunwind/test/Output/unw_resume.pass.cpp.dir/t.tmp.exe+0xd081d)
# | #4 0x556248a6  
(/home/dima/work/llvm-project/build/runtimes/runtimes-bins/libunwind/test/Output/unw_resume.pass.cpp.dir/t.tmp.exe+0xd08a6)
# | #5 0x77945e07  (/usr/lib/libc.so.6+0x25e07) (BuildId: 
98b3d8e0b8c534c769cb871c438b4f8f3a8e4bf3)
# | #6 0x77945ecb  (/usr/lib/libc.so.6+0x25ecb) (BuildId: 
98b3d8e0b8c534c769cb871c438b4f8f3a8e4bf3)
# | #7 0x55587334  
(/home/dima/work/llvm-project/build/runtimes/runtimes-bins/libunwind/test/Output/unw_resume.pass.cpp.dir/t.tmp.exe+0x4)
# | 
# |   Uninitialized value was stored to memory at
# | #0 0x5558e52d  
(/home/dima/work/llvm-project/build/runtimes/runtimes-bins/libunwind/test/Output/unw_resume.pass.cpp.dir/t.tmp.exe+0x3a52d)
# | #1 0x77fa28dc  
(/home/dima/work/llvm-project/build/runtimes/runtimes-bins/libunwind/test-suite-install/lib/x86_64-unknown-linux-gnu/libunwind.so.1+0x28dc)
# | #2 0x5562481d  
(/home/dima/work/llvm-project/build/runtimes/runtimes-bins/libunwind/test/Output/unw_resume.pass.cpp.dir/t.tmp.exe+0xd081d)
# | #3 0x556248a6  
(/home/dima/work/llvm-project/build/runtimes/runtimes-bins/libunwind/test/Output/unw_resume.pass.cpp.dir/t.tmp.exe+0xd08a6)
# | #4 0x77945e07  (/usr/lib/libc.so.6+0x25e07) (BuildId: 
98b3d8e0b8c534c769cb871c438b4f8f3a8e4bf3)
# | #5 0x77945ecb  (/usr/lib/libc.so.6+0x25ecb) (BuildId: 
98b3d8e0b8c534c769cb871c438b4f8f3a8e4bf3)
# | #6 0x55587334  
(/home/dima/work/llvm-project/build/runtimes/runtimes-bins/libunwind/test/Output/unw_resume.pass.cpp.dir/t.tmp.exe+0x4)
# | 
# |   Uninitialized value was created by an allocation of 'context' in the 
stack frame
# | #0 0x556247bc  
(/home/dima/work/llvm-project/build/runtimes/runtimes-bins/libunwind/test/Output/unw_resume.pass.cpp.dir/t.tmp.exe+0xd07bc)

```

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

[libunwind] [Libunwind] Try to fix msan failures (PR #120013)

2024-12-17 Thread Dmitry Chestnykh via cfe-commits

https://github.com/chestnykh updated 
https://github.com/llvm/llvm-project/pull/120013

>From 9422b097ff80f5501dcf4fa3d41176b9439ab3f6 Mon Sep 17 00:00:00 2001
From: Dmitry Chestnykh 
Date: Sun, 15 Dec 2024 21:18:23 +0300
Subject: [PATCH 1/4] [Libunwind] Don't XFAIL tests with msan

---
 libunwind/test/forceunwind.pass.cpp | 3 ---
 libunwind/test/libunwind_01.pass.cpp| 3 ---
 libunwind/test/libunwind_02.pass.cpp| 3 ---
 libunwind/test/signal_frame.pass.cpp| 3 ---
 libunwind/test/signal_unwind.pass.cpp   | 3 ---
 libunwind/test/unw_resume.pass.cpp  | 3 ---
 libunwind/test/unwind_leaffunction.pass.cpp | 3 ---
 7 files changed, 21 deletions(-)

diff --git a/libunwind/test/forceunwind.pass.cpp 
b/libunwind/test/forceunwind.pass.cpp
index 344034e1ea5f5e..e8333eb74a979a 100644
--- a/libunwind/test/forceunwind.pass.cpp
+++ b/libunwind/test/forceunwind.pass.cpp
@@ -9,9 +9,6 @@
 
 // REQUIRES: linux
 
-// TODO: Figure out why this fails with Memory Sanitizer.
-// XFAIL: msan
-
 // Basic test for _Unwind_ForcedUnwind.
 // See libcxxabi/test/forced_unwind* tests too.
 
diff --git a/libunwind/test/libunwind_01.pass.cpp 
b/libunwind/test/libunwind_01.pass.cpp
index 838df6b5897204..82fb66d665c259 100644
--- a/libunwind/test/libunwind_01.pass.cpp
+++ b/libunwind/test/libunwind_01.pass.cpp
@@ -10,9 +10,6 @@
 // TODO: Investigate this failure on x86_64 macOS back deployment
 // XFAIL: stdlib=system && 
target=x86_64-apple-macosx{{10.9|10.10|10.11|10.12|10.13|10.14|10.15|11.0|12.0}}
 
-// TODO: Figure out why this fails with Memory Sanitizer.
-// XFAIL: msan
-
 #include 
 #include 
 #include 
diff --git a/libunwind/test/libunwind_02.pass.cpp 
b/libunwind/test/libunwind_02.pass.cpp
index 9fd8e5d7159c96..5f2d2b43bddc1c 100644
--- a/libunwind/test/libunwind_02.pass.cpp
+++ b/libunwind/test/libunwind_02.pass.cpp
@@ -7,9 +7,6 @@
 //
 
//===--===//
 
-// TODO: Figure out why this fails with Memory Sanitizer.
-// XFAIL: msan
-
 // This test fails on older llvm, when built with picolibc.
 // XFAIL: clang-16 && LIBCXX-PICOLIBC-FIXME
 
diff --git a/libunwind/test/signal_frame.pass.cpp 
b/libunwind/test/signal_frame.pass.cpp
index 004029cfe1e90b..67b862c98fbfc7 100644
--- a/libunwind/test/signal_frame.pass.cpp
+++ b/libunwind/test/signal_frame.pass.cpp
@@ -12,9 +12,6 @@
 // TODO: Investigate this failure on Apple
 // XFAIL: target={{.+}}-apple-{{.+}}
 
-// TODO: Figure out why this fails with Memory Sanitizer.
-// XFAIL: msan
-
 // UNSUPPORTED: libunwind-arm-ehabi
 
 // The AIX assembler does not support CFI directives, which
diff --git a/libunwind/test/signal_unwind.pass.cpp 
b/libunwind/test/signal_unwind.pass.cpp
index 1c1566415a4d4b..8ba0c8b2859ac4 100644
--- a/libunwind/test/signal_unwind.pass.cpp
+++ b/libunwind/test/signal_unwind.pass.cpp
@@ -10,9 +10,6 @@
 // Ensure that the unwinder can cope with the signal handler.
 // REQUIRES: target={{(aarch64|riscv64|s390x|x86_64)-.+linux.*}}
 
-// TODO: Figure out why this fails with Memory Sanitizer.
-// XFAIL: msan
-
 // Note: this test fails on musl because:
 //
 //  (a) musl disables emission of unwind information for its build, and
diff --git a/libunwind/test/unw_resume.pass.cpp 
b/libunwind/test/unw_resume.pass.cpp
index 2b7470b5cad0eb..ca6068a828e0ac 100644
--- a/libunwind/test/unw_resume.pass.cpp
+++ b/libunwind/test/unw_resume.pass.cpp
@@ -10,9 +10,6 @@
 // Ensure that unw_resume() resumes execution at the stack frame identified by
 // cursor.
 
-// TODO: Figure out why this fails with Memory Sanitizer.
-// XFAIL: msan
-
 #include 
 
 __attribute__((noinline)) void test_unw_resume() {
diff --git a/libunwind/test/unwind_leaffunction.pass.cpp 
b/libunwind/test/unwind_leaffunction.pass.cpp
index 98de7dc43260c2..4259406cc493d1 100644
--- a/libunwind/test/unwind_leaffunction.pass.cpp
+++ b/libunwind/test/unwind_leaffunction.pass.cpp
@@ -10,9 +10,6 @@
 // Ensure that leaf function can be unwund.
 // REQUIRES: target={{(aarch64|riscv64|s390x|x86_64)-.+linux.*}}
 
-// TODO: Figure out why this fails with Memory Sanitizer.
-// XFAIL: msan
-
 // Note: this test fails on musl because:
 //
 //  (a) musl disables emission of unwind information for its build, and

>From 0a4a0e12d7b4daf72dd4461962fbf6cc5114347f Mon Sep 17 00:00:00 2001
From: Dmitry Chestnykh 
Date: Mon, 16 Dec 2024 21:40:46 +0300
Subject: [PATCH 2/4] Try to remove -lunwind from link flags

The possible reason why tests fail is that
MAYBE there are another libunwind on the testing host
which is loaded(?) instead of libunwind from llvm.
clang passes 'right' libunwind (-lunwind) to the linker
if -unwindlib=libunwind is passed to the driver
---
 libunwind/test/configs/llvm-libunwind-shared.cfg.in | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libunwind/test/configs/llvm-libunwind-shared.cfg.in 
b/libunwind/test/configs/llvm-libunwind-shared.cfg.in
index f3e40928b525da..256f8111948bd3 100644
--

[libunwind] [Libunwind] Try to fix msan failures (PR #120013)

2024-12-17 Thread Dmitry Chestnykh via cfe-commits

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


[libunwind] [Libunwind] Try to fix msan failures (PR #120013)

2024-12-17 Thread Dmitry Chestnykh via cfe-commits

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


[libunwind] [Libunwind] Try to fix msan failures (PR #120013)

2024-12-17 Thread Dmitry Chestnykh via cfe-commits


@@ -133,6 +133,10 @@ _LIBUNWIND_EXPORT _Unwind_Reason_Code
 _Unwind_Backtrace(_Unwind_Trace_Fn callback, void *ref) {
   unw_cursor_t cursor;
   unw_context_t uc;
+#if __has_feature(memory_sanitizer)
+  __builtin_memset(&cursor, 0, sizeof(cursor));

chestnykh wrote:

It's better to create a bug on msan?

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


[libunwind] [Libunwind] Try to fix msan failures (PR #120013)

2024-12-17 Thread Dmitry Chestnykh via cfe-commits

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


[clang] [Clang][Sema] Process warnings conditionally (PR #120591)

2024-12-19 Thread Dmitry Chestnykh via cfe-commits

https://github.com/chestnykh created 
https://github.com/llvm/llvm-project/pull/120591

There are a few functions that emit warnings related to positional arguments in 
format strings. These functions use `getLocationOfByte()` which has O(n) 
complexity and may lead to silent hang of compilation in some cases. But such 
warnings is not widely used and actually don't emit if user didn't pass the 
appropriate `-W...` flag, so if the flag is not passed dont make the call
to `EmitFormatDiagnostic` for such diags.

Fix #120462

>From 5b61245bbdc9d1874684f29bba880f6b5a4cfe82 Mon Sep 17 00:00:00 2001
From: Dmitry Chestnykh 
Date: Thu, 19 Dec 2024 18:35:35 +0300
Subject: [PATCH] [Clang][Sema] Process warnings conditionally

There are a few functions that emit warnings
related to positional arguments in format strings.
These functions use `getLocationOfByte()` which has O(n)
complexity and may lead to silent hang of compilation in some cases.
But such warnings is not widely used and actually don't emit
if user didn't pass the appropriate `-W...` flag, so
if the flag is not passed dont make the call
to `EmitFormatDiagnostic` for such diags.

Fix #120462
---
 clang/lib/Sema/SemaChecking.cpp | 30 ++
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index be5d3694aec152..a745250988feeb 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -6612,27 +6612,33 @@ void 
CheckFormatHandler::HandleNonStandardConversionSpecifier(
 
 void CheckFormatHandler::HandlePosition(const char *startPos,
 unsigned posLen) {
-  EmitFormatDiagnostic(S.PDiag(diag::warn_format_non_standard_positional_arg),
-   getLocationOfByte(startPos),
-   /*IsStringLocation*/true,
-   getSpecifierRange(startPos, posLen));
+  if 
(!S.getDiagnostics().isIgnored(diag::warn_format_non_standard_positional_arg, 
SourceLocation())) {
+
EmitFormatDiagnostic(S.PDiag(diag::warn_format_non_standard_positional_arg),
+getLocationOfByte(startPos),
+/*IsStringLocation*/true,
+getSpecifierRange(startPos, posLen));
+  }
 }
 
 void CheckFormatHandler::HandleInvalidPosition(
 const char *startSpecifier, unsigned specifierLen,
 analyze_format_string::PositionContext p) {
-  EmitFormatDiagnostic(
-  S.PDiag(diag::warn_format_invalid_positional_specifier) << (unsigned)p,
-  getLocationOfByte(startSpecifier), /*IsStringLocation*/ true,
-  getSpecifierRange(startSpecifier, specifierLen));
+  if 
(!S.getDiagnostics().isIgnored(diag::warn_format_invalid_positional_specifier, 
SourceLocation())) {
+EmitFormatDiagnostic(
+S.PDiag(diag::warn_format_invalid_positional_specifier) << (unsigned)p,
+getLocationOfByte(startSpecifier), /*IsStringLocation*/ true,
+getSpecifierRange(startSpecifier, specifierLen));
+  }
 }
 
 void CheckFormatHandler::HandleZeroPosition(const char *startPos,
 unsigned posLen) {
-  EmitFormatDiagnostic(S.PDiag(diag::warn_format_zero_positional_specifier),
-   getLocationOfByte(startPos),
-   /*IsStringLocation*/true,
-   getSpecifierRange(startPos, posLen));
+  if 
(!S.getDiagnostics().isIgnored(diag::warn_format_zero_positional_specifier, 
SourceLocation())) {
+EmitFormatDiagnostic(S.PDiag(diag::warn_format_zero_positional_specifier),
+getLocationOfByte(startPos),
+/*IsStringLocation*/true,
+getSpecifierRange(startPos, posLen));
+  }
 }
 
 void CheckFormatHandler::HandleNullChar(const char *nullCharacter) {

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


[clang] [Clang][Sema] Process warnings conditionally (PR #120591)

2024-12-19 Thread Dmitry Chestnykh via cfe-commits

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


[clang] [Clang][Sema] Process warnings conditionally (PR #120591)

2024-12-19 Thread Dmitry Chestnykh via cfe-commits

https://github.com/chestnykh updated 
https://github.com/llvm/llvm-project/pull/120591

>From 5b61245bbdc9d1874684f29bba880f6b5a4cfe82 Mon Sep 17 00:00:00 2001
From: Dmitry Chestnykh 
Date: Thu, 19 Dec 2024 18:35:35 +0300
Subject: [PATCH 1/2] [Clang][Sema] Process warnings conditionally

There are a few functions that emit warnings
related to positional arguments in format strings.
These functions use `getLocationOfByte()` which has O(n)
complexity and may lead to silent hang of compilation in some cases.
But such warnings is not widely used and actually don't emit
if user didn't pass the appropriate `-W...` flag, so
if the flag is not passed dont make the call
to `EmitFormatDiagnostic` for such diags.

Fix #120462
---
 clang/lib/Sema/SemaChecking.cpp | 30 ++
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index be5d3694aec152..a745250988feeb 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -6612,27 +6612,33 @@ void 
CheckFormatHandler::HandleNonStandardConversionSpecifier(
 
 void CheckFormatHandler::HandlePosition(const char *startPos,
 unsigned posLen) {
-  EmitFormatDiagnostic(S.PDiag(diag::warn_format_non_standard_positional_arg),
-   getLocationOfByte(startPos),
-   /*IsStringLocation*/true,
-   getSpecifierRange(startPos, posLen));
+  if 
(!S.getDiagnostics().isIgnored(diag::warn_format_non_standard_positional_arg, 
SourceLocation())) {
+
EmitFormatDiagnostic(S.PDiag(diag::warn_format_non_standard_positional_arg),
+getLocationOfByte(startPos),
+/*IsStringLocation*/true,
+getSpecifierRange(startPos, posLen));
+  }
 }
 
 void CheckFormatHandler::HandleInvalidPosition(
 const char *startSpecifier, unsigned specifierLen,
 analyze_format_string::PositionContext p) {
-  EmitFormatDiagnostic(
-  S.PDiag(diag::warn_format_invalid_positional_specifier) << (unsigned)p,
-  getLocationOfByte(startSpecifier), /*IsStringLocation*/ true,
-  getSpecifierRange(startSpecifier, specifierLen));
+  if 
(!S.getDiagnostics().isIgnored(diag::warn_format_invalid_positional_specifier, 
SourceLocation())) {
+EmitFormatDiagnostic(
+S.PDiag(diag::warn_format_invalid_positional_specifier) << (unsigned)p,
+getLocationOfByte(startSpecifier), /*IsStringLocation*/ true,
+getSpecifierRange(startSpecifier, specifierLen));
+  }
 }
 
 void CheckFormatHandler::HandleZeroPosition(const char *startPos,
 unsigned posLen) {
-  EmitFormatDiagnostic(S.PDiag(diag::warn_format_zero_positional_specifier),
-   getLocationOfByte(startPos),
-   /*IsStringLocation*/true,
-   getSpecifierRange(startPos, posLen));
+  if 
(!S.getDiagnostics().isIgnored(diag::warn_format_zero_positional_specifier, 
SourceLocation())) {
+EmitFormatDiagnostic(S.PDiag(diag::warn_format_zero_positional_specifier),
+getLocationOfByte(startPos),
+/*IsStringLocation*/true,
+getSpecifierRange(startPos, posLen));
+  }
 }
 
 void CheckFormatHandler::HandleNullChar(const char *nullCharacter) {

>From 7f93928a842888ab848a97bd5fbd981523c9c4d9 Mon Sep 17 00:00:00 2001
From: Dmitry Chestnykh 
Date: Thu, 19 Dec 2024 18:50:04 +0300
Subject: [PATCH 2/2] [clang][Sema] Fix code style

---
 clang/lib/Sema/SemaChecking.cpp | 21 -
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index a745250988feeb..b0076c2686a35b 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -6612,18 +6612,20 @@ void 
CheckFormatHandler::HandleNonStandardConversionSpecifier(
 
 void CheckFormatHandler::HandlePosition(const char *startPos,
 unsigned posLen) {
-  if 
(!S.getDiagnostics().isIgnored(diag::warn_format_non_standard_positional_arg, 
SourceLocation())) {
+  if (!S.getDiagnostics().isIgnored(
+  diag::warn_format_non_standard_positional_arg, SourceLocation())) {
 
EmitFormatDiagnostic(S.PDiag(diag::warn_format_non_standard_positional_arg),
-getLocationOfByte(startPos),
-/*IsStringLocation*/true,
-getSpecifierRange(startPos, posLen));
+ getLocationOfByte(startPos),
+ /*IsStringLocation*/ true,
+ getSpecifierRange(startPos, posLen));
   }
 }
 
 void CheckFormatHandler::HandleInvalidPosition(
 const char *startSpecifier, unsi

[clang] [Clang][Sema] Process warnings conditionally (PR #120591)

2024-12-22 Thread Dmitry Chestnykh via cfe-commits

https://github.com/chestnykh updated 
https://github.com/llvm/llvm-project/pull/120591

>From 9a0d5d44f70477403a33d2feb3f5518b0d078a66 Mon Sep 17 00:00:00 2001
From: Dmitry Chestnykh 
Date: Thu, 19 Dec 2024 18:35:35 +0300
Subject: [PATCH 1/2] [Clang][Sema] Process warnings conditionally

There are a few functions that emit warnings
related to positional arguments in format strings.
These functions use `getLocationOfByte()` which has O(n)
complexity and may lead to silent hang of compilation in some cases.
But such warnings is not widely used and actually don't emit
if user didn't pass the appropriate `-W...` flag, so
if the flag is not passed dont make the call
to `EmitFormatDiagnostic` for such diags.

Fix #120462
---
 clang/lib/Sema/SemaChecking.cpp | 30 ++
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index e703a62ff9cf18..f5c42eba51c252 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -6591,27 +6591,33 @@ void 
CheckFormatHandler::HandleNonStandardConversionSpecifier(
 
 void CheckFormatHandler::HandlePosition(const char *startPos,
 unsigned posLen) {
-  EmitFormatDiagnostic(S.PDiag(diag::warn_format_non_standard_positional_arg),
-   getLocationOfByte(startPos),
-   /*IsStringLocation*/true,
-   getSpecifierRange(startPos, posLen));
+  if 
(!S.getDiagnostics().isIgnored(diag::warn_format_non_standard_positional_arg, 
SourceLocation())) {
+
EmitFormatDiagnostic(S.PDiag(diag::warn_format_non_standard_positional_arg),
+getLocationOfByte(startPos),
+/*IsStringLocation*/true,
+getSpecifierRange(startPos, posLen));
+  }
 }
 
 void CheckFormatHandler::HandleInvalidPosition(
 const char *startSpecifier, unsigned specifierLen,
 analyze_format_string::PositionContext p) {
-  EmitFormatDiagnostic(
-  S.PDiag(diag::warn_format_invalid_positional_specifier) << (unsigned)p,
-  getLocationOfByte(startSpecifier), /*IsStringLocation*/ true,
-  getSpecifierRange(startSpecifier, specifierLen));
+  if 
(!S.getDiagnostics().isIgnored(diag::warn_format_invalid_positional_specifier, 
SourceLocation())) {
+EmitFormatDiagnostic(
+S.PDiag(diag::warn_format_invalid_positional_specifier) << (unsigned)p,
+getLocationOfByte(startSpecifier), /*IsStringLocation*/ true,
+getSpecifierRange(startSpecifier, specifierLen));
+  }
 }
 
 void CheckFormatHandler::HandleZeroPosition(const char *startPos,
 unsigned posLen) {
-  EmitFormatDiagnostic(S.PDiag(diag::warn_format_zero_positional_specifier),
-   getLocationOfByte(startPos),
-   /*IsStringLocation*/true,
-   getSpecifierRange(startPos, posLen));
+  if 
(!S.getDiagnostics().isIgnored(diag::warn_format_zero_positional_specifier, 
SourceLocation())) {
+EmitFormatDiagnostic(S.PDiag(diag::warn_format_zero_positional_specifier),
+getLocationOfByte(startPos),
+/*IsStringLocation*/true,
+getSpecifierRange(startPos, posLen));
+  }
 }
 
 void CheckFormatHandler::HandleNullChar(const char *nullCharacter) {

>From 7928effc17882139e548adbfe88a52d56f844d3b Mon Sep 17 00:00:00 2001
From: Dmitry Chestnykh 
Date: Thu, 19 Dec 2024 18:50:04 +0300
Subject: [PATCH 2/2] [clang][Sema] Fix code style

---
 clang/lib/Sema/SemaChecking.cpp | 21 -
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index f5c42eba51c252..9a05181405cde5 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -6591,18 +6591,20 @@ void 
CheckFormatHandler::HandleNonStandardConversionSpecifier(
 
 void CheckFormatHandler::HandlePosition(const char *startPos,
 unsigned posLen) {
-  if 
(!S.getDiagnostics().isIgnored(diag::warn_format_non_standard_positional_arg, 
SourceLocation())) {
+  if (!S.getDiagnostics().isIgnored(
+  diag::warn_format_non_standard_positional_arg, SourceLocation())) {
 
EmitFormatDiagnostic(S.PDiag(diag::warn_format_non_standard_positional_arg),
-getLocationOfByte(startPos),
-/*IsStringLocation*/true,
-getSpecifierRange(startPos, posLen));
+ getLocationOfByte(startPos),
+ /*IsStringLocation*/ true,
+ getSpecifierRange(startPos, posLen));
   }
 }
 
 void CheckFormatHandler::HandleInvalidPosition(
 const char *startSpecifier, unsi

[clang] [Clang][Sema] Process warnings conditionally (PR #120591)

2024-12-23 Thread Dmitry Chestnykh via cfe-commits

https://github.com/chestnykh updated 
https://github.com/llvm/llvm-project/pull/120591

>From 9a0d5d44f70477403a33d2feb3f5518b0d078a66 Mon Sep 17 00:00:00 2001
From: Dmitry Chestnykh 
Date: Thu, 19 Dec 2024 18:35:35 +0300
Subject: [PATCH 1/3] [Clang][Sema] Process warnings conditionally

There are a few functions that emit warnings
related to positional arguments in format strings.
These functions use `getLocationOfByte()` which has O(n)
complexity and may lead to silent hang of compilation in some cases.
But such warnings is not widely used and actually don't emit
if user didn't pass the appropriate `-W...` flag, so
if the flag is not passed dont make the call
to `EmitFormatDiagnostic` for such diags.

Fix #120462
---
 clang/lib/Sema/SemaChecking.cpp | 30 ++
 1 file changed, 18 insertions(+), 12 deletions(-)

diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index e703a62ff9cf18..f5c42eba51c252 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -6591,27 +6591,33 @@ void 
CheckFormatHandler::HandleNonStandardConversionSpecifier(
 
 void CheckFormatHandler::HandlePosition(const char *startPos,
 unsigned posLen) {
-  EmitFormatDiagnostic(S.PDiag(diag::warn_format_non_standard_positional_arg),
-   getLocationOfByte(startPos),
-   /*IsStringLocation*/true,
-   getSpecifierRange(startPos, posLen));
+  if 
(!S.getDiagnostics().isIgnored(diag::warn_format_non_standard_positional_arg, 
SourceLocation())) {
+
EmitFormatDiagnostic(S.PDiag(diag::warn_format_non_standard_positional_arg),
+getLocationOfByte(startPos),
+/*IsStringLocation*/true,
+getSpecifierRange(startPos, posLen));
+  }
 }
 
 void CheckFormatHandler::HandleInvalidPosition(
 const char *startSpecifier, unsigned specifierLen,
 analyze_format_string::PositionContext p) {
-  EmitFormatDiagnostic(
-  S.PDiag(diag::warn_format_invalid_positional_specifier) << (unsigned)p,
-  getLocationOfByte(startSpecifier), /*IsStringLocation*/ true,
-  getSpecifierRange(startSpecifier, specifierLen));
+  if 
(!S.getDiagnostics().isIgnored(diag::warn_format_invalid_positional_specifier, 
SourceLocation())) {
+EmitFormatDiagnostic(
+S.PDiag(diag::warn_format_invalid_positional_specifier) << (unsigned)p,
+getLocationOfByte(startSpecifier), /*IsStringLocation*/ true,
+getSpecifierRange(startSpecifier, specifierLen));
+  }
 }
 
 void CheckFormatHandler::HandleZeroPosition(const char *startPos,
 unsigned posLen) {
-  EmitFormatDiagnostic(S.PDiag(diag::warn_format_zero_positional_specifier),
-   getLocationOfByte(startPos),
-   /*IsStringLocation*/true,
-   getSpecifierRange(startPos, posLen));
+  if 
(!S.getDiagnostics().isIgnored(diag::warn_format_zero_positional_specifier, 
SourceLocation())) {
+EmitFormatDiagnostic(S.PDiag(diag::warn_format_zero_positional_specifier),
+getLocationOfByte(startPos),
+/*IsStringLocation*/true,
+getSpecifierRange(startPos, posLen));
+  }
 }
 
 void CheckFormatHandler::HandleNullChar(const char *nullCharacter) {

>From 7928effc17882139e548adbfe88a52d56f844d3b Mon Sep 17 00:00:00 2001
From: Dmitry Chestnykh 
Date: Thu, 19 Dec 2024 18:50:04 +0300
Subject: [PATCH 2/3] [clang][Sema] Fix code style

---
 clang/lib/Sema/SemaChecking.cpp | 21 -
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index f5c42eba51c252..9a05181405cde5 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -6591,18 +6591,20 @@ void 
CheckFormatHandler::HandleNonStandardConversionSpecifier(
 
 void CheckFormatHandler::HandlePosition(const char *startPos,
 unsigned posLen) {
-  if 
(!S.getDiagnostics().isIgnored(diag::warn_format_non_standard_positional_arg, 
SourceLocation())) {
+  if (!S.getDiagnostics().isIgnored(
+  diag::warn_format_non_standard_positional_arg, SourceLocation())) {
 
EmitFormatDiagnostic(S.PDiag(diag::warn_format_non_standard_positional_arg),
-getLocationOfByte(startPos),
-/*IsStringLocation*/true,
-getSpecifierRange(startPos, posLen));
+ getLocationOfByte(startPos),
+ /*IsStringLocation*/ true,
+ getSpecifierRange(startPos, posLen));
   }
 }
 
 void CheckFormatHandler::HandleInvalidPosition(
 const char *startSpecifier, unsi

[clang] [Clang][Sema] Process warnings conditionally (PR #120591)

2024-12-23 Thread Dmitry Chestnykh via cfe-commits


@@ -6591,27 +6591,36 @@ void 
CheckFormatHandler::HandleNonStandardConversionSpecifier(
 
 void CheckFormatHandler::HandlePosition(const char *startPos,
 unsigned posLen) {
-  EmitFormatDiagnostic(S.PDiag(diag::warn_format_non_standard_positional_arg),
-   getLocationOfByte(startPos),
-   /*IsStringLocation*/true,
-   getSpecifierRange(startPos, posLen));
+  if (!S.getDiagnostics().isIgnored(
+  diag::warn_format_non_standard_positional_arg, SourceLocation())) {
+
EmitFormatDiagnostic(S.PDiag(diag::warn_format_non_standard_positional_arg),
+ getLocationOfByte(startPos),
+ /*IsStringLocation*/ true,
+ getSpecifierRange(startPos, posLen));
+  }

chestnykh wrote:

Fixed

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


[clang] [Clang][Sema] Process warnings conditionally (PR #120591)

2024-12-23 Thread Dmitry Chestnykh via cfe-commits


@@ -6591,27 +6591,36 @@ void 
CheckFormatHandler::HandleNonStandardConversionSpecifier(
 
 void CheckFormatHandler::HandlePosition(const char *startPos,
 unsigned posLen) {
-  EmitFormatDiagnostic(S.PDiag(diag::warn_format_non_standard_positional_arg),
-   getLocationOfByte(startPos),
-   /*IsStringLocation*/true,
-   getSpecifierRange(startPos, posLen));
+  if (!S.getDiagnostics().isIgnored(
+  diag::warn_format_non_standard_positional_arg, SourceLocation())) {
+
EmitFormatDiagnostic(S.PDiag(diag::warn_format_non_standard_positional_arg),
+ getLocationOfByte(startPos),
+ /*IsStringLocation*/ true,
+ getSpecifierRange(startPos, posLen));
+  }
 }
 
 void CheckFormatHandler::HandleInvalidPosition(
 const char *startSpecifier, unsigned specifierLen,
 analyze_format_string::PositionContext p) {
-  EmitFormatDiagnostic(
-  S.PDiag(diag::warn_format_invalid_positional_specifier) << (unsigned)p,
-  getLocationOfByte(startSpecifier), /*IsStringLocation*/ true,
-  getSpecifierRange(startSpecifier, specifierLen));
+  if (!S.getDiagnostics().isIgnored(
+  diag::warn_format_invalid_positional_specifier, SourceLocation())) {
+EmitFormatDiagnostic(
+S.PDiag(diag::warn_format_invalid_positional_specifier) << (unsigned)p,
+getLocationOfByte(startSpecifier), /*IsStringLocation*/ true,
+getSpecifierRange(startSpecifier, specifierLen));
+  }

chestnykh wrote:

Fixed

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


[clang] [Clang][Sema] Process warnings conditionally (PR #120591)

2024-12-23 Thread Dmitry Chestnykh via cfe-commits


@@ -6591,27 +6591,36 @@ void 
CheckFormatHandler::HandleNonStandardConversionSpecifier(
 
 void CheckFormatHandler::HandlePosition(const char *startPos,
 unsigned posLen) {
-  EmitFormatDiagnostic(S.PDiag(diag::warn_format_non_standard_positional_arg),
-   getLocationOfByte(startPos),
-   /*IsStringLocation*/true,
-   getSpecifierRange(startPos, posLen));
+  if (!S.getDiagnostics().isIgnored(
+  diag::warn_format_non_standard_positional_arg, SourceLocation())) {
+
EmitFormatDiagnostic(S.PDiag(diag::warn_format_non_standard_positional_arg),
+ getLocationOfByte(startPos),
+ /*IsStringLocation*/ true,
+ getSpecifierRange(startPos, posLen));
+  }
 }
 
 void CheckFormatHandler::HandleInvalidPosition(
 const char *startSpecifier, unsigned specifierLen,
 analyze_format_string::PositionContext p) {
-  EmitFormatDiagnostic(
-  S.PDiag(diag::warn_format_invalid_positional_specifier) << (unsigned)p,
-  getLocationOfByte(startSpecifier), /*IsStringLocation*/ true,
-  getSpecifierRange(startSpecifier, specifierLen));
+  if (!S.getDiagnostics().isIgnored(
+  diag::warn_format_invalid_positional_specifier, SourceLocation())) {
+EmitFormatDiagnostic(
+S.PDiag(diag::warn_format_invalid_positional_specifier) << (unsigned)p,
+getLocationOfByte(startSpecifier), /*IsStringLocation*/ true,
+getSpecifierRange(startSpecifier, specifierLen));
+  }
 }
 
 void CheckFormatHandler::HandleZeroPosition(const char *startPos,
 unsigned posLen) {
-  EmitFormatDiagnostic(S.PDiag(diag::warn_format_zero_positional_specifier),
-   getLocationOfByte(startPos),
-   /*IsStringLocation*/true,
-   getSpecifierRange(startPos, posLen));
+  if 
(!S.getDiagnostics().isIgnored(diag::warn_format_zero_positional_specifier,
+SourceLocation())) {
+EmitFormatDiagnostic(S.PDiag(diag::warn_format_zero_positional_specifier),
+ getLocationOfByte(startPos),
+ /*IsStringLocation*/ true,
+ getSpecifierRange(startPos, posLen));
+  }

chestnykh wrote:

Fixed

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


[clang] [Clang][Sema] Process warnings conditionally (PR #120591)

2024-12-23 Thread Dmitry Chestnykh via cfe-commits

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


[clang] [sanitizer][CFI] Add support to build CFI with sanitize-coverage (PR #131296)

2025-04-05 Thread Dmitry Chestnykh via cfe-commits

chestnykh wrote:

@Mephistophiles do you have commit access or you need someone to push on your 
behalf?

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


[clang] [sanitizer][CFI] Add support to build CFI with sanitize-coverage (PR #131296)

2025-04-05 Thread Dmitry Chestnykh via cfe-commits

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


[clang] [sanitizer][CFI] Add support to build CFI with sanitize-coverage (PR #131296)

2025-04-02 Thread Dmitry Chestnykh via cfe-commits

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

LGTM

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