I meant global g1, not g2, in this line: %8 = load i64* bitcast (i8* getelementptr inbounds (%struct.S4* @g1, i64 0, i32 3) to i64*), align 1
________________________________________ From: Hatanaka, Akira Sent: Wednesday, November 02, 2011 6:09 PM To: Eli Friedman Cc: [email protected] Subject: RE: [cfe-commits] r143596 - /cfe/trunk/lib/CodeGen/TargetInfo.cpp Yes, that should be 40-bits. The structure with sub-doubleword fields was needed to handle packed structures whose size is not a multiple of 64. When I test it with the program below, a full double word load is used to load the last field of struct S4 instead of a byte load. Is this legal? It seems incorrect to me to load from a memory location outside the global g2. ### source program. typedef struct { int i1, i2; double d1; char f1; } __attribute__((packed)) S4; void foo110(S4, int, int); extern S4 g2, g1; void foo100(int a1, S4 a2, int a3) { g2 = a2; foo110(g1, a3, a1); } ### everything with 64-bit chunks. ; ModuleID = 'f1.c' target datalayout = "e-p:64:64:64-i1:8:8-i8:8:32-i16:16:32-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f128:128:128-v64:64:64-n32" target triple = "mips64el-unknown-linux" %struct.S4 = type <{ i32, i32, double, i8 }> @g2 = external global %struct.S4 @g1 = external global %struct.S4 define void @foo100(i32 %a1, i64 %a2.coerce0, double %a2.coerce1, i64 %a2.coerce2, i32 %a3) nounwind { entry: %0 = zext i64 %a2.coerce0 to i136 %1 = bitcast double %a2.coerce1 to i64 %2 = zext i64 %1 to i136 %3 = shl nuw nsw i136 %2, 64 %4 = zext i64 %a2.coerce2 to i136 %5 = shl i136 %4, 128 %ins3 = or i136 %5, %0 %ins = or i136 %ins3, %3 store i136 %ins, i136* bitcast (%struct.S4* @g2 to i136*), align 1 %6 = load i64* bitcast (%struct.S4* @g1 to i64*), align 1 %7 = load double* getelementptr inbounds (%struct.S4* @g1, i64 0, i32 2), align 1 %8 = load i64* bitcast (i8* getelementptr inbounds (%struct.S4* @g1, i64 0, i32 3) to i64*), align 1 tail call void @foo110(i64 %6, double %7, i64 %8, i32 %a3, i32 %a1) nounwind ret void } declare void @foo110(i64, double, i64, i32, i32) The code in trunk emits this: ### structure with sub-doubleword fields. ; ModuleID = 'f1.c' target datalayout = "e-p:64:64:64-i1:8:8-i8:8:32-i16:16:32-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f128:128:128-v64:64:64-n32" target triple = "mips64el-unknown-linux" %struct.S4 = type <{ i32, i32, double, i8 }> @g2 = external global %struct.S4 @g1 = external global %struct.S4 define void @foo100(i32 %a1, i64 %a2.coerce0, double %a2.coerce1, { i8 } %a2.coerce2, i32 %a3) nounwind { entry: %0 = zext i64 %a2.coerce0 to i136 %1 = bitcast double %a2.coerce1 to i64 %2 = zext i64 %1 to i136 %3 = shl nuw nsw i136 %2, 64 %4 = extractvalue { i8 } %a2.coerce2, 0 %5 = zext i8 %4 to i136 %6 = shl nuw i136 %5, 128 %ins3 = or i136 %3, %0 %ins = or i136 %ins3, %6 store i136 %ins, i136* bitcast (%struct.S4* @g2 to i136*), align 1 %7 = load i64* bitcast (%struct.S4* @g1 to i64*), align 1 %8 = load double* getelementptr inbounds (%struct.S4* @g1, i64 0, i32 2), align 1 %9 = load { i8 }* bitcast (i8* getelementptr inbounds (%struct.S4* @g1, i64 0, i32 3) to { i8 }*), align 1 tail call void @foo110(i64 %7, double %8, { i8 } %9, i32 %a3, i32 %a1) nounwind ret void } declare void @foo110(i64, double, { i8 }, i32, i32) ______________________________________ From: Eli Friedman [[email protected]] Sent: Wednesday, November 02, 2011 5:22 PM To: Hatanaka, Akira Cc: [email protected] Subject: Re: [cfe-commits] r143596 - /cfe/trunk/lib/CodeGen/TargetInfo.cpp On Wed, Nov 2, 2011 at 4:54 PM, Akira Hatanaka <[email protected]> wrote: > + // Add ((StructSize - LastOffset) / 64) args of type i64. > + for (unsigned N = (StructSize - LastOffset) / 64; N; --N) > + ArgList.push_back(I64); > + > + // Whatever is left over goes into a structure consisting of sub-doubleword > + // types. For example, if the size of the remainder is 40-bytes, > + // struct {i32, i8} is added to ArgList. I assume you mean bits? >From looking over the ABI description, this doesn't look right... everything should be using i64 chunks. -Eli _______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
