[clang] [clang][AArch64] Avoid a crash when a non-reserved register is used (PR #117419)
Igor Kudrin via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 25 20:57:29 PST 2024
================
@@ -232,13 +232,23 @@ bool AArch64TargetInfo::validateTarget(DiagnosticsEngine &Diags) const {
bool AArch64TargetInfo::validateGlobalRegisterVariable(
StringRef RegName, unsigned RegSize, bool &HasSizeMismatch) const {
- if ((RegName == "sp") || RegName.starts_with("x")) {
- HasSizeMismatch = RegSize != 64;
- return true;
- } else if (RegName.starts_with("w")) {
+ if (RegName.starts_with("w")) {
HasSizeMismatch = RegSize != 32;
return true;
}
+ if (RegName == "sp") {
+ HasSizeMismatch = RegSize != 64;
+ return true;
+ }
+ if (RegName.starts_with("x")) {
+ HasSizeMismatch = RegSize != 64;
+ // Check if the register is reserved. See also
+ // AArch64TargetLowering::getRegisterByName().
+ return RegName == "x0" ||
----------------
igorkudrin wrote:
Done
https://github.com/llvm/llvm-project/pull/117419
More information about the cfe-commits
mailing list