mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-02 07:11:49 +00:00
Noting and enforcing that GC intrinsics are valid only within a
function with GC. This will catch the error when the inliner inlines a function with GC into a caller with no GC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45350 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
27acd3a999
commit
e1433f24cf
@ -3995,8 +3995,9 @@ value address) contains the meta-data to be associated with the root.</p>
|
||||
|
||||
<p>At runtime, a call to this intrinsics stores a null pointer into the "ptrloc"
|
||||
location. At compile-time, the code generator generates information to allow
|
||||
the runtime to find the pointer at GC safe points.
|
||||
</p>
|
||||
the runtime to find the pointer at GC safe points. The '<tt>llvm.gcroot</tt>'
|
||||
intrinsic may only be used in a function which <a href="#gc">specifies a GC
|
||||
algorithm</a>.</p>
|
||||
|
||||
</div>
|
||||
|
||||
@ -4031,7 +4032,9 @@ null).</p>
|
||||
|
||||
<p>The '<tt>llvm.gcread</tt>' intrinsic has the same semantics as a load
|
||||
instruction, but may be replaced with substantially more complex code by the
|
||||
garbage collector runtime, as needed.</p>
|
||||
garbage collector runtime, as needed. The '<tt>llvm.gcread</tt>' intrinsic
|
||||
may only be used in a function which <a href="#gc">specifies a GC
|
||||
algorithm</a>.</p>
|
||||
|
||||
</div>
|
||||
|
||||
@ -4066,7 +4069,9 @@ null.</p>
|
||||
|
||||
<p>The '<tt>llvm.gcwrite</tt>' intrinsic has the same semantics as a store
|
||||
instruction, but may be replaced with substantially more complex code by the
|
||||
garbage collector runtime, as needed.</p>
|
||||
garbage collector runtime, as needed. The '<tt>llvm.gcwrite</tt>' intrinsic
|
||||
may only be used in a function which <a href="#gc">specifies a GC
|
||||
algorithm</a>.</p>
|
||||
|
||||
</div>
|
||||
|
||||
|
@ -1167,37 +1167,45 @@ void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) {
|
||||
switch (ID) {
|
||||
default:
|
||||
break;
|
||||
case Intrinsic::gcroot: {
|
||||
Type *PtrTy = PointerType::getUnqual(Type::Int8Ty),
|
||||
*PtrPtrTy = PointerType::getUnqual(PtrTy);
|
||||
Assert1(CI.getOperand(1)->getType() == PtrPtrTy,
|
||||
"Intrinsic parameter #1 is not i8**.", &CI);
|
||||
Assert1(CI.getOperand(2)->getType() == PtrTy,
|
||||
"Intrinsic parameter #2 is not i8*.", &CI);
|
||||
Assert1(
|
||||
isa<AllocaInst>(IntrinsicInst::StripPointerCasts(CI.getOperand(1))),
|
||||
"llvm.gcroot parameter #1 must be an alloca.",
|
||||
&CI);
|
||||
Assert1(isa<Constant>(CI.getOperand(2)),
|
||||
"llvm.gcroot parameter #2 must be a constant.", &CI);
|
||||
} break;
|
||||
case Intrinsic::gcwrite: {
|
||||
Type *PtrTy = PointerType::getUnqual(Type::Int8Ty),
|
||||
*PtrPtrTy = PointerType::getUnqual(PtrTy);
|
||||
Assert1(CI.getOperand(1)->getType() == PtrTy,
|
||||
"Intrinsic parameter #1 is not a i8*.", &CI);
|
||||
Assert1(CI.getOperand(2)->getType() == PtrTy,
|
||||
"Intrinsic parameter #2 is not a i8*.", &CI);
|
||||
Assert1(CI.getOperand(3)->getType() == PtrPtrTy,
|
||||
"Intrinsic parameter #3 is not a i8**.", &CI);
|
||||
} break;
|
||||
case Intrinsic::gcroot:
|
||||
case Intrinsic::gcwrite:
|
||||
case Intrinsic::gcread: {
|
||||
Type *PtrTy = PointerType::getUnqual(Type::Int8Ty),
|
||||
*PtrPtrTy = PointerType::getUnqual(PtrTy);
|
||||
Assert1(CI.getOperand(1)->getType() == PtrTy,
|
||||
"Intrinsic parameter #1 is not a i8*.", &CI);
|
||||
Assert1(CI.getOperand(2)->getType() == PtrPtrTy,
|
||||
"Intrinsic parameter #2 is not a i8**.", &CI);
|
||||
|
||||
switch (ID) {
|
||||
default:
|
||||
break;
|
||||
case Intrinsic::gcroot:
|
||||
Assert1(CI.getOperand(1)->getType() == PtrPtrTy,
|
||||
"Intrinsic parameter #1 is not i8**.", &CI);
|
||||
Assert1(CI.getOperand(2)->getType() == PtrTy,
|
||||
"Intrinsic parameter #2 is not i8*.", &CI);
|
||||
Assert1(isa<AllocaInst>(
|
||||
IntrinsicInst::StripPointerCasts(CI.getOperand(1))),
|
||||
"llvm.gcroot parameter #1 must be an alloca.", &CI);
|
||||
Assert1(isa<Constant>(CI.getOperand(2)),
|
||||
"llvm.gcroot parameter #2 must be a constant.", &CI);
|
||||
break;
|
||||
case Intrinsic::gcwrite:
|
||||
Assert1(CI.getOperand(1)->getType() == PtrTy,
|
||||
"Intrinsic parameter #1 is not a i8*.", &CI);
|
||||
Assert1(CI.getOperand(2)->getType() == PtrTy,
|
||||
"Intrinsic parameter #2 is not a i8*.", &CI);
|
||||
Assert1(CI.getOperand(3)->getType() == PtrPtrTy,
|
||||
"Intrinsic parameter #3 is not a i8**.", &CI);
|
||||
break;
|
||||
case Intrinsic::gcread:
|
||||
Assert1(CI.getOperand(1)->getType() == PtrTy,
|
||||
"Intrinsic parameter #1 is not a i8*.", &CI);
|
||||
Assert1(CI.getOperand(2)->getType() == PtrPtrTy,
|
||||
"Intrinsic parameter #2 is not a i8**.", &CI);
|
||||
break;
|
||||
}
|
||||
|
||||
Assert1(CI.getParent()->getParent()->hasCollector(),
|
||||
"Enclosing function does not specify a collector algorithm.",
|
||||
&CI);
|
||||
} break;
|
||||
case Intrinsic::init_trampoline:
|
||||
Assert1(isa<Function>(IntrinsicInst::StripPointerCasts(CI.getOperand(2))),
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
%Env = type i8*
|
||||
|
||||
define void @.main(%Env) {
|
||||
define void @.main(%Env) gc "shadow-stack" {
|
||||
%Root = alloca %Env
|
||||
call void @llvm.gcroot( %Env* %Root, %Env null )
|
||||
unreachable
|
||||
|
10
test/CodeGen/Generic/GC/outside.ll
Normal file
10
test/CodeGen/Generic/GC/outside.ll
Normal file
@ -0,0 +1,10 @@
|
||||
; RUN: not llvm-as < %s
|
||||
|
||||
declare void @llvm.gcroot(i8**, i8*)
|
||||
|
||||
define void @f(i8* %x) {
|
||||
%root = alloca i8*
|
||||
call void @llvm.gcroot(i8** %root, i8* null)
|
||||
store i8* %x, i8** %root
|
||||
ret void
|
||||
}
|
Loading…
Reference in New Issue
Block a user