From ae214b18e7f893dcad1f1630e8f3027e1beaa00c Mon Sep 17 00:00:00 2001 From: Tomas Lindquist Olsen Date: Tue, 3 Mar 2009 19:18:47 +0100 Subject: [PATCH] Added ~{memory} clobber when a jump_target is generated in inline asm (branch out of inline asm) --- gen/asmstmt.cpp | 1 + gen/toir.cpp | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/gen/asmstmt.cpp b/gen/asmstmt.cpp index 9e414766..548fc661 100644 --- a/gen/asmstmt.cpp +++ b/gen/asmstmt.cpp @@ -594,6 +594,7 @@ void AsmBlockStatement::toIR(IRState* p) // setup variable for output from asm outSetterStmt->out_c = "=*m,"; outSetterStmt->out.push_back(jump_target); + asmblock->clobs.insert("~{memory},"); asmblock->s.push_back(outSetterStmt); } diff --git a/gen/toir.cpp b/gen/toir.cpp index 8e559789..a6ddee5b 100644 --- a/gen/toir.cpp +++ b/gen/toir.cpp @@ -2593,7 +2593,11 @@ STUB(TupleExp); STUB(SymbolExp); #endif -#define CONSTSTUB(x) LLConstant* x::toConstElem(IRState * p) {error("non-const expression '%s' or const Exp type "#x" not implemented", toChars()); fatal(); return NULL; } +#define CONSTSTUB(x) LLConstant* x::toConstElem(IRState * p) { \ + error("expression '%s' is not a constant", toChars()); \ + fatal(); \ + return NULL; \ +} CONSTSTUB(Expression); CONSTSTUB(GEPExp); CONSTSTUB(SliceExp); @@ -2761,9 +2765,10 @@ int TypedefDeclaration::cvMember(unsigned char*) void obj_includelib(const char* lib) { - char *arg = (char *)mem.malloc(64); + size_t n = strlen(lib)+3; + char *arg = (char *)mem.malloc(n); strcpy(arg, "-l"); - strncat(arg, lib, 64); + strncat(arg, lib, n); global.params.linkswitches->push(arg); }