[Bug target/85927] ud2 instruction generated starting with gcc 8

ndesaulniers at google dot com gcc-bugzilla@gcc.gnu.org
Fri May 25 20:38:00 GMT 2018


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85927

--- Comment #2 from Nick Desaulniers <ndesaulniers at google dot com> ---
Sorry, probably:

__attribute__((naked))
unsigned long save_flags4(void) {
    asm volatile("pushf; pop %rax;ret;");
}

is a better example:

0000000000000000 <save_flags4>:
   0:   9c                      pushfq 
   1:   58                      pop    %rax
   2:   c3                      retq   
   3:   0f 0b                   ud2 

(gcc-7 replaces ud2 with another ret, but I guess both should work in
practice).


More information about the Gcc-bugs mailing list