Skip to content

RISC-V: register __asm__ ("tp") doesn't access TP #112773

@palmer-dabbelt

Description

@palmer-dabbelt

This came up as part of a glibc patch review https://inbox.sourceware.org/libc-alpha/[email protected]/. Looks like this register ... __asm__ ("tp") syntax isn't working in clang.

void *
__thread_pointer (void)
{
   register void *__tp __asm__ ("tp");
   return __tp;
}

generates

__thread_pointer():
        ret

GCC generates

__thread_pointer():
        mv      a0,tp
        ret

which is the sort of thing I'd expect.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions