Skip to content

__attribute__((nocf_check)) on function pointer doesn't add notrack prefix with -O1+ #91228

@sroettger

Description

@sroettger

I'm trying to use the nocf_check attribute on a function pointer by reproducing this testcase:
https://github.com/llvm/llvm-project/blob/main/llvm/test/CodeGen/X86/nocf_check.ll#L7

void __attribute__((nocf_check)) NoCfCheckFunc(void) {}

typedef void(*FuncPointer)(void);
void NoCfCheckCall(FuncPointer f) {
  __attribute__((nocf_check)) FuncPointer p = (__attribute__((nocf_check)) FuncPointer) (f);
  (*p)();
}

Compiling this with -fcf-protection=branch my expectation is that the call to p should have a notrack prefix.
This is the case, but only if I add -O0. Any higher optimization level results in a regular branch without the notrack.

https://godbolt.org/z/ocnz1qhbW

cc @MaskRay

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions