[llvm-branch-commits] [llvm] [ARM][Thumb1] Verify EstimateFunctionSizeInBytes every time (PR #203319)
Peter Smith via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Jun 12 07:58:56 PDT 2026
================
@@ -511,6 +511,36 @@ bool ARMConstantIslands::runOnMachineFunction(MachineFunction &mf) {
LLVM_DEBUG(dbgs() << '\n'; dumpBBs());
+ if (auto Estimate = AFI->getEstimatedFunctionSizeInBytes()) {
+ auto RealSize = BBUtils->getFunctionSize();
+ if (RealSize > *Estimate) {
+ LLVM_DEBUG({
+ dbgs() << "ARMConstantIslandsPass output for " << mf.getName()
+ << " with sizes:\n";
+ for (MachineBasicBlock &MBB : mf) {
+ unsigned Offset = BBUtils->getOffsetOf(&MBB);
+ unsigned End = BBUtils->getBBInfo()[MBB.getNumber()].postOffset();
+ dbgs() << printMBBReference(MBB) << ": // offset "
+ << Twine::utohexstr(Offset) << "\n";
+ for (MachineInstr &MI : MBB) {
+ unsigned InstSize = TII->getInstSizeInBytes(MI);
+ LLVM_DEBUG(dbgs() << " 0x" << Twine::utohexstr(Offset) << " +"
+ << InstSize << ": " << MI);
+ Offset += InstSize;
+ }
+ if (Offset < End) {
+ LLVM_DEBUG(dbgs() << " 0x" << Twine::utohexstr(Offset) << " +"
+ << (End - Offset) << ": extra\n");
+ }
+ }
+ });
+ report_fatal_error(
----------------
smithp35 wrote:
Would a `-mllvm` level command-line option to disable this error be worthwhile? I'm thinking that we may be unconditionally breaking programs that while their size is underestimated, currently compile successfully.
The other thing we could do is make it a warning, which would be irritating enough to report the problem, but would allow the program to build.
https://github.com/llvm/llvm-project/pull/203319
More information about the llvm-branch-commits
mailing list