-
Notifications
You must be signed in to change notification settings - Fork 14.2k
[llvm-exegesis][AArch64] Disable pauth and ldgm as unsupported instructions #132346
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
madhur13490
merged 11 commits into
llvm:main
from
lakshayk-nv:llvm-exegesis-illegal-instr
Apr 9, 2025
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f1e1d7a
[llvm-exegesis] [AArch64] Resolving Illegal Instruction Error
lakshayk-nv 5039c2b
[llvm-exegesis] [AArch64] Use enum values for opcode validation
lakshayk-nv 6b81e65
[llvm-exegesis][AArch64] Disable pauth and ldgm as unsupported instru…
lakshayk-nv bef8e21
Merge branch 'main' of https://github.com/llvm/llvm-project into llvm…
lakshayk-nv dade502
[llvm-exegesis][AArch64] Formatting changes
lakshayk-nv b6ce448
[llvm-exegesis] Add Linux PR_PAC_* constants and update opcode handling
lakshayk-nv 783f86d
[llvm-exegesis][AArch64] Updated the testcase for AUT instruction class.
lakshayk-nv 70eb3bf
[llvm-exegesis][AArch64] Refactor opcode handling for pointer authent…
lakshayk-nv a1fedb4
[llvm-exegesis][AArch64] Enhance pointer authentication handling for …
lakshayk-nv 06fbe30
Revert "[llvm-exegesis][AArch64] Formatting changes"
lakshayk-nv 3af87a0
[llvm-exegesis][AArch64] Revert back unnecessary unfolded error and f…
lakshayk-nv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
llvm/test/tools/llvm-exegesis/AArch64/skip_unsupported_instructions.s
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# REQUIRES: aarch64-registered-target | ||
|
||
# Check for skipping of illegal instruction errors (AUT and LDGM) | ||
# RUN: llvm-exegesis -mcpu=neoverse-v2 -mode=latency --opcode-name=AUTIA --benchmark-phase=assemble-measured-code 2>&1 | FileCheck %s --check-prefix=CHECK-AUTIA | ||
# CHECK-AUTIA-NOT: snippet crashed while running: Illegal instruction | ||
|
||
# RUN: llvm-exegesis -mcpu=neoverse-v2 -mode=latency --opcode-name=LDGM --benchmark-phase=assemble-measured-code 2>&1 | FileCheck %s --check-prefix=CHECK-LDGM | ||
# CHECK-LDGM: LDGM: Unsupported opcode: load tag multiple |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,12 +9,58 @@ | |
#include "AArch64.h" | ||
#include "AArch64RegisterInfo.h" | ||
|
||
#ifdef __linux__ | ||
#include <linux/prctl.h> // For PR_PAC_* constants | ||
#include <sys/prctl.h> | ||
#endif | ||
|
||
#define GET_AVAILABLE_OPCODE_CHECKER | ||
#include "AArch64GenInstrInfo.inc" | ||
|
||
namespace llvm { | ||
namespace exegesis { | ||
|
||
bool isPointerAuth(unsigned Opcode) { | ||
switch (Opcode) { | ||
default: | ||
return false; | ||
|
||
// FIXME: Pointer Authentication instructions. | ||
// We would like to measure these instructions, but they can behave | ||
// differently on different platforms, and maybe the snippets need to look | ||
// different for these instructions, | ||
// Platform-specific handling: On Linux, we disable authentication, may | ||
// interfere with measurements. On non-Linux platforms, disable opcodes for | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a note: Exegesis doesn't really support benchmarking on non-Linux platforms. |
||
// now. | ||
case AArch64::AUTDA: | ||
case AArch64::AUTDB: | ||
case AArch64::AUTDZA: | ||
case AArch64::AUTDZB: | ||
case AArch64::AUTIA: | ||
case AArch64::AUTIA1716: | ||
case AArch64::AUTIASP: | ||
case AArch64::AUTIAZ: | ||
case AArch64::AUTIB: | ||
case AArch64::AUTIB1716: | ||
case AArch64::AUTIBSP: | ||
case AArch64::AUTIBZ: | ||
case AArch64::AUTIZA: | ||
case AArch64::AUTIZB: | ||
return true; | ||
} | ||
} | ||
|
||
bool isLoadTagMultiple(unsigned Opcode) { | ||
switch (Opcode) { | ||
default: | ||
return false; | ||
|
||
// Load tag multiple instruction | ||
case AArch64::LDGM: | ||
return true; | ||
} | ||
} | ||
|
||
static unsigned getLoadImmediateOpcode(unsigned RegBitWidth) { | ||
switch (RegBitWidth) { | ||
case 32: | ||
|
@@ -134,6 +180,35 @@ class ExegesisAArch64Target : public ExegesisTarget { | |
// Function return is a pseudo-instruction that needs to be expanded | ||
PM.add(createAArch64ExpandPseudoPass()); | ||
} | ||
|
||
const char *getIgnoredOpcodeReasonOrNull(const LLVMState &State, | ||
unsigned Opcode) const override { | ||
if (const char *Reason = | ||
ExegesisTarget::getIgnoredOpcodeReasonOrNull(State, Opcode)) | ||
return Reason; | ||
|
||
if (isPointerAuth(Opcode)) { | ||
#ifdef __linux__ | ||
// Disable all PAC keys. Note that while we expect the measurements to | ||
// be the same with PAC keys disabled, they could potentially be lower | ||
// since authentication checks are bypassed. | ||
if (prctl(PR_PAC_SET_ENABLED_KEYS, | ||
PR_PAC_APIAKEY | PR_PAC_APIBKEY | PR_PAC_APDAKEY | | ||
PR_PAC_APDBKEY, // all keys | ||
0, // disable all | ||
0, 0) < 0) { | ||
return "Failed to disable PAC keys"; | ||
} | ||
#else | ||
return "Unsupported opcode: isPointerAuth"; | ||
#endif | ||
} | ||
|
||
if (isLoadTagMultiple(Opcode)) | ||
return "Unsupported opcode: load tag multiple"; | ||
|
||
return nullptr; | ||
} | ||
}; | ||
|
||
} // namespace | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.