mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-05 19:29:54 +00:00
Teach the verifier to enforce that the alignment argument of memory intrinsics must be a power of 2.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230941 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8fae2845b1
commit
132a34981f
@ -2796,14 +2796,20 @@ void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) {
|
|||||||
} break;
|
} break;
|
||||||
case Intrinsic::memcpy:
|
case Intrinsic::memcpy:
|
||||||
case Intrinsic::memmove:
|
case Intrinsic::memmove:
|
||||||
case Intrinsic::memset:
|
case Intrinsic::memset: {
|
||||||
Assert1(isa<ConstantInt>(CI.getArgOperand(3)),
|
ConstantInt *AlignCI = dyn_cast<ConstantInt>(CI.getArgOperand(3));
|
||||||
|
Assert1(AlignCI,
|
||||||
"alignment argument of memory intrinsics must be a constant int",
|
"alignment argument of memory intrinsics must be a constant int",
|
||||||
&CI);
|
&CI);
|
||||||
|
const APInt &AlignVal = AlignCI->getValue();
|
||||||
|
Assert1(AlignCI->isZero() || AlignVal.isPowerOf2(),
|
||||||
|
"alignment argument of memory intrinsics must be a power of 2",
|
||||||
|
&CI);
|
||||||
Assert1(isa<ConstantInt>(CI.getArgOperand(4)),
|
Assert1(isa<ConstantInt>(CI.getArgOperand(4)),
|
||||||
"isvolatile argument of memory intrinsics must be a constant int",
|
"isvolatile argument of memory intrinsics must be a constant int",
|
||||||
&CI);
|
&CI);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case Intrinsic::gcroot:
|
case Intrinsic::gcroot:
|
||||||
case Intrinsic::gcwrite:
|
case Intrinsic::gcwrite:
|
||||||
case Intrinsic::gcread:
|
case Intrinsic::gcread:
|
||||||
|
9
test/Verifier/memcpy.ll
Normal file
9
test/Verifier/memcpy.ll
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
; RUN: not opt -verify < %s 2>&1 | FileCheck %s
|
||||||
|
|
||||||
|
; CHECK: alignment argument of memory intrinsics must be a power of 2
|
||||||
|
|
||||||
|
define void @foo(i8* %P, i8* %Q) {
|
||||||
|
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %P, i8* %Q, i32 4, i32 3, i1 false)
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture, i32, i32, i1) nounwind
|
Loading…
Reference in New Issue
Block a user