]> granicus.if.org Git - clang/commitdiff
Fix x86-64 byval passing to specify the alignment even when the code
authorChris Lattner <sabre@nondot.org>
Sun, 22 May 2011 23:21:23 +0000 (23:21 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 22 May 2011 23:21:23 +0000 (23:21 +0000)
generator will give it something sufficient.  This is important because
the mid-level optimizer doesn't know what alignment is required otherwise.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131879 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/TargetInfo.cpp
test/CodeGen/x86_64-arguments.c

index 73526fbfdd0fe6e592b8de22fe8bd8b0b7793272..5ac5ea4ac402c6598d7e07b83e5e9681f7447746 100644 (file)
@@ -1315,13 +1315,10 @@ ABIArgInfo X86_64ABIInfo::getIndirectResult(QualType Ty) const {
   if (isRecordWithNonTrivialDestructorOrCopyConstructor(Ty))
     return ABIArgInfo::getIndirect(0, /*ByVal=*/false);
 
-  // Compute the byval alignment. We trust the back-end to honor the
-  // minimum ABI alignment for byval, to make cleaner IR.
-  const unsigned MinABIAlign = 8;
-  unsigned Align = getContext().getTypeAlign(Ty) / 8;
-  if (Align > MinABIAlign)
-    return ABIArgInfo::getIndirect(Align);
-  return ABIArgInfo::getIndirect(0);
+  // Compute the byval alignment. We specify the alignment of the byval in all
+  // cases so that the mid-level optimizer knows the alignment of the byval.
+  unsigned Align = std::max(getContext().getTypeAlign(Ty) / 8, 8U);
+  return ABIArgInfo::getIndirect(Align);
 }
 
 /// Get16ByteVectorType - The ABI specifies that a value should be passed in an
index ebde884d78d6c665f7baafcad80ab2f40eeddfa1..75c4788f7120f2962edc10df3960c124c2758ce1 100644 (file)
@@ -69,7 +69,7 @@ void f12_1(struct s12 a0) {}
 
 // Check that sret parameter is accounted for when checking available integer
 // registers.
-// CHECK: define void @f13(%struct.s13_0* sret %agg.result, i32 %a, i32 %b, i32 %c, i32 %d, {{.*}}* byval %e, i32 %f)
+// CHECK: define void @f13(%struct.s13_0* sret %agg.result, i32 %a, i32 %b, i32 %c, i32 %d, {{.*}}* byval align 8 %e, i32 %f)
 
 struct s13_0 { long long f0[3]; };
 struct s13_1 { long long f0[2]; };