[all-commits] [llvm/llvm-project] f65e8c: [bolt] Fix std::prev()-past-begin in veneer handli...
Nico Weber via All-commits
all-commits at lists.llvm.org
Fri Nov 18 11:42:30 PST 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: f65e8c3c519ade29139f90d235884d3ad12fae5d
https://github.com/llvm/llvm-project/commit/f65e8c3c519ade29139f90d235884d3ad12fae5d
Author: Nico Weber <thakis at chromium.org>
Date: 2022-11-18 (Fri, 18 Nov 2022)
Changed paths:
M bolt/lib/Core/BinaryContext.cpp
Log Message:
-----------
[bolt] Fix std::prev()-past-begin in veneer handling code
matchLinkerVeneer() returns 3 if `Instruction` and the last
two instructions in `[Instructions.begin, Instructions.end())`
match the pattern
ADRP x16, imm
ADD x16, x16, imm
BR x16
BinaryContext.cpp used to use
--Count;
for (auto It = std::prev(Instructions.end()); Count != 0;
It = std::prev(It), --Count) {
...use It...
}
to walk these instructions. The first `--Count` skips the
instruction that's in `Instruction` instead of in `Instructions`.
The loop then walks over `Instructions`.
However, on the last iteration, this calls `std::prev()` on an
iterator that points at the container's begin(), which can blow
up.
Instead, use rbegin(), which sidesteps this issue.
Fixes test/AArch64/veneer-gold.s on a macOS host.
With this, check-bolt passes on macOS.
Differential Revision: https://reviews.llvm.org/D138313
More information about the All-commits
mailing list