From 2687d581981a4a0b5f0359c57ee7a0a412e5021e Mon Sep 17 00:00:00 2001 From: Frits van Bommel Date: Sun, 8 Mar 2009 00:57:58 +0100 Subject: [PATCH] Always pass an address expression (not a var expression) to asm operands of type Arg_Memory. This fixes the following code: {{{ void f(real x) { asm { fld x[RBP]; } } void g(int x) { asm { mov EAX, x[RBP]; } } }}} --- gen/asm-x86-64.h | 7 ++----- gen/asmstmt.cpp | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/gen/asm-x86-64.h b/gen/asm-x86-64.h index eec6d5e3..da5ce9ba 100644 --- a/gen/asm-x86-64.h +++ b/gen/asm-x86-64.h @@ -2144,11 +2144,8 @@ namespace AsmParserx8664 ( ( operand->baseReg == Reg_ESP || ( operand->baseReg == Reg_RSP ) ) && ! sc->func->naked ) ) ) { - if ( mode == Mode_Output ) - { - e = new AddrExp ( 0, e ); - e->type = decl->type->pointerTo(); - } + e = new AddrExp ( 0, e ); + e->type = decl->type->pointerTo(); #if !IN_LLVM /* DMD uses the same frame offsets for naked functions. */ diff --git a/gen/asmstmt.cpp b/gen/asmstmt.cpp index 9e414766..fe045661 100644 --- a/gen/asmstmt.cpp +++ b/gen/asmstmt.cpp @@ -415,6 +415,26 @@ assert(0); asmblock->clobs.insert(clobstr); } + if (Logger::enabled()) { + typedef std::deque::iterator It; + { + Logger::println("Output values:"); + LOG_SCOPE + size_t i = 0; + for (It I = output_values.begin(), E = output_values.end(); I != E; ++I) { + Logger::cout() << "Out " << i++ << " = " << **I << '\n'; + } + } + { + Logger::println("Input values:"); + LOG_SCOPE + size_t i = 0; + for (It I = input_values.begin(), E = input_values.end(); I != E; ++I) { + Logger::cout() << "In " << i++ << " = " << **I << '\n'; + } + } + } + // excessive commas are removed later... // push asm statement