@@ -2538,6 +2538,7 @@ int main(int argc, char **argv)
25382538 options.push_back (" -Ojump-elim=0" );
25392539 options.push_back (" -Ojump-elim-size=0" );
25402540 options.push_back (" -Ojump-peephole=false" );
2541+ options.push_back (" -Ojump-peephole-2=false" );
25412542 options.push_back (" -Oorder-trampolines=false" );
25422543 options.push_back (" -Oscratch-stack=false" );
25432544 options.push_back (" --mem-granularity=64" );
@@ -2547,6 +2548,7 @@ int main(int argc, char **argv)
25472548 options.push_back (" -Ojump-elim-size=0" );
25482549 options.push_back (" -Oorder-trampolines=false" );
25492550 options.push_back (" -Ojump-peephole=true" );
2551+ options.push_back (" -Ojump-peephole-2=true" );
25502552 options.push_back (" -Oscratch-stack=true" );
25512553 options.push_back (" --mem-granularity=128" );
25522554 break ;
@@ -2555,6 +2557,7 @@ int main(int argc, char **argv)
25552557 options.push_back (" -Ojump-elim-size=64" );
25562558 options.push_back (" -Oorder-trampolines=true" );
25572559 options.push_back (" -Ojump-peephole=true" );
2560+ options.push_back (" -Ojump-peephole-2=true" );
25582561 options.push_back (" -Oscratch-stack=true" );
25592562 options.push_back (" --mem-granularity=128" );
25602563 break ;
@@ -2563,13 +2566,15 @@ int main(int argc, char **argv)
25632566 options.push_back (" -Ojump-elim-size=512" );
25642567 options.push_back (" -Oorder-trampolines=true" );
25652568 options.push_back (" -Ojump-peephole=true" );
2569+ options.push_back (" -Ojump-peephole-2=true" );
25662570 options.push_back (" -Oscratch-stack=true" );
25672571 options.push_back (" --mem-granularity=4096" );
25682572 break ;
25692573 case ' s' :
25702574 options.push_back (" -Ojump-elim=0" );
25712575 options.push_back (" -Ojump-elim-size=0" );
25722576 options.push_back (" -Ojump-peephole=true" );
2577+ options.push_back (" -Ojump-peephole-2=true" );
25732578 options.push_back (" -Oorder-trampolines=true" );
25742579 options.push_back (" -Oscratch-stack=true" );
25752580 options.push_back (" --mem-granularity=4096" );
@@ -2758,6 +2763,10 @@ int main(int argc, char **argv)
27582763 I.string .instr ,
27592764 (matched && option_is_tty? " \33 [0m" : " " ),
27602765 (matched && !option_is_tty? " (matched)" : " " ));
2766+ if (I.size >= /* sizeof(jmpq)=*/ 5 &&
2767+ ((I.category & CATEGORY_JUMP) != 0 ||
2768+ (I.category & CATEGORY_CALL) != 0 ))
2769+ Is[i].jump = true ;
27612770 }
27622771 notifyPlugins (backend.out , &elf, Is.data (), Is.size (),
27632772 EVENT_MATCHING_COMPLETE);
@@ -2768,6 +2777,18 @@ int main(int argc, char **argv)
27682777 intptr_t id = -1 ;
27692778 for (ssize_t i = (ssize_t )count - 1 ; i >= 0 ; i--)
27702779 {
2780+ switch (option_optimization_level)
2781+ {
2782+ case ' 2' : case ' 3' : case ' s' :
2783+ if (!Is[i].emitted && Is[i].jump )
2784+ {
2785+ // Always emits jump/calls for -Ojump-peephole-2
2786+ Is[i].emitted = true ;
2787+ sendInstructionMessage (backend.out , Is[i].address ,
2788+ Is[i].size , Is[i].offset );
2789+ }
2790+ break ;
2791+ }
27712792 if (!Is[i].patch )
27722793 continue ;
27732794
0 commit comments