Skip to content

Commit 8becb1b

Browse files
committed
[ARM64] Fix lifting of mrs xzr, ... to not reference the xzr register
ARM64 lifting replaces references to the zero register with constant zeroes. The zero register is not intended to appear in any lifted IL. In the case of the `mrs` instruction, the destination being a zero register means the system register is accessed only for a side-effect, and is not stored anywhere. The lifting is updated to specify no output registers for the intrinsic in that case.
1 parent 31eea4e commit 8becb1b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

arch/arm64/il.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2803,8 +2803,13 @@ bool GetLowLevelILForInstruction(
28032803
operand2.implspec[3], operand2.implspec[4]);
28042804
}
28052805

2806-
il.AddInstruction(
2807-
il.Intrinsic({RegisterOrFlag::Register(REG_O(operand1))}, ARM64_INTRIN_MRS, {il.Const(4, reg)}));
2806+
if (IS_ZERO_REG(REG_O(operand1))) {
2807+
il.AddInstruction(
2808+
il.Intrinsic({}, ARM64_INTRIN_MRS, {il.Const(4, reg)}));
2809+
} else {
2810+
il.AddInstruction(
2811+
il.Intrinsic({RegisterOrFlag::Register(REG_O(operand1))}, ARM64_INTRIN_MRS, {il.Const(4, reg)}));
2812+
}
28082813
break;
28092814
}
28102815
case ARM64_MSUB:

0 commit comments

Comments
 (0)