changeset 1350:e44202fdb50b

[Issue 824] "mov EAX, func;" and "lea EAX, func;" generate incorrect code Thomas K?hne <thomas-dloop@kuehne.cn> 2007-01-09 http://d.puremagic.com/issues/show_bug.cgi?id=824
author thomask
date Wed, 14 Feb 2007 10:11:10 +0000
parents b46ea253c724
children 68bba8897adb
files run/a/asm_lea_02_A.d run/a/asm_mov_04_A.d
diffstat 2 files changed, 91 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/run/a/asm_lea_02_A.d	Wed Feb 14 10:11:10 2007 +0000
@@ -0,0 +1,49 @@
+// $HeadURL$
+// $Date$
+// $Author$
+
+// @author@	Thomas Kühne <thomas-dloop@kuehne.cn>
+// @date@	2007-01-09
+// @uri@	http://d.puremagic.com/issues/show_bug.cgi?id=824
+// @desc@	[Issue 824] "mov EAX, func;" and "lea EAX, func;" generate incorrect code
+
+module dstress.run.a.asm_lea_02_A;
+
+version(D_InlineAsm_X86){
+	version = runTest;
+}else version(D_InlineAsm_X86_64){
+	version = runTest;
+}
+
+version(runTest){
+	void func(){
+	}
+
+	int main(){
+		void* f = &func;
+		void* g = null;
+
+		static if(4 == size_t.sizeof){
+			asm{
+				lea EAX, func;
+				mov g, EAX;
+			}
+		}else static if(8 == size_t.sizeof){
+			asm{
+				lea RAX, func;
+				mov g, RAX;
+			}
+		}else{
+			static assert(0, "DSTRESS{XFAIL}: unsupported pointer size");
+		}
+
+		if(f != g){
+			assert(0);
+		}
+
+		return 0;
+	}
+}else{
+	pragma(msg, "DSTRESS{XFAIL}: no inline ASM support");
+	static assert(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/run/a/asm_mov_04_A.d	Wed Feb 14 10:11:10 2007 +0000
@@ -0,0 +1,42 @@
+// $HeadURL$
+// $Date$
+// $Author$
+
+// @author@	Thomas Kühne <thomas-dloop@kuehne.cn>
+// @date@	2007-01-09
+// @uri@	http://d.puremagic.com/issues/show_bug.cgi?id=824
+// @desc@	[Issue 824] "mov EAX, func;" and "lea EAX, func;" generate incorrect code
+
+module dstress.run.a.asm_mov_04_A;
+
+version(D_InlineAsm_X86){
+	version = runTest;
+}else version(D_InlineAsm_X86_64){
+	version = runTest;
+}
+
+version(runTest){
+	void func(){
+	}
+
+	int main(){
+		void* a = &func;
+		uint* b = cast(uint*) a;
+		uint f = *b;
+		uint g;
+
+		asm{
+			mov EAX, func;
+			mov g, EAX;
+		}
+
+		if(f != g){
+			assert(0);
+		}
+
+		return 0;
+	}
+}else{
+	pragma(msg, "DSTRESS{XFAIL}: no inline ASM support");
+	static assert(0);
+}