Skip to content

Commit 20ded7c

Browse files
committed
[SOL] Do not add a return after a JA (#155)
* Do not add a return after a JA * Update runner to windows 2022 * Do not iterate over all blocks
1 parent 83cbab2 commit 20ded7c

File tree

2 files changed

+13
-15
lines changed

2 files changed

+13
-15
lines changed

.github/workflows/llvm-project-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ on:
4444
# to install a python version linked against a newer version of glibc.
4545
# TODO(boomanaiden154): Bump the Ubuntu version once the version in the
4646
# container is bumped.
47-
default: '["ubuntu-22.04", "windows-2019", "macOS-13"]'
47+
default: '["ubuntu-22.04", "windows-2022", "macOS-13"]'
4848

4949
python_version:
5050
required: false
@@ -74,7 +74,7 @@ jobs:
7474
- ubuntu-22.04
7575
# Use windows-2019 due to:
7676
# https://developercommunity.visualstudio.com/t/Prev-Issue---with-__assume-isnan-/1597317
77-
- windows-2019
77+
- windows-2022
7878
# We're using a specific version of macOS due to:
7979
# https://github.com/actions/virtual-environments/issues/5900
8080
- macOS-latest

llvm/lib/Target/SBF/SBFMIPeephole.cpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -187,23 +187,21 @@ bool SBFMIPreEmitPeephole::addReturn() {
187187
//
188188
// Although we can change ISelLowering and manually add the return for an
189189
// LLVM-IR unreachable instruction, LLVM codegen uses the target machine's
190-
// return instruction to determine whether a function needs an epilogue,
191-
// increasing code size more, even when we know the call won't transfer
192-
// control back to the caller.
190+
// return instruction to determine whether a function needs an epilogue.
191+
// This setting increases code size, even when we know the call won't
192+
// trasnfer control back to the caller.
193193
//
194194
// In that case, we can analyze every function before emitting machine code
195195
// and include a useless return instruction.
196196

197-
for (MachineBasicBlock &MBB: *MF) {
198-
if (!MBB.succ_empty() || MBB.empty())
199-
continue;
200-
201-
MachineInstr &MI = MBB.back();
202-
unsigned Opcode = MI.getOpcode();
203-
if (Opcode != SBF::RETURN_v3) {
204-
BuildMI(&MBB, MI.getDebugLoc(), TII->get(SBF::RETURN_v3));
205-
Added = true;
206-
}
197+
// PreEmitPeephole happens after block placement, so the last block in
198+
// the ELF layout is also the last one in MF.
199+
MachineBasicBlock &MBB = MF->back();
200+
MachineInstr &MI = MBB.back();
201+
unsigned Opcode = MI.getOpcode();
202+
if (Opcode != SBF::RETURN_v3 && Opcode != SBF::JMP) {
203+
BuildMI(&MBB, MI.getDebugLoc(), TII->get(SBF::RETURN_v3));
204+
Added = true;
207205
}
208206

209207
return Added;

0 commit comments

Comments
 (0)