Skip to content

Replace ArchSpec::PiecewiseCompare() with Triple::operator==() #82804

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions lldb/include/lldb/Utility/ArchSpec.h
Original file line number Diff line number Diff line change
Expand Up @@ -505,11 +505,6 @@ class ArchSpec {

bool IsFullySpecifiedTriple() const;

void PiecewiseTripleCompare(const ArchSpec &other, bool &arch_different,
bool &vendor_different, bool &os_different,
bool &os_version_different,
bool &env_different) const;

/// Detect whether this architecture uses thumb code exclusively
///
/// Some embedded ARM chips (e.g. the ARM Cortex M0-7 line) can only execute
Expand Down
8 changes: 1 addition & 7 deletions lldb/source/Target/Target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1568,14 +1568,8 @@ bool Target::SetArchitecture(const ArchSpec &arch_spec, bool set_platform,

if (m_arch.GetSpec().IsCompatibleMatch(other)) {
compatible_local_arch = true;
bool arch_changed, vendor_changed, os_changed, os_ver_changed,
env_changed;

m_arch.GetSpec().PiecewiseTripleCompare(other, arch_changed,
vendor_changed, os_changed,
os_ver_changed, env_changed);

if (!arch_changed && !vendor_changed && !os_changed && !env_changed)
if (m_arch.GetSpec().GetTriple() == other.GetTriple())
replace_local_arch = false;
}
}
Expand Down
17 changes: 0 additions & 17 deletions lldb/source/Utility/ArchSpec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1421,23 +1421,6 @@ bool ArchSpec::IsFullySpecifiedTriple() const {
return true;
}

void ArchSpec::PiecewiseTripleCompare(
const ArchSpec &other, bool &arch_different, bool &vendor_different,
bool &os_different, bool &os_version_different, bool &env_different) const {
const llvm::Triple &me(GetTriple());
const llvm::Triple &them(other.GetTriple());

arch_different = (me.getArch() != them.getArch());

vendor_different = (me.getVendor() != them.getVendor());

os_different = (me.getOS() != them.getOS());

os_version_different = (me.getOSMajorVersion() != them.getOSMajorVersion());

env_different = (me.getEnvironment() != them.getEnvironment());
}

bool ArchSpec::IsAlwaysThumbInstructions() const {
std::string Status;
if (GetTriple().getArch() == llvm::Triple::arm ||
Expand Down
2 changes: 2 additions & 0 deletions lldb/test/API/macosx/arm64e-attach/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
C_SOURCES := main.c
include Makefile.rules
Comment on lines +1 to +2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you want to build this test for arm64e?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is implicit. If you are running the tests with an arm64e ARCH, the test will run (with that triple).

28 changes: 28 additions & 0 deletions lldb/test/API/macosx/arm64e-attach/TestArm64eAttach.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil


class TestArm64eAttach(TestBase):
NO_DEBUG_INFO_TESTCASE = True

# On Darwin systems, arch arm64e means ARMv8.3 with ptrauth ABI used.
@skipIf(archs=no_match(["arm64e"]))
def test(self):
# Skip this test if not running on AArch64 target that supports PAC
if not self.isAArch64PAuth():
self.skipTest("Target must support pointer authentication.")
self.build()
popen = self.spawnSubprocess(self.getBuildArtifact(), [])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To run arm64e code you need to set a -arm64e_preview_abi boot arg. I'd be surprised if the bots have that set. You'll probably want to skip this test when this fails to launch.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bots will already fail at the archs=no_match(["arm64e"] decorator.

error = lldb.SBError()
# This simulates how Xcode attaches to a process by pid/name.
target = self.dbg.CreateTarget("", "arm64", "", True, error)
listener = lldb.SBListener("my.attach.listener")
process = target.AttachToProcessWithID(listener, popen.pid, error)
self.assertSuccess(error)
self.assertTrue(process, PROCESS_IS_VALID)
self.assertEqual(target.GetTriple().split('-')[0], "arm64e",
"target triple is updated correctly")
error = process.Kill()
self.assertSuccess(error)
2 changes: 2 additions & 0 deletions lldb/test/API/macosx/arm64e-attach/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
int getchar();
int main() { return getchar(); }