aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCWin64EH.cpp
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2022-08-08 12:34:29 +0300
committerMartin Storsjö <martin@martin.st>2022-08-08 23:03:17 +0300
commit0c52ab39688e8e107487b8cee00f509fe092f40a (patch)
tree4e77b08b4f4ed9bf23551bd2d9a7066b43be043d /llvm/lib/MC/MCWin64EH.cpp
parentf181dff0846c2236f72e3f13a819bb0c968ccfb8 (diff)
downloadllvm-0c52ab39688e8e107487b8cee00f509fe092f40a.zip
llvm-0c52ab39688e8e107487b8cee00f509fe092f40a.tar.gz
llvm-0c52ab39688e8e107487b8cee00f509fe092f40a.tar.bz2
[MC] [Win64EH] Fix the calculation of the end of epilogs
Exclude the terminating end opcode from the epilog - it doesn't correspond to an actual instruction that is included in the epilog itself (within the .seh_startepilogue/.seh_endepilogue range). In most (all?) cases, an epilog is followed by a matching terminating instruction though (a ret or a branch to a tail call), but it's not strictly within the .seh_startepilogue/.seh_endepilogue range. This fixes a number of failed asserts in cases where the codegen has incorrectly reoredered SEH opcodes so they don't match up exactly with their instructions. However this still just avoids failing the assertion; the root cause of generating unexpected epilogs is still present (and fixing that is a less obvious issue). Differential Revision: https://reviews.llvm.org/D131393
Diffstat (limited to 'llvm/lib/MC/MCWin64EH.cpp')
-rw-r--r--llvm/lib/MC/MCWin64EH.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/MC/MCWin64EH.cpp b/llvm/lib/MC/MCWin64EH.cpp
index 8f53ab1..ff1c1ad 100644
--- a/llvm/lib/MC/MCWin64EH.cpp
+++ b/llvm/lib/MC/MCWin64EH.cpp
@@ -997,7 +997,9 @@ static void ARM64FindSegmentsInFunction(MCStreamer &streamer,
int64_t Offset = GetAbsDifference(streamer, Start, info->Begin);
assert((Epilogs.size() == 0 || Offset >= Epilogs.back().End) &&
"Epilogs should be monotonically ordered");
- Epilogs.push_back({Start, Offset, Offset + (int64_t)Instrs.size() * 4});
+ // Exclue the end opcode from Instrs.size() when calculating the end of the
+ // epilog.
+ Epilogs.push_back({Start, Offset, Offset + (int64_t)(Instrs.size() - 1) * 4});
}
unsigned E = 0;