changeset 1036:01544da4cdd8

Added ~{memory} clobber when a jump_target is generated in inline asm (branch out of inline asm)
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Tue, 03 Mar 2009 19:18:47 +0100
parents 4c524d80e6e1
children 1d8a8ecf14e1
files gen/asmstmt.cpp gen/toir.cpp
diffstat 2 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/gen/asmstmt.cpp	Tue Mar 03 19:03:27 2009 +0100
+++ b/gen/asmstmt.cpp	Tue Mar 03 19:18:47 2009 +0100
@@ -594,6 +594,7 @@
             // 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);
         }
--- a/gen/toir.cpp	Tue Mar 03 19:03:27 2009 +0100
+++ b/gen/toir.cpp	Tue Mar 03 19:18:47 2009 +0100
@@ -2593,7 +2593,11 @@
 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 @@
 
 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);
 }