[llvm-bugs] [Bug 47447] New: bad and questionable codegen for inline asm returning a value in a fixed register
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Sep 7 04:10:53 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=47447
Bug ID: 47447
Summary: bad and questionable codegen for inline asm returning
a value in a fixed register
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Backend: RISC-V
Assignee: unassignedbugs at nondot.org
Reporter: sorear at fastmail.com
CC: asb at lowrisc.org, llvm-bugs at lists.llvm.org
__builtin_thread_pointer() is not supported on released versions of risc-v gcc
or clang, so I looked for alternatives that would generate the same code. I
tried:
void *get_tp() {
register void *tp asm("tp");
asm("" : "=r"(tp));
return tp;
}
define i8* @get_tp() {
%1 = tail call i8* asm "", "={x4}"()
ret i8* %1
}
(https://gcc.godbolt.org/z/GP5ab4)
This works fine on released gcc (can even fold into subsequent memory accesses
which become tp-relative) but llvm generates a superfluous stack frame as
though tp were a call-saved register. Since tp is a fixed register, I don't
think llvm is _allowed_ to insert saves and restores for it; the asm might be
erroneous, I am not sure of the intended semantics, but if it is accepted it
should be accepted without generating a stack frame.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200907/271aa90d/attachment.html>
More information about the llvm-bugs
mailing list