Don't try to calculate the alignment of an unsigned type. Fixes PR14371!
authorNick Lewycky <nicholas@mxc.ca>
Sun, 18 Nov 2012 05:39:39 +0000 (05:39 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Sun, 18 Nov 2012 05:39:39 +0000 (05:39 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168280 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
test/Transforms/InstCombine/alloca.ll

index 4ab5b6e4a04165a6a97bd32a946931c922b9d96c..4d106fc1885344e715d429142b8608eaa0e6de67 100644 (file)
@@ -164,7 +164,8 @@ static unsigned getPointeeAlignment(Value *V, const DataLayout &TD) {
       return TD.getPreferredAlignment(GV);
 
   if (PointerType *PT = dyn_cast<PointerType>(V->getType()))
-    return TD.getABITypeAlignment(PT->getElementType());
+    if (PT->getElementType()->isSized())
+      return TD.getABITypeAlignment(PT->getElementType());
 
   return 0;
 }
index 50e03479f650b4237f8266000280c622444b820b..68a671cec88afbe7c70cebf3def73416dca2d655 100644 (file)
@@ -94,3 +94,19 @@ entry:
   tail call void @f(i32* %b)
   ret void
 }
+
+; PR14371
+%opaque_type = type opaque
+%real_type = type { { i32, i32* } }
+
+@opaque_global = external constant %opaque_type, align 4
+
+define void @test7() {
+entry:
+  %0 = alloca %real_type, align 4
+  %1 = bitcast %real_type* %0 to i8*
+  call void @llvm.memcpy.p0i8.p0i8.i32(i8* %1, i8* bitcast (%opaque_type* @opaque_global to i8*), i32 8, i32 1, i1 false)
+  ret void
+}
+
+declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32, i1) nounwind