# HG changeset patch # User ChristianK # Date 1214339275 -7200 # Node ID 7b1040c76dd25de7bbf9e1bb73a1fde60282ad35 # Parent df8a7b8d59295e877be0faa4ae6a36f97385ab65 [svn r321] Fix bug in argument remapping functions. diff -r df8a7b8d5929 -r 7b1040c76dd2 gen/asmstmt.cpp --- a/gen/asmstmt.cpp Tue Jun 24 21:38:23 2008 +0200 +++ b/gen/asmstmt.cpp Tue Jun 24 22:27:55 2008 +0200 @@ -463,8 +463,11 @@ char buf[10]; for (unsigned i = 0; i < nargs; i++) { needle = prefix + digits[i] + suffix; - sprintf(buf, "%u", idx++); - insnt.replace(insnt.find(needle), needle.size(), buf); + size_t pos = insnt.find(needle); + if(pos != std::string::npos) { + sprintf(buf, "%u", idx++); + insnt.replace(pos, needle.size(), buf); + } } } @@ -485,8 +488,11 @@ char buf[10]; for (unsigned i = 0; i < nargs; i++) { needle = prefix + digits[i] + suffix; - sprintf(buf, "%u", idx++); - insnt.replace(insnt.find(needle), needle.size(), buf); + size_t pos = insnt.find(needle); + if(pos != std::string::npos) { + sprintf(buf, "%u", idx++); + insnt.replace(pos, needle.size(), buf); + } } } @@ -515,7 +521,11 @@ // this additional asm code sets the __llvm_jump_target variable // to a unique value that will identify the jump target in // a post-asm switch - //FIXME: Need to init __llvm_jump_target + + // create storage for and initialize the temporary + llvm::AllocaInst* jump_target = new llvm::AllocaInst(llvm::IntegerType::get(32), "__llvm_jump_target", p->topallocapoint()); + gIR->ir->CreateStore(llvm::ConstantInt::get(llvm::IntegerType::get(32), 0), jump_target); + //FIXME: Store the value -> label mapping somewhere, so it can be referenced later std::string asmGotoEnd = "jmp __llvm_asm_end ; "; std::string outGotoSetter = asmGotoEnd; @@ -582,7 +592,7 @@ { out_c += a->out_c; } - remap_outargs(a->code, onn, asmIdx); + remap_outargs(a->code, onn+a->in.size(), asmIdx); } for (size_t i=0; iin_c; } - remap_inargs(a->code, inn, asmIdx); + remap_inargs(a->code, inn+a->out.size(), asmIdx); if (!code.empty()) code += " ; "; code += a->code;