Skip to content
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

Non-extended inline assembly statements should have asmstrings interpreted #1296

Closed
llvmbot opened this issue Sep 26, 2006 · 3 comments
Closed
Assignees
Labels
bugzilla Issues migrated from bugzilla compile-fail Use [accepts-invalid] and [rejects-valid] instead llvm-tools All llvm tools that do not have corresponding tag

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Sep 26, 2006

Bugzilla Link 924
Resolution FIXED
Resolved on Feb 22, 2010 12:49
Version 1.7
OS All
Blocks #1234
Reporter LLVM Bugzilla Contributor

Extended Description

This is a reduction from the linux kernel (gcc is happy with it, llvm-gcc isn't):

void bar() {
asm volatile ("xorl %eax, %eax; movl %eax, %fs; movl %eax, %gs");
}

@llvmbot
Copy link
Collaborator Author

llvmbot commented Sep 26, 2006

assigned to @lattner

@lattner
Copy link
Collaborator

lattner commented Sep 28, 2006

After poking at this for a while, it turns out that GCC has special support for asms with no operands. Urg.

-Chris

@lattner
Copy link
Collaborator

lattner commented Sep 28, 2006

Fixed. Testcase here:
Regression/CFrontend/2006-09-28-SimpleAsm.c

Patch here:

===============================================================

--- llvm-convert.cpp (revision 118365)
+++ llvm-convert.cpp (working copy)
@@ -2443,6 +2443,20 @@
tree str = ASM_STRING(exp);
if (TREE_CODE(str) == ADDR_EXPR) str = TREE_OPERAND(str, 0);

  • // ASM_INPUT_P - This flag is set if this is a non-extended ASM, which means
  • // that the asm string should not be interpreted, other than to escape $'s.
  • if (ASM_INPUT_P(exp)) {
  • const char *InStr = TREE_STRING_POINTER(str);
  • std::string Result;
  • while (1) {
  •  switch (*InStr++) {
    
  •  case 0: return Result;                 // End of string.
    
  •  default: Result += InStr[-1]; break;   // Normal character.
    
  •  case '$': Result += "$$"; break;       // Escape '$' characters.
    
  •  }
    
  • }
  • }
  • // Expand [name] symbolic operand names.
    str = resolve_asm_operand_names(str, ASM_OUTPUTS(exp), ASM_INPUTS(exp));

-Chris

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla compile-fail Use [accepts-invalid] and [rejects-valid] instead llvm-tools All llvm tools that do not have corresponding tag
Projects
None yet
Development

No branches or pull requests

2 participants