llvm.org GIT mirror llvm / 1bb580a
Reject unrepresentable pointer types in intrinsics. Fixes PR7316. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110541 91177308-0d34-0410-b5e6-96231b3b80d8 Nick Lewycky 10 years ago
2 changed file(s) with 28 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
18391839 // and iPTR. In the verifier, we can not distinguish which case we have so
18401840 // allow either case to be legal.
18411841 if (const PointerType* PTyp = dyn_cast(Ty)) {
1842 Suffix += ".p" + utostr(PTyp->getAddressSpace()) +
1843 EVT::getEVT(PTyp->getElementType()).getEVTString();
1842 EVT PointeeVT = EVT::getEVT(PTyp->getElementType(), true);
1843 if (PointeeVT == MVT::Other) {
1844 CheckFailed("Intrinsic has pointer to complex type.");
1845 return false;
1846 }
1847 Suffix += ".p" + utostr(PTyp->getAddressSpace()) +
1848 PointeeVT.getEVTString();
18441849 } else {
18451850 CheckFailed(IntrinsicParam(ArgNo, NumRetVals) + " is not a "
18461851 "pointer and a pointer is required.", F);
0 ; RUN: not llvm-as < %s 2> %t
1 ; RUN: grep {Broken module} %t
2 ; PR7316
3
4 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:32"
5 target triple = "x86-unknown-unknown"
6 @aa = global [32 x i8] zeroinitializer, align 1
7 @bb = global [16 x i8] zeroinitializer, align 1
8 define void @x() nounwind {
9 L.0:
10 %0 = getelementptr [32 x i8]* @aa, i32 0, i32 4
11 %1 = bitcast i8* %0 to [16 x i8]*
12 %2 = bitcast [16 x i8]* %1 to [0 x i8]*
13 %3 = getelementptr [16 x i8]* @bb
14 %4 = bitcast [16 x i8]* %3 to [0 x i8]*
15 call void @llvm.memcpy.i32([0 x i8]* %2, [0 x i8]* %4, i32 16, i32 1)
16 br label %return
17 return:
18 ret void
19 }
20 declare void @llvm.memcpy.i32([0 x i8]*, [0 x i8]*, i32, i32) nounwind