[llvm-commits] [llvm-gcc-4.2] r66529 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp

Chris Lattner sabre at nondot.org
Mon Mar 9 22:42:04 PDT 2009


Author: lattner
Date: Tue Mar 10 00:42:04 2009
New Revision: 66529

URL: http://llvm.org/viewvc/llvm-project?rev=66529&view=rev
Log:
Instead of manually expanding %=, turn it into ${:uid}.  This 
allows us to properly handle the case when an optimizer duplicates
the asm, such as here:

void bar() {
  int i;
  for (i = 0; i < 3; ++i)
    asm("foo %=" : : "r"(0));
}

we now produce:

_bar:
	xorl	%eax, %eax
	## InlineAsm Start
	foo 0
	## InlineAsm End
	## InlineAsm Start
	foo 1
	## InlineAsm End
	## InlineAsm Start
	foo 2
	## InlineAsm End
	ret

instead of:

_bar:
	xorl	%eax, %eax
	## InlineAsm Start
	foo 1
	## InlineAsm End
	## InlineAsm Start
	foo 1
	## InlineAsm End
	## InlineAsm Start
	foo 1
	## InlineAsm End
	ret


Modified:
    llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp

Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=66529&r1=66528&r2=66529&view=diff

==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Tue Mar 10 00:42:04 2009
@@ -3730,8 +3730,6 @@
 /// Other %xN expressions are turned into LLVM ${N:x} operands.
 ///
 static std::string ConvertInlineAsmStr(tree exp, unsigned NumOperands) {
-  static unsigned InlineAsmCounter = 0U;
-  unsigned InlineAsmNum = InlineAsmCounter++;
 
   tree str = ASM_STRING(exp);
   if (TREE_CODE(str) == ADDR_EXPR) str = TREE_OPERAND(str, 0);
@@ -3772,7 +3770,7 @@
       if (EscapedChar == '%') {            // Escaped '%' character
         Result += '%';
       } else if (EscapedChar == '=') {     // Unique ID for the asm instance.
-        Result += utostr(InlineAsmNum);
+        Result += "${:uid}";
       }
 #ifdef LLVM_ASM_EXTENSIONS
       LLVM_ASM_EXTENSIONS(EscapedChar, InStr, Result)





More information about the llvm-commits mailing list