[cfe-commits] r66528 - /cfe/trunk/lib/CodeGen/CGStmt.cpp
Chris Lattner
sabre at nondot.org
Mon Mar 9 22:39:21 PDT 2009
Author: lattner
Date: Tue Mar 10 00:39:21 2009
New Revision: 66528
URL: http://llvm.org/viewvc/llvm-project?rev=66528&view=rev
Log:
Expand %= into ${:uid} so that the code generator emits a unique ID for the
asm. 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
This also fixes a fixme by eliminating a static.
Modified:
cfe/trunk/lib/CodeGen/CGStmt.cpp
Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=66528&r1=66527&r2=66528&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Tue Mar 10 00:39:21 2009
@@ -714,10 +714,6 @@
unsigned NumOperands = S.getNumOutputs() + S.getNumInputs();
- // FIXME: Static counters are not thread safe or reproducible.
- static unsigned AsmCounter = 0;
- AsmCounter++;
-
while (*Start) {
switch (*Start) {
default:
@@ -729,10 +725,8 @@
case '%':
// Escaped character
Start++;
- if (!*Start) {
- // FIXME: This should be caught during Sema.
- assert(0 && "Trailing '%' in asm string.");
- }
+ // FIXME: This should be caught during Sema.
+ assert(*Start && "Trailing '%' in asm string.");
char EscapedChar = *Start;
if (EscapedChar == '%') {
@@ -740,7 +734,7 @@
Result += '%';
} else if (EscapedChar == '=') {
// Generate an unique ID.
- Result += llvm::utostr(AsmCounter);
+ Result += "${:uid}";
} else if (isdigit(EscapedChar)) {
// %n - Assembler operand n
char *End;
@@ -823,8 +817,7 @@
static std::string SimplifyConstraint(const char* Constraint,
TargetInfo &Target,
const std::string *OutputNamesBegin = 0,
- const std::string *OutputNamesEnd = 0)
-{
+ const std::string *OutputNamesEnd = 0) {
std::string Result;
while (*Constraint) {
@@ -862,8 +855,7 @@
llvm::Value* CodeGenFunction::EmitAsmInput(const AsmStmt &S,
TargetInfo::ConstraintInfo Info,
const Expr *InputExpr,
- std::string &ConstraintStr)
-{
+ std::string &ConstraintStr) {
llvm::Value *Arg;
if ((Info & TargetInfo::CI_AllowsRegister) ||
!(Info & TargetInfo::CI_AllowsMemory)) {
More information about the cfe-commits
mailing list