Stop rewriting ret to repz ret on x86_64
This is an old workaround from the AMD K8 days. GCC stopped doing it for
their generic output in 2017.
https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=4ca47ced33cc0d6f9e336930d628a6fdbf22f6e2
b/65150507#comment2 says LLVM has never done it.
We can retire this now and recover a small handful of bytes.
Change-Id: I37ef47038b6b3a1a7500bcea8cbd1beefc83121c
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/63205
Auto-Submit: David Benjamin <davidben@google.com>
Commit-Queue: David Benjamin <davidben@google.com>
Reviewed-by: Bob Beck <bbe@google.com>
diff --git a/crypto/perlasm/x86_64-xlate.pl b/crypto/perlasm/x86_64-xlate.pl
index e9fc322..9fb1de1 100755
--- a/crypto/perlasm/x86_64-xlate.pl
+++ b/crypto/perlasm/x86_64-xlate.pl
@@ -47,7 +47,6 @@
# (sorry about latter).
# 6. Don't use [or hand-code with .byte] "rep ret." "ret" mnemonic is
# required to identify the spots, where to inject Win64 epilogue!
-# But on the pros, it's then prefixed with rep automatically:-)
# 7. Stick to explicit ip-relative addressing. If you have to use
# GOTPCREL addressing, stick to mov symbol@GOTPCREL(%rip),%r??.
# Both are recognized and translated to proper Win64 addressing
@@ -157,7 +156,7 @@
$epilogue = "movq 8(%rsp),%rdi\n\t" .
"movq 16(%rsp),%rsi\n\t";
}
- $epilogue . ".byte 0xf3,0xc3";
+ $epilogue . "ret";
} elsif ($self->{op} eq "call" && !$elf && $current_segment eq ".init") {
".p2align\t3\n\t.quad";
} else {
@@ -171,7 +170,7 @@
$self->{op} = "mov rdi,QWORD$PTR\[8+rsp\]\t;WIN64 epilogue\n\t".
"mov rsi,QWORD$PTR\[16+rsp\]\n\t";
}
- $self->{op} .= "DB\t0F3h,0C3h\t\t;repret";
+ $self->{op} .= "ret";
} elsif ($self->{op} =~ /^(pop|push)f/) {
$self->{op} .= $self->{sz};
} elsif ($self->{op} eq "call" && $current_segment eq ".CRT\$XCU") {