diff --git a/Research/Borland C++ decompilation.md b/Research/Borland C++ decompilation.md index dd64ea9a..4483323e 100644 --- a/Research/Borland C++ decompilation.md +++ b/Research/Borland C++ decompilation.md @@ -429,10 +429,6 @@ foo_c(100, 200); // PUSH 200; PUSH 100 ### `-O` (Optimize jumps) -Also merges individual `ADD SP, imm8` or `POP CX` stack-clearing instructions -after `__cdecl` function calls into a single one with their combined parameter -size. - Inhibited by: * identical variable declarations within more than one scope – the @@ -459,6 +455,24 @@ Inhibited by: * inlined calls to empty functions +`-O` also merges individual `ADD SP, imm8` or `POP CX` stack-clearing +instructions after `__cdecl` function calls into a single one with their +combined parameter size. + +* **[Bug:]** Any emitted call to `SCOPY@` will disable this feature of `-O` for + all generated code in a translation unit that follows the `SCOPY@` call. + + This can explain why a function might seem impossible to decompile with the + wrong translation unit layout. If it + + * *doesn't* contain the stack-clearing optimization, + * but *does* definitely contain optimized jumps, + * which couldn't be reproduced with the slight jump optimization provided by + `-O- -y`, + + the translation unit is simply missing a `SCOPY@` before the function in + question. + ### `-y` (Produce line number info) Provides its own kind of slight jump optimization if combined with `-O-`. Yes, @@ -650,3 +664,11 @@ contains one of the following: **Workaround**: Not happening when compiling via TASM (`-B` on the command line, or `#pragma inline`). + +* Any emitted call to `SCOPY@` will disable the stack cleanup optimization + generated by [`-O`](#-o-optimize-jumps) for all generated code in a + translation unit that follows the `SCOPY@` call. + +---- + +[Bug:]: #compiler-bugs