[llvm-bugs] [Bug 45585] New: Assembler operand constraints are ineffective with global register variables
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Apr 17 08:19:21 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=45585
Bug ID: 45585
Summary: Assembler operand constraints are ineffective with
global register variables
Product: clang
Version: 9.0
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C
Assignee: unassignedclangbugs at nondot.org
Reporter: ubizjak at gmail.com
CC: blitzrakete at gmail.com, dgregor at apple.com,
erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
richard-llvm at metafoo.co.uk
Following testcase:
--cut here--
register unsigned long current_stack_pointer asm("rsp");
void
foo (void)
{
asm volatile ("# %0" :: "a" (current_stack_pointer));
}
--cut here--
compiles on x86 with -O2 to:
#APP
# %rsp
#NO_APP
Please note that the asm uses input operand constraint "a" that would allow
only %rax register.
GCC gets this right and reloads %rsp to %rax:
movq %rsp, %rax
#APP
# %rax
#NO_APP
If the constraint is changed to "r", which allows all general registers,
including %rsp, GCC generates
#APP
# %rsp
#NO_APP
I'd like to argue that the compiler should reload the input argument, so that
the asm input operand constraint is always respected.
--
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/20200417/b6f0440d/attachment.html>
More information about the llvm-bugs
mailing list