Skip to content

Commit ddf0706

Browse files
committed
Merging r168280: into 3.2 release branch.
Don't try to calculate the alignment of an unsigned type. Fixes PR14371! git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_32@168480 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 3e2cbf9 commit ddf0706

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ static unsigned getPointeeAlignment(Value *V, const DataLayout &TD) {
164164
return TD.getPreferredAlignment(GV);
165165

166166
if (PointerType *PT = dyn_cast<PointerType>(V->getType()))
167-
return TD.getABITypeAlignment(PT->getElementType());
167+
if (PT->getElementType()->isSized())
168+
return TD.getABITypeAlignment(PT->getElementType());
168169

169170
return 0;
170171
}

test/Transforms/InstCombine/alloca.ll

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,19 @@ entry:
9494
tail call void @f(i32* %b)
9595
ret void
9696
}
97+
98+
; PR14371
99+
%opaque_type = type opaque
100+
%real_type = type { { i32, i32* } }
101+
102+
@opaque_global = external constant %opaque_type, align 4
103+
104+
define void @test7() {
105+
entry:
106+
%0 = alloca %real_type, align 4
107+
%1 = bitcast %real_type* %0 to i8*
108+
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %1, i8* bitcast (%opaque_type* @opaque_global to i8*), i32 8, i32 1, i1 false)
109+
ret void
110+
}
111+
112+
declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32, i1) nounwind

0 commit comments

Comments
 (0)