From 3d35b45f8e709316142cd469c9e16e29b214c2a6 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Sun, 18 Nov 2012 05:39:39 +0000 Subject: [PATCH] Don't try to calculate the alignment of an unsigned type. Fixes PR14371! llvm-svn: 168280 --- .../InstCombine/InstCombineLoadStoreAlloca.cpp | 3 ++- llvm/test/Transforms/InstCombine/alloca.ll | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp index 4ab5b6e..4d106fc 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp @@ -164,7 +164,8 @@ static unsigned getPointeeAlignment(Value *V, const DataLayout &TD) { return TD.getPreferredAlignment(GV); if (PointerType *PT = dyn_cast(V->getType())) - return TD.getABITypeAlignment(PT->getElementType()); + if (PT->getElementType()->isSized()) + return TD.getABITypeAlignment(PT->getElementType()); return 0; } diff --git a/llvm/test/Transforms/InstCombine/alloca.ll b/llvm/test/Transforms/InstCombine/alloca.ll index 50e0347..68a671c 100644 --- a/llvm/test/Transforms/InstCombine/alloca.ll +++ b/llvm/test/Transforms/InstCombine/alloca.ll @@ -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 -- 2.7.4