Skip to content

Asm "p" constraint rejected #10060

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
llvmbot opened this issue Apr 12, 2011 · 3 comments
Open

Asm "p" constraint rejected #10060

llvmbot opened this issue Apr 12, 2011 · 3 comments
Labels
bugzilla Issues migrated from bugzilla llvm:codegen

Comments

@llvmbot
Copy link
Member

llvmbot commented Apr 12, 2011

Bugzilla Link 9688
Version 2.9
OS Linux
Blocks llvm/llvm-bugzilla-archive#10988
Reporter LLVM Bugzilla Contributor
CC @RKSimon

Extended Description

From gcc testcase asm-4.c:

int main()
{
  int z;
  asm volatile ("test2 X%a0Y%a[arg]Z" : : [arg] "p" (&z));
}

Both clang and dragonegg reject this. See #8704 for discussion.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
@arsenm
Copy link
Contributor

arsenm commented Aug 5, 2023

clang still rejects this today while gcc accepts it:

	#APP
/tmp/issue10060.c:4:15: error: invalid operand in inline asm: 'test2 X${0:a}Y${0:a}Z'
    4 | asm volatile ("test2 X%a0Y%a[arg]Z" : : [arg] "p" (&z));
      |               ^
/tmp/issue10060.c:4:15: error: invalid operand in inline asm: 'test2 X${0:a}Y${0:a}Z'
/tmp/issue10060.c:4:15: error: invalid instruction mnemonic 'test2'
<inline asm>:1:2: note: instantiated into assembly here
    1 |         test2 XYZ
      |         ^~~~~
	#NO_APP

@shafik
Copy link
Collaborator

shafik commented Aug 5, 2023

CC @AaronBallman do you have any opinions on whether we should accept this or not?

@AaronBallman
Copy link
Collaborator

I don't have strong opinions; assembly constraints are handled by the backend:

Msg << "invalid operand in inline asm: '" << AsmStr << "'";

weliveindetail pushed a commit to weliveindetail/llvm-project that referenced this issue Feb 26, 2025
…e interop mode (llvm#10060) (llvm#10103)

For a __null_terminated pointer 'p', only a __null_terminated pointer,
a string literal or a call to `std::string::c_str/data` can be assigned to
(/passed to/used to initialize, etc.) 'p'.  Otherwise, an error will be emitted.
The implementation reuses Bounds Safety's diagnostics.

(rdar://138798346)
qiongsiwu pushed a commit to qiongsiwu/llvm-project that referenced this issue Mar 1, 2025
…e interop mode (llvm#10060)

For a __null_terminated pointer 'p', only a __null_terminated pointer,
a string literal or a call to `std::string::c_str/data` can be assigned to
(/passed to/used to initialize, etc.) 'p'.  Otherwise, an error will be emitted. 
The implementation reuses Bounds Safety's diagnostics.

(rdar://138798346)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla llvm:codegen
Projects
None yet
Development

No branches or pull requests

4 participants