Skip to content

[Clang] Clang vs. GCC Frame Pointer Differences #108019

Open
@guoxin049

Description

@guoxin049

We used Clang 15 to build our kernel and encountered a problem during the process. I'm not sure if this is a bug or an issue with our configuration.

enum regs {
#ifdef CONFIG_THUMB2_KERNEL
	FP = 7,
#else
	FP = 11,
#endif
	SP = 13,
	LR = 14,
	PC = 15
};

When using CONFIG_THUMB2_KERNEL, the frame pointer (FP) is set to r7. However, after compiling with Clang 15 and setting the option '-mframe-chain=aapcs+leaf', the frame pointer changes to r11.

  • I noticed that this part of the llvm code caused
    MCPhysReg getFramePointerReg() const {
    if (isTargetDarwin() ||
    (!isTargetWindows() && isThumb() && !createAAPCSFrameChain()))
    return ARM::R7;
    return ARM::R11;
    }

When the -mframe-chain=aapcs+leaf option is set, the createAAPCSFrameChain() function returns true, and the getFramePointerReg() function uses ARM::R11 as the frame pointer. However, when I compile with GCC using the options -mthumb -mabi=aapcs, it still uses r7 as the frame pointer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    backend:ARMquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions