Trunk compiler cycle failure for x86_64-linux with -O3 option
<!-- See available text formatting: https://gitlab.com/help/user/markdown.md --> ## Summary <!-- Summarize the bug encountered concisely --> Current trunk cannot be compiled with `-O3` in `OPT` make variable. ## System Information <!-- The more information are provided the easier it is to replicate the bug --> - **Operating system:** linux (probably also others)<!-- Windows, Linux (if possible, also name the distro), FreeBSD, Android, ... --> - **Processor architecture:** x86_64<!-- x86, x86-64, ARM, AARCH64, AVR, RISC-V, PowerPC, ... --> - **Compiler version:** trunk at f724b49d1fcf<!-- 3.2, 3.2.2, 3.3, trunk, beta, ... (if possible, give also the git hash) --> ## Steps to reproduce <!-- How one can reproduce the issue - this is very important! --> Start with release compiler. ``` muller@cfarm70:~/pas/trunk/fpcsrc/rtl/linux$ ppcx64 -iVDW 3.2.2 2021/05/16 3.2.2 ``` Run this command: ``` make cycle OPT="-n -gwl -CriotR" OPTNEW="-n -gwl -CriotR -O3" ``` leads to: ``` make[6]: Leaving directory '/home/muller/pas/gitlab-fpc-source/rtl/linux' as --64 -o ../../rtl/units/x86_64-linux/abitag.o x86_64/abitag.as /home/muller/pas/gitlab-fpc-source/compiler/ppc2 -Fi../inc -Fi../x86_64 -Fi../unix -Fix86_64 -FE. -FU../../rtl/units/x86_64-linux -Cg -Fl/usr/lib/gcc/x86_64-linux-gnu/6 -n -gwl -CriotR -n -gwl -CriotR -O3 -DD2026/04/28 -dx86_64 -Us -Sg system.pp Error: Compilation raised exception internally An unhandled exception occurred at $0000000000412035: EObjectCheck: Object reference is Nil or VMT is damaged $0000000000412035 fpc_do_as, line 71 of ../inc/objpas.inc ``` ## Example Project <!-- If possible, please create an example project that exhibits the problematic behavior, and link to it here in the bug report. --> ## What is the current bug behavior? <!-- What actually happens --> ## What is the expected (correct) behavior? <!-- What you should see instead --> ## Relevant logs and/or screenshots <!-- Paste any relevant logs - please use code blocks (```) to format console output, logs, and code --> ## Possible fixes <!-- If you can, link to the line of code that might be responsible for the problem --> Patch suggested by @_alligator_ in #41743 ``` diff --git a/compiler/x86/aoptx86.pas b/compiler/x86/aoptx86.pas index ff454ba945..a668ff71b1 100644 --- a/compiler/x86/aoptx86.pas +++ b/compiler/x86/aoptx86.pas @@ -6371,6 +6371,7 @@ TJumpTrackingItem = class(TLinkedListItem) ) and { Make sure the destination operands are actually the same } MatchOperand(taicpu(p_dist).oper[1]^, taicpu(p).oper[1]^) and + (taicpu(p_dist).opsize = taicpu(p).opsize) and GetNextInstruction(p_dist, hp1_dist) and MatchInstruction(hp1_dist, A_JCC, []) then begin ``` seems to be insufficient to allow successful cycling...
issue