This seems generally fine to me, although I'd like John or someone to confirm it's the right behavior on Darwin.<div><br></div><div>Also, you need test cases. =]<br><br><div class="gmail_quote">On Thu, Jun 7, 2012 at 2:23 PM, David Sehr <span dir="ltr"><<a href="mailto:sehr@google.com" target="_blank">sehr@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">All,<br>
<br>
I have recently been debugging a failure with one of the tests from<br>
the gcc torture test suite and discovered that gcc and llvm seem to<br>
differ on whether __builtin_alloca is aligned more than 0mod4 (gcc<br>
thinks it's aligned by what clang stores inTargetInfo::SuitableAlign).<br>
 Below is a patch that (1) changes the alignment of __builtin_alloca<br>
for all targets, (2) adds setting SuitableAlign to the PNaCl target,<br>
and (3) fixes the size and alignment of v128 for PNaCl.  Please let me<br>
know how to proceed.<br>
<br>
David<br>
<br>
----<br>
Index: lib/Basic/Targets.cpp<br>
===================================================================<br>
--- lib/Basic/Targets.cpp (revision 158168)<br>
+++ lib/Basic/Targets.cpp (working copy)<br>
@@ -3888,6 +3888,7 @@<br>
     this->LongWidth = 32;<br>
     this->PointerAlign = 32;<br>
     this->PointerWidth = 32;<br>
+    this->SuitableAlign = 128;<br>
     this->IntMaxType = TargetInfo::SignedLongLong;<br>
     this->UIntMaxType = TargetInfo::UnsignedLongLong;<br>
     this->Int64Type = TargetInfo::SignedLongLong;<br>
@@ -3899,7 +3900,7 @@<br>
     this->IntPtrType = TargetInfo::SignedInt;<br>
     this->RegParmMax = 2;<br>
     DescriptionString = "e-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"<br>
-                        "f32:32:32-f64:64:64-p:32:32:32-v128:32:32";<br>
+                        "f32:32:32-f64:64:64-p:32:32:32-v128:128:128";<br>
   }<br>
<br>
   void getDefaultFeatures(llvm::StringMap<bool> &Features) const {<br>
Index: lib/CodeGen/CGBuiltin.cpp<br>
===================================================================<br>
--- lib/CodeGen/CGBuiltin.cpp (revision 158168)<br>
+++ lib/CodeGen/CGBuiltin.cpp (working copy)<br>
@@ -536,7 +536,9 @@<br>
   case Builtin::BIalloca:<br>
   case Builtin::BI__builtin_alloca: {<br>
     Value *Size = EmitScalarExpr(E->getArg(0));<br>
-    return RValue::get(Builder.CreateAlloca(Builder.getInt8Ty(), Size));<br>
+    AllocaInst *Alloca = Builder.CreateAlloca(Builder.getInt8Ty(), Size);<br>
+    Alloca->setAlignment(CGM.getTarget().getSuitableAlign() / 8);<br>
+    return RValue::get(Alloca);<br>
   }<br>
   case Builtin::BIbzero:<br>
   case Builtin::BI__builtin_bzero: {<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>