From ea7df9b296616de7e6302c2c636b90bc371b43f9 Mon Sep 17 00:00:00 2001 From: Lucas Steuernagel Date: Mon, 16 Jun 2025 18:22:58 -0300 Subject: [PATCH 1/3] Do not add a return after a JA --- llvm/lib/Target/SBF/SBFMIPeephole.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/lib/Target/SBF/SBFMIPeephole.cpp b/llvm/lib/Target/SBF/SBFMIPeephole.cpp index 3bc3f70d958d6..8d39657df2d27 100644 --- a/llvm/lib/Target/SBF/SBFMIPeephole.cpp +++ b/llvm/lib/Target/SBF/SBFMIPeephole.cpp @@ -200,7 +200,7 @@ bool SBFMIPreEmitPeephole::addReturn() { MachineInstr &MI = MBB.back(); unsigned Opcode = MI.getOpcode(); - if (Opcode != SBF::RETURN_v3) { + if (Opcode != SBF::RETURN_v3 && Opcode != SBF::JMP) { BuildMI(&MBB, MI.getDebugLoc(), TII->get(SBF::RETURN_v3)); Added = true; } From eeb96cc4ca1254008f990d7e5f3a7f5c4fd7e8c0 Mon Sep 17 00:00:00 2001 From: Lucas Steuernagel Date: Tue, 17 Jun 2025 13:29:13 -0300 Subject: [PATCH 2/3] Update runner to windows 2022 --- .github/workflows/llvm-project-tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/llvm-project-tests.yml b/.github/workflows/llvm-project-tests.yml index 92b04345123b8..592e76e339629 100644 --- a/.github/workflows/llvm-project-tests.yml +++ b/.github/workflows/llvm-project-tests.yml @@ -44,7 +44,7 @@ on: # to install a python version linked against a newer version of glibc. # TODO(boomanaiden154): Bump the Ubuntu version once the version in the # container is bumped. - default: '["ubuntu-22.04", "windows-2019", "macOS-13"]' + default: '["ubuntu-22.04", "windows-2022", "macOS-13"]' python_version: required: false @@ -74,7 +74,7 @@ jobs: - ubuntu-22.04 # Use windows-2019 due to: # https://developercommunity.visualstudio.com/t/Prev-Issue---with-__assume-isnan-/1597317 - - windows-2019 + - windows-2022 # We're using a specific version of macOS due to: # https://github.com/actions/virtual-environments/issues/5900 - macOS-latest From 3f03d4a7a6ff091ee6a1c0f93cbcfdf300623365 Mon Sep 17 00:00:00 2001 From: Lucas Steuernagel Date: Fri, 20 Jun 2025 20:14:00 -0300 Subject: [PATCH 3/3] Do not iterate over all blocks --- llvm/lib/Target/SBF/SBFMIPeephole.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/llvm/lib/Target/SBF/SBFMIPeephole.cpp b/llvm/lib/Target/SBF/SBFMIPeephole.cpp index 8d39657df2d27..d09df5513b254 100644 --- a/llvm/lib/Target/SBF/SBFMIPeephole.cpp +++ b/llvm/lib/Target/SBF/SBFMIPeephole.cpp @@ -187,23 +187,21 @@ bool SBFMIPreEmitPeephole::addReturn() { // // Although we can change ISelLowering and manually add the return for an // LLVM-IR unreachable instruction, LLVM codegen uses the target machine's - // return instruction to determine whether a function needs an epilogue, - // increasing code size more, even when we know the call won't transfer - // control back to the caller. + // return instruction to determine whether a function needs an epilogue. + // This setting increases code size, even when we know the call won't + // trasnfer control back to the caller. // // In that case, we can analyze every function before emitting machine code // and include a useless return instruction. - for (MachineBasicBlock &MBB: *MF) { - if (!MBB.succ_empty() || MBB.empty()) - continue; - - MachineInstr &MI = MBB.back(); - unsigned Opcode = MI.getOpcode(); - if (Opcode != SBF::RETURN_v3 && Opcode != SBF::JMP) { - BuildMI(&MBB, MI.getDebugLoc(), TII->get(SBF::RETURN_v3)); - Added = true; - } + // PreEmitPeephole happens after block placement, so the last block in + // the ELF layout is also the last one in MF. + MachineBasicBlock &MBB = MF->back(); + MachineInstr &MI = MBB.back(); + unsigned Opcode = MI.getOpcode(); + if (Opcode != SBF::RETURN_v3 && Opcode != SBF::JMP) { + BuildMI(&MBB, MI.getDebugLoc(), TII->get(SBF::RETURN_v3)); + Added = true; } return Added;