[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [lldb] [llvm] [mlir] [openmp] [polly] fix(python): fix comparison to None (PR #91857)

2024-05-12 Thread Mircea Trofin via lldb-commits

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

LGTM for the `ctx_profile` part.

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


[Lldb-commits] [lldb] [lldb] Fixed the test TestQuoting (PR #91886)

2024-05-12 Thread Dmitry Vasilyev via lldb-commits

https://github.com/slydiman updated 
https://github.com/llvm/llvm-project/pull/91886

>From f6135c1b825afd9fe733b845dfd12ffe3c162840 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Sun, 12 May 2024 18:08:50 +0400
Subject: [PATCH 1/2] [lldb] Fixed the test TestQuoting

os.path.join() uses the path separator of the host OS by default. outfile_arg 
will be incorrect in case of Windows host and Linux target. Use 
lldbutil.append_to_process_working_directory() instead.
---
 lldb/test/API/commands/settings/quoting/TestQuoting.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lldb/test/API/commands/settings/quoting/TestQuoting.py 
b/lldb/test/API/commands/settings/quoting/TestQuoting.py
index 393f4be3c8242..d6246a5309c5d 100644
--- a/lldb/test/API/commands/settings/quoting/TestQuoting.py
+++ b/lldb/test/API/commands/settings/quoting/TestQuoting.py
@@ -51,8 +51,8 @@ def expect_args(self, args_in, args_out):
 outfile = self.getBuildArtifact(filename)
 
 if lldb.remote_platform:
-outfile_arg = os.path.join(
-lldb.remote_platform.GetWorkingDirectory(), filename
+outfile_arg = lldbutil.append_to_process_working_directory(
+self, filename
 )
 else:
 outfile_arg = outfile

>From ff85c4d9cb0c749fe75be1493dd22b7f7c0de9be Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Sun, 12 May 2024 18:35:12 +0400
Subject: [PATCH 2/2] Updated the formatting by darker

---
 lldb/test/API/commands/settings/quoting/TestQuoting.py | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/lldb/test/API/commands/settings/quoting/TestQuoting.py 
b/lldb/test/API/commands/settings/quoting/TestQuoting.py
index d6246a5309c5d..60ad4e0a4 100644
--- a/lldb/test/API/commands/settings/quoting/TestQuoting.py
+++ b/lldb/test/API/commands/settings/quoting/TestQuoting.py
@@ -51,9 +51,7 @@ def expect_args(self, args_in, args_out):
 outfile = self.getBuildArtifact(filename)
 
 if lldb.remote_platform:
-outfile_arg = lldbutil.append_to_process_working_directory(
-self, filename
-)
+outfile_arg = lldbutil.append_to_process_working_directory(self, 
filename)
 else:
 outfile_arg = outfile
 

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


[Lldb-commits] [lldb] [lldb][Windows] Enforce exec permission using Platform::Install() from Windows host (PR #91887)

2024-05-12 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dmitry Vasilyev (slydiman)


Changes

Target::Install() set 0700 permissions for the main executable file. 
Platform::Install() just copies permissions from the source. But the permission 
eFilePermissionsUserExecute is missing on the Windows host. A lot of tests 
failed in case of Windows host and Linux target because of this issue. There is 
no API to provide the exec flag. This patch set the permission 
eFilePermissionsUserExecute for all files installed via Platform::Install() 
from the Windows host. It fixes a lot of tests in case of Windows host and 
Linux target.

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


1 Files Affected:

- (modified) lldb/source/Target/Platform.cpp (+4) 


``diff
diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp
index 4af4aa68ccd01..0e7739b3712d7 100644
--- a/lldb/source/Target/Platform.cpp
+++ b/lldb/source/Target/Platform.cpp
@@ -1227,6 +1227,10 @@ Status Platform::PutFile(const FileSpec , const 
FileSpec ,
   if (permissions == 0)
 permissions = lldb::eFilePermissionsFileDefault;
 
+#if defined(_WIN32)
+  permissions |= lldb::eFilePermissionsUserExecute;
+#endif
+
   lldb::user_id_t dest_file = OpenFile(
   destination, File::eOpenOptionCanCreate | File::eOpenOptionWriteOnly |
File::eOpenOptionTruncate | 
File::eOpenOptionCloseOnExec,

``




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


[Lldb-commits] [lldb] [lldb][Windows] Enforce exec permission using Platform::Install() from Windows host (PR #91887)

2024-05-12 Thread Dmitry Vasilyev via lldb-commits

https://github.com/slydiman created 
https://github.com/llvm/llvm-project/pull/91887

Target::Install() set 0700 permissions for the main executable file. 
Platform::Install() just copies permissions from the source. But the permission 
eFilePermissionsUserExecute is missing on the Windows host. A lot of tests 
failed in case of Windows host and Linux target because of this issue. There is 
no API to provide the exec flag. This patch set the permission 
eFilePermissionsUserExecute for all files installed via Platform::Install() 
from the Windows host. It fixes a lot of tests in case of Windows host and 
Linux target.

>From 94f75bd21aac412b9971ccc8dc8382e4a75dc1cd Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Sun, 12 May 2024 18:29:09 +0400
Subject: [PATCH] [lldb][Windows] Enforce exec permission using
 Platform::Install() from Windows host

Target::Install() set 0700 permissions for the main executable file. 
Platform::Install() just copies permissions from the source. But the permission 
eFilePermissionsUserExecute is missing on the Windows host. A lot of tests 
failed in case of Windows host and Linux target because of this issue. There is 
no API to provide the exec flag. This patch set the permission 
eFilePermissionsUserExecute for all files installed via Platform::Install() 
from the Windows host. It fixes a lot of tests in case of Windows host and 
Linux target.
---
 lldb/source/Target/Platform.cpp | 4 
 1 file changed, 4 insertions(+)

diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp
index 4af4aa68ccd01..0e7739b3712d7 100644
--- a/lldb/source/Target/Platform.cpp
+++ b/lldb/source/Target/Platform.cpp
@@ -1227,6 +1227,10 @@ Status Platform::PutFile(const FileSpec , const 
FileSpec ,
   if (permissions == 0)
 permissions = lldb::eFilePermissionsFileDefault;
 
+#if defined(_WIN32)
+  permissions |= lldb::eFilePermissionsUserExecute;
+#endif
+
   lldb::user_id_t dest_file = OpenFile(
   destination, File::eOpenOptionCanCreate | File::eOpenOptionWriteOnly |
File::eOpenOptionTruncate | 
File::eOpenOptionCloseOnExec,

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


[Lldb-commits] [lldb] [lldb] Fixed the test TestQuoting (PR #91886)

2024-05-12 Thread via lldb-commits

github-actions[bot] wrote:




:warning: Python code formatter, darker found issues in your code. :warning:



You can test this locally with the following command:


``bash
darker --check --diff -r 
1d6bf0ca29322b08e8b50681d440e7182441b025...f6135c1b825afd9fe733b845dfd12ffe3c162840
 lldb/test/API/commands/settings/quoting/TestQuoting.py
``





View the diff from darker here.


``diff
--- TestQuoting.py  2024-05-12 14:08:50.00 +
+++ TestQuoting.py  2024-05-12 14:13:04.914847 +
@@ -49,13 +49,11 @@
 
 filename = SettingsCommandTestCase.output_file_name
 outfile = self.getBuildArtifact(filename)
 
 if lldb.remote_platform:
-outfile_arg = lldbutil.append_to_process_working_directory(
-self, filename
-)
+outfile_arg = lldbutil.append_to_process_working_directory(self, 
filename)
 else:
 outfile_arg = outfile
 
 self.runCmd("process launch -- %s %s" % (outfile_arg, args_in))
 

``




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


[Lldb-commits] [lldb] [lldb] Fixed the test TestQuoting (PR #91886)

2024-05-12 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: Dmitry Vasilyev (slydiman)


Changes

os.path.join() uses the path separator of the host OS by default. outfile_arg 
will be incorrect in case of Windows host and Linux target. Use 
lldbutil.append_to_process_working_directory() instead.

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


1 Files Affected:

- (modified) lldb/test/API/commands/settings/quoting/TestQuoting.py (+2-2) 


``diff
diff --git a/lldb/test/API/commands/settings/quoting/TestQuoting.py 
b/lldb/test/API/commands/settings/quoting/TestQuoting.py
index 393f4be3c8242..d6246a5309c5d 100644
--- a/lldb/test/API/commands/settings/quoting/TestQuoting.py
+++ b/lldb/test/API/commands/settings/quoting/TestQuoting.py
@@ -51,8 +51,8 @@ def expect_args(self, args_in, args_out):
 outfile = self.getBuildArtifact(filename)
 
 if lldb.remote_platform:
-outfile_arg = os.path.join(
-lldb.remote_platform.GetWorkingDirectory(), filename
+outfile_arg = lldbutil.append_to_process_working_directory(
+self, filename
 )
 else:
 outfile_arg = outfile

``




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


[Lldb-commits] [lldb] [lldb] Fixed the test TestQuoting (PR #91886)

2024-05-12 Thread Dmitry Vasilyev via lldb-commits

https://github.com/slydiman created 
https://github.com/llvm/llvm-project/pull/91886

os.path.join() uses the path separator of the host OS by default. outfile_arg 
will be incorrect in case of Windows host and Linux target. Use 
lldbutil.append_to_process_working_directory() instead.

>From f6135c1b825afd9fe733b845dfd12ffe3c162840 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev 
Date: Sun, 12 May 2024 18:08:50 +0400
Subject: [PATCH] [lldb] Fixed the test TestQuoting

os.path.join() uses the path separator of the host OS by default. outfile_arg 
will be incorrect in case of Windows host and Linux target. Use 
lldbutil.append_to_process_working_directory() instead.
---
 lldb/test/API/commands/settings/quoting/TestQuoting.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lldb/test/API/commands/settings/quoting/TestQuoting.py 
b/lldb/test/API/commands/settings/quoting/TestQuoting.py
index 393f4be3c8242..d6246a5309c5d 100644
--- a/lldb/test/API/commands/settings/quoting/TestQuoting.py
+++ b/lldb/test/API/commands/settings/quoting/TestQuoting.py
@@ -51,8 +51,8 @@ def expect_args(self, args_in, args_out):
 outfile = self.getBuildArtifact(filename)
 
 if lldb.remote_platform:
-outfile_arg = os.path.join(
-lldb.remote_platform.GetWorkingDirectory(), filename
+outfile_arg = lldbutil.append_to_process_working_directory(
+self, filename
 )
 else:
 outfile_arg = outfile

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


[Lldb-commits] [clang] [clang-tools-extra] [compiler-rt] [lldb] [llvm] [mlir] [openmp] [polly] fix(python): fix comparison to None (PR #91857)

2024-05-12 Thread Oleksandr Alex Zinenko via lldb-commits

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

LGTM for the MLIR part. Please seek approval from relevant reviewers for all 
other subprojects.

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


[Lldb-commits] [lldb] [llvm] [lldb] Refactor string manipulation in Debugger.cpp (#91209) (PR #91880)

2024-05-12 Thread Youngsuk Kim via lldb-commits

https://github.com/JOE1994 closed 
https://github.com/llvm/llvm-project/pull/91880
___
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


[Lldb-commits] [lldb] [llvm] [lldb] Refactor string manipulation in Debugger.cpp (#91209) (PR #91880)

2024-05-12 Thread Youngsuk Kim via lldb-commits

JOE1994 wrote:

A new user already asked to be assigned to work on #91209 2 days ago in the 
comments.
**I think that user deserves an opportunity to work on the issue**.

Next time when you see a **"good first issue"** which a new user had already 
asked to get assigned to,
please assign it to the new user.

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


[Lldb-commits] [lldb] [lldb] Fix redundant condition in Target.cpp (PR #91882)

2024-05-12 Thread via lldb-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff 63224d717108d927e998da8a67050a6cc5dd74a2 
9b4160975efe059f39a842689b1f750a10453203 -- lldb/source/Target/Target.cpp
``





View the diff from clang-format here.


``diff
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index fe87728a33..afc9506d3d 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -841,14 +841,14 @@ static bool CheckIfWatchpointsSupported(Target *target, 
Status ) {
   if (!num_supported_hardware_watchpoints)
 return true;
 
-  // If num_supported_hardware_watchpoints is zero, set an 
-  //error message and return false.
+  // If num_supported_hardware_watchpoints is zero, set an
+  // error message and return false.
 
   error.SetErrorStringWithFormat(
   "Target supports (%u) hardware watchpoint slots.\n",
   *num_supported_hardware_watchpoints);
   return false;
-  
+
   return true;
 }
 

``




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


[Lldb-commits] [lldb] [lldb] Fix redundant condition in Target.cpp (PR #91882)

2024-05-12 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-lldb

Author: None (aabhinavg)


Changes

This commit addresses issue #87244, where a redundant condition was 
found in the Target.cpp file. Static analyzer cppcheck flagged the issue in the 
Target.cpp file
fix #87244 

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


1 Files Affected:

- (modified) lldb/source/Target/Target.cpp (+8-6) 


``diff
diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 82f3040e539a3..fe87728a33dc8 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -841,12 +841,14 @@ static bool CheckIfWatchpointsSupported(Target *target, 
Status ) {
   if (!num_supported_hardware_watchpoints)
 return true;
 
-  if (num_supported_hardware_watchpoints == 0) {
-error.SetErrorStringWithFormat(
-"Target supports (%u) hardware watchpoint slots.\n",
-*num_supported_hardware_watchpoints);
-return false;
-  }
+  // If num_supported_hardware_watchpoints is zero, set an 
+  //error message and return false.
+
+  error.SetErrorStringWithFormat(
+  "Target supports (%u) hardware watchpoint slots.\n",
+  *num_supported_hardware_watchpoints);
+  return false;
+  
   return true;
 }
 

``




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


[Lldb-commits] [lldb] [lldb] Fix redundant condition in Target.cpp (PR #91882)

2024-05-12 Thread via lldb-commits

https://github.com/aabhinavg created 
https://github.com/llvm/llvm-project/pull/91882

This commit addresses issue #87244, where a redundant condition was found in 
the Target.cpp file. Static analyzer cppcheck flagged the issue in the 
Target.cpp file
fix #87244 

>From 9b4160975efe059f39a842689b1f750a10453203 Mon Sep 17 00:00:00 2001
From: aabhinavg 
Date: Sun, 12 May 2024 12:42:59 +0530
Subject: [PATCH] Fix redundant condition in Target.cpp

This commit addresses issue #87244, where a redundant condition was found in 
the Target.cpp file.
Static analyzer cppcheck flagged the issue in the Target.cpp file
---
 lldb/source/Target/Target.cpp | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp
index 82f3040e539a3..fe87728a33dc8 100644
--- a/lldb/source/Target/Target.cpp
+++ b/lldb/source/Target/Target.cpp
@@ -841,12 +841,14 @@ static bool CheckIfWatchpointsSupported(Target *target, 
Status ) {
   if (!num_supported_hardware_watchpoints)
 return true;
 
-  if (num_supported_hardware_watchpoints == 0) {
-error.SetErrorStringWithFormat(
-"Target supports (%u) hardware watchpoint slots.\n",
-*num_supported_hardware_watchpoints);
-return false;
-  }
+  // If num_supported_hardware_watchpoints is zero, set an 
+  //error message and return false.
+
+  error.SetErrorStringWithFormat(
+  "Target supports (%u) hardware watchpoint slots.\n",
+  *num_supported_hardware_watchpoints);
+  return false;
+  
   return true;
 }
 

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


[Lldb-commits] [lldb] [llvm] [lldb] Refactor string manipulation in Debugger.cpp (#91209) (PR #91880)

2024-05-12 Thread via lldb-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-x86

Author: None (aabhinavg)


Changes

Author: aabhinavg tiwariabhinavak@gmail.com
Date: Sun May 12 12:46:54 2024 +0800
Reviewers: @JOE1994, @chelcassanova, @dcb314

Fixes: #91209

Summary of Changes:
- Replaced the ineffective call to 'substr' with a more efficient use of 
'resize' to truncate the string.
- Adjusted the code to use 'resize' instead of 'substr' for better performance 
and readability.

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


3 Files Affected:

- (modified) lldb/source/Core/Debugger.cpp (+1-1) 
- (modified) llvm/lib/Target/X86/X86ISelDAGToDAG.cpp (+18-6) 
- (modified) llvm/test/CodeGen/X86/cmp.ll (+15-32) 


``diff
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 9951fbcd3e7c3..70303173925e3 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -2067,7 +2067,7 @@ void Debugger::HandleProgressEvent(const lldb::EventSP 
_sp) {
   const uint32_t term_width = GetTerminalWidth();
   const uint32_t ellipsis = 3;
   if (message.size() + ellipsis >= term_width)
-message = message.substr(0, term_width - ellipsis);
+message.resize(message.size() - ellipsis);
 
   const bool use_color = GetUseColor();
   llvm::StringRef ansi_prefix = GetShowProgressAnsiPrefix();
diff --git a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp 
b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
index 14c62893766ad..ea3b84d0ca9eb 100644
--- a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
+++ b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
@@ -1560,7 +1560,9 @@ void X86DAGToDAGISel::PostprocessISelDAG() {
   SDValue And = N->getOperand(0);
   unsigned N0Opc = And.getMachineOpcode();
   if ((N0Opc == X86::AND8rr || N0Opc == X86::AND16rr ||
-   N0Opc == X86::AND32rr || N0Opc == X86::AND64rr) &&
+   N0Opc == X86::AND32rr || N0Opc == X86::AND64rr ||
+   N0Opc == X86::AND8rr_ND || N0Opc == X86::AND16rr_ND ||
+   N0Opc == X86::AND32rr_ND || N0Opc == X86::AND64rr_ND) &&
   !And->hasAnyUseOfValue(1)) {
 MachineSDNode *Test = CurDAG->getMachineNode(Opc, SDLoc(N),
  MVT::i32,
@@ -1571,15 +1573,25 @@ void X86DAGToDAGISel::PostprocessISelDAG() {
 continue;
   }
   if ((N0Opc == X86::AND8rm || N0Opc == X86::AND16rm ||
-   N0Opc == X86::AND32rm || N0Opc == X86::AND64rm) &&
+   N0Opc == X86::AND32rm || N0Opc == X86::AND64rm ||
+   N0Opc == X86::AND8rm_ND || N0Opc == X86::AND16rm_ND ||
+   N0Opc == X86::AND32rm_ND || N0Opc == X86::AND64rm_ND) &&
   !And->hasAnyUseOfValue(1)) {
 unsigned NewOpc;
+#define CASE_ND(OP)
\
+  case X86::OP:
\
+  case X86::OP##_ND:
+#define FROM_TO(A, B)  
\
+  CASE_ND(A) NewOpc = X86::B;  
\
+  break;
 switch (N0Opc) {
-case X86::AND8rm:  NewOpc = X86::TEST8mr; break;
-case X86::AND16rm: NewOpc = X86::TEST16mr; break;
-case X86::AND32rm: NewOpc = X86::TEST32mr; break;
-case X86::AND64rm: NewOpc = X86::TEST64mr; break;
+  FROM_TO(AND8rm, TEST8mr);
+  FROM_TO(AND16rm, TEST16mr);
+  FROM_TO(AND32rm, TEST32mr);
+  FROM_TO(AND64rm, TEST64mr);
 }
+#undef FROM_TO
+#undef CASE_ND
 
 // Need to swap the memory and register operand.
 SDValue Ops[] = { And.getOperand(1),
diff --git a/llvm/test/CodeGen/X86/cmp.ll b/llvm/test/CodeGen/X86/cmp.ll
index 402da547613c5..5a63d36a6be4e 100644
--- a/llvm/test/CodeGen/X86/cmp.ll
+++ b/llvm/test/CodeGen/X86/cmp.ll
@@ -787,25 +787,15 @@ define i1 @shifted_mask64_testl(i64 %a) {
 }
 
 define i1 @shifted_mask64_extra_use_const(i64 %a) {
-; NO-NDD-LABEL: shifted_mask64_extra_use_const:
-; NO-NDD:   # %bb.0:
-; NO-NDD-NEXT:movabsq $287104476244869120, %rcx # encoding: 
[0x48,0xb9,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x03]
-; NO-NDD-NEXT:# imm = 0x3FC
-; NO-NDD-NEXT:testq %rcx, %rdi # encoding: [0x48,0x85,0xcf]
-; NO-NDD-NEXT:setne %al # encoding: [0x0f,0x95,0xc0]
-; NO-NDD-NEXT:movq %rcx, d64(%rip) # encoding: [0x48,0x89,0x0d,A,A,A,A]
-; NO-NDD-NEXT:# fixup A - offset: 3, value: d64-4, kind: reloc_riprel_4byte
-; NO-NDD-NEXT:retq # encoding: [0xc3]
-;
-; NDD-LABEL: shifted_mask64_extra_use_const:
-; NDD:   # %bb.0:
-; NDD-NEXT:movabsq $287104476244869120, %rcx # encoding: 
[0x48,0xb9,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x03]
-; NDD-NEXT:# imm = 0x3FC
-; NDD-NEXT:andq %rcx, %rdi, %rax # encoding: 
[0x62,0xf4,0xfc,0x18,0x21,0xcf]
-; NDD-NEXT:setne %al # encoding: [0x0f,0x95,0xc0]
-; NDD-NEXT:movq %rcx, d64(%rip) # encoding: [0x48,0x89,0x0d,A,A,A,A]
-; NDD-NEXT:# fixup A - offset: 3, value: d64-4, 

[Lldb-commits] [lldb] [llvm] [lldb] Refactor string manipulation in Debugger.cpp (#91209) (PR #91880)

2024-05-12 Thread via lldb-commits

https://github.com/aabhinavg created 
https://github.com/llvm/llvm-project/pull/91880

Author: aabhinavg 
Date: Sun May 12 12:46:54 2024 +0800
Reviewers: @JOE1994, @chelcassanova, @dcb314

Fixes: #91209

Summary of Changes:
- Replaced the ineffective call to 'substr' with a more efficient use of 
'resize' to truncate the string.
- Adjusted the code to use 'resize' instead of 'substr' for better performance 
and readability.

>From 48ebf2cf7c6ed2c477b825e531848fd3f64c5cf2 Mon Sep 17 00:00:00 2001
From: Shengchen Kan 
Date: Sun, 12 May 2024 12:46:54 +0800
Subject: [PATCH] [lldb] Refactor string manipulation in Debugger.cpp (#91209)

Author: aabhinavg 
Date: Sun May 12 12:46:54 2024 +0800
Reviewers: @JOE1994, @chelcassanova, @dcb314

Fixes: #91209

Summary of Changes:
- Replaced the ineffective call to 'substr' with a more efficient use of 
'resize' to truncate the string.
- Adjusted the code to use 'resize' instead of 'substr' for better performance 
and readability.
---
 lldb/source/Core/Debugger.cpp   |  2 +-
 llvm/lib/Target/X86/X86ISelDAGToDAG.cpp | 24 +
 llvm/test/CodeGen/X86/cmp.ll| 47 -
 3 files changed, 34 insertions(+), 39 deletions(-)

diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 9951fbcd3e7c3..70303173925e3 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -2067,7 +2067,7 @@ void Debugger::HandleProgressEvent(const lldb::EventSP 
_sp) {
   const uint32_t term_width = GetTerminalWidth();
   const uint32_t ellipsis = 3;
   if (message.size() + ellipsis >= term_width)
-message = message.substr(0, term_width - ellipsis);
+message.resize(message.size() - ellipsis);
 
   const bool use_color = GetUseColor();
   llvm::StringRef ansi_prefix = GetShowProgressAnsiPrefix();
diff --git a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp 
b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
index 14c62893766ad..ea3b84d0ca9eb 100644
--- a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
+++ b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
@@ -1560,7 +1560,9 @@ void X86DAGToDAGISel::PostprocessISelDAG() {
   SDValue And = N->getOperand(0);
   unsigned N0Opc = And.getMachineOpcode();
   if ((N0Opc == X86::AND8rr || N0Opc == X86::AND16rr ||
-   N0Opc == X86::AND32rr || N0Opc == X86::AND64rr) &&
+   N0Opc == X86::AND32rr || N0Opc == X86::AND64rr ||
+   N0Opc == X86::AND8rr_ND || N0Opc == X86::AND16rr_ND ||
+   N0Opc == X86::AND32rr_ND || N0Opc == X86::AND64rr_ND) &&
   !And->hasAnyUseOfValue(1)) {
 MachineSDNode *Test = CurDAG->getMachineNode(Opc, SDLoc(N),
  MVT::i32,
@@ -1571,15 +1573,25 @@ void X86DAGToDAGISel::PostprocessISelDAG() {
 continue;
   }
   if ((N0Opc == X86::AND8rm || N0Opc == X86::AND16rm ||
-   N0Opc == X86::AND32rm || N0Opc == X86::AND64rm) &&
+   N0Opc == X86::AND32rm || N0Opc == X86::AND64rm ||
+   N0Opc == X86::AND8rm_ND || N0Opc == X86::AND16rm_ND ||
+   N0Opc == X86::AND32rm_ND || N0Opc == X86::AND64rm_ND) &&
   !And->hasAnyUseOfValue(1)) {
 unsigned NewOpc;
+#define CASE_ND(OP)
\
+  case X86::OP:
\
+  case X86::OP##_ND:
+#define FROM_TO(A, B)  
\
+  CASE_ND(A) NewOpc = X86::B;  
\
+  break;
 switch (N0Opc) {
-case X86::AND8rm:  NewOpc = X86::TEST8mr; break;
-case X86::AND16rm: NewOpc = X86::TEST16mr; break;
-case X86::AND32rm: NewOpc = X86::TEST32mr; break;
-case X86::AND64rm: NewOpc = X86::TEST64mr; break;
+  FROM_TO(AND8rm, TEST8mr);
+  FROM_TO(AND16rm, TEST16mr);
+  FROM_TO(AND32rm, TEST32mr);
+  FROM_TO(AND64rm, TEST64mr);
 }
+#undef FROM_TO
+#undef CASE_ND
 
 // Need to swap the memory and register operand.
 SDValue Ops[] = { And.getOperand(1),
diff --git a/llvm/test/CodeGen/X86/cmp.ll b/llvm/test/CodeGen/X86/cmp.ll
index 402da547613c5..5a63d36a6be4e 100644
--- a/llvm/test/CodeGen/X86/cmp.ll
+++ b/llvm/test/CodeGen/X86/cmp.ll
@@ -787,25 +787,15 @@ define i1 @shifted_mask64_testl(i64 %a) {
 }
 
 define i1 @shifted_mask64_extra_use_const(i64 %a) {
-; NO-NDD-LABEL: shifted_mask64_extra_use_const:
-; NO-NDD:   # %bb.0:
-; NO-NDD-NEXT:movabsq $287104476244869120, %rcx # encoding: 
[0x48,0xb9,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0x03]
-; NO-NDD-NEXT:# imm = 0x3FC
-; NO-NDD-NEXT:testq %rcx, %rdi # encoding: [0x48,0x85,0xcf]
-; NO-NDD-NEXT:setne %al # encoding: [0x0f,0x95,0xc0]
-; NO-NDD-NEXT:movq %rcx, d64(%rip) # encoding: [0x48,0x89,0x0d,A,A,A,A]
-; NO-NDD-NEXT:# fixup A - offset: 3, value: d64-4, kind: reloc_riprel_4byte
-; NO-NDD-NEXT:retq # encoding: [0xc3]
-;