Skip to content

__builtin_ia32_readeflags_u64() unnecessarily forces a frame pointer #46875

@llvmbot

Description

@llvmbot
Bugzilla Link 47531
Version trunk
OS Linux
Blocks #4440
Reporter LLVM Bugzilla Contributor
CC @topperc,@majnemer,@RKSimon,@nickdesaulniers,@zygoloid,@rnk,@rotateright,@tstellar

Extended Description

This code:

unsigned long read_eflags(void)
{
   return __builtin_ia32_readeflags_u64();
}

compiles to:

read_eflags:
        pushq   %rbp
        movq    %rsp, %rbp
        pushfq
        popq    %rax
        popq    %rbp
        retq

which has an unnecessary frame pointer. (I'm somewhat puzzled as to why this happened. Sure, the redzone slot clobbered by the pushfq can't be used, but I don't see what this has to do with a frame pointer.)

gcc generates:

read_eflags:
        pushfq
        popq    %rax
        ret

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions