X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=blobdiff_plain;f=lib%2FIR%2FVerifier.cpp;h=49f8a7ca4a112e0f896ecba1ebe409ebcbdde501;hp=1a30d5b5448bb1616dab037568e1f51799c9c58c;hb=19d2499d6a592c2643f02b98b74edb3e74d887bb;hpb=a7574638e7da2645d4e06c62bd7c190be131efca diff --git a/lib/IR/Verifier.cpp b/lib/IR/Verifier.cpp index 1a30d5b5448..49f8a7ca4a1 100644 --- a/lib/IR/Verifier.cpp +++ b/lib/IR/Verifier.cpp @@ -437,7 +437,7 @@ void Verifier::visitGlobalValue(const GlobalValue &GV) { if (GV.hasAppendingLinkage()) { const GlobalVariable *GVar = dyn_cast(&GV); - Assert(GVar && GVar->getType()->getElementType()->isArrayTy(), + Assert(GVar && GVar->getValueType()->isArrayTy(), "Only global arrays can have appending linkage!", GVar); } } @@ -469,7 +469,7 @@ void Verifier::visitGlobalVariable(const GlobalVariable &GV) { "invalid linkage for intrinsic global variable", &GV); // Don't worry about emitting an error for it not being an array, // visitGlobalValue will complain on appending non-array. - if (ArrayType *ATy = dyn_cast(GV.getType()->getElementType())) { + if (ArrayType *ATy = dyn_cast(GV.getValueType())) { StructType *STy = dyn_cast(ATy->getElementType()); PointerType *FuncPtrTy = FunctionType::get(Type::getVoidTy(*Context), false)->getPointerTo(); @@ -1503,7 +1503,7 @@ void Verifier::VerifyStatepoint(ImmutableCallSite CS) { const PointerType *PT = dyn_cast(Target->getType()); Assert(PT && PT->getElementType()->isFunctionTy(), "gc.statepoint callee must be of function pointer type", &CI, Target); - FunctionType *TargetFuncType = cast(PT->getElementType()); + FunctionType *TargetFuncType = CS.getFunctionType(); const Value *NumCallArgsV = CS.getArgument(1); Assert(isa(NumCallArgsV), @@ -1529,9 +1529,12 @@ void Verifier::VerifyStatepoint(ImmutableCallSite CS) { Assert(NumCallArgs == NumParams, "gc.statepoint mismatch in number of call args", &CI); - const Value *Unused = CS.getArgument(2); - Assert(isa(Unused) && cast(Unused)->isNullValue(), - "gc.statepoint parameter #3 must be zero", &CI); + const Value *FlagsV = CS.getArgument(2); + Assert(isa(FlagsV), + "gc.statepoint flags must be constant integer", &CI); + const uint64_t Flags = cast(FlagsV)->getZExtValue(); + Assert((Flags & ~(uint64_t)StatepointFlags::MaskAll) == 0, + "unknown flag used in gc.statepoint flags argument", &CI); // Verify that the types of the call parameter arguments match // the type of the wrapped callee. @@ -1544,7 +1547,19 @@ void Verifier::VerifyStatepoint(ImmutableCallSite CS) { &CI); } const int EndCallArgsInx = 2+NumCallArgs; - const Value *NumDeoptArgsV = CS.getArgument(EndCallArgsInx+1); + + const Value *NumTransitionArgsV = CS.getArgument(EndCallArgsInx+1); + Assert(isa(NumTransitionArgsV), + "gc.statepoint number of transition arguments " + "must be constant integer", + &CI); + const int NumTransitionArgs = + cast(NumTransitionArgsV)->getZExtValue(); + Assert(NumTransitionArgs >= 0, + "gc.statepoint number of transition arguments must be positive", &CI); + const int EndTransitionArgsInx = EndCallArgsInx + 1 + NumTransitionArgs; + + const Value *NumDeoptArgsV = CS.getArgument(EndTransitionArgsInx+1); Assert(isa(NumDeoptArgsV), "gc.statepoint number of deoptimization arguments " "must be constant integer", @@ -1554,7 +1569,9 @@ void Verifier::VerifyStatepoint(ImmutableCallSite CS) { "must be positive", &CI); - Assert(4 + NumCallArgs + NumDeoptArgs <= (int)CS.arg_size(), + const int ExpectedNumArgs = + 5 + NumCallArgs + NumTransitionArgs + NumDeoptArgs; + Assert(ExpectedNumArgs <= (int)CS.arg_size(), "gc.statepoint too few arguments according to length fields", &CI); // Check that the only uses of this gc.statepoint are gc.result or @@ -3048,8 +3065,8 @@ bool Verifier::VerifyIntrinsicType(Type *Ty, dyn_cast(ThisArgVecTy->getVectorElementType()); if (!ThisArgEltTy) return true; - return (!(ThisArgEltTy->getElementType() == - ReferenceType->getVectorElementType())); + return ThisArgEltTy->getElementType() != + ReferenceType->getVectorElementType(); } } llvm_unreachable("unhandled"); @@ -3175,7 +3192,7 @@ void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) { Assert(AI, "llvm.gcroot parameter #1 must be an alloca.", &CI); Assert(isa(CI.getArgOperand(1)), "llvm.gcroot parameter #2 must be a constant.", &CI); - if (!AI->getType()->getElementType()->isPointerTy()) { + if (!AI->getAllocatedType()->isPointerTy()) { Assert(!isa(CI.getArgOperand(1)), "llvm.gcroot parameter #1 must either be a pointer alloca, " "or argument #2 must be a non-null constant.", @@ -3346,11 +3363,17 @@ void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) { Assert(StatepointCS.arg_size() > NumCallArgs+3, "gc.statepoint: mismatch in number of call arguments"); Assert(isa(StatepointCS.getArgument(NumCallArgs+3)), + "gc.statepoint: number of transition arguments must be " + "a constant integer"); + const int NumTransitionArgs = + cast(StatepointCS.getArgument(NumCallArgs + 3))->getZExtValue(); + const int DeoptArgsStart = 2 + NumCallArgs + 1 + NumTransitionArgs + 1; + Assert(isa(StatepointCS.getArgument(DeoptArgsStart)), "gc.statepoint: number of deoptimization arguments must be " "a constant integer"); const int NumDeoptArgs = - cast(StatepointCS.getArgument(NumCallArgs + 3))->getZExtValue(); - const int GCParamArgsStart = NumCallArgs + NumDeoptArgs + 4; + cast(StatepointCS.getArgument(DeoptArgsStart))->getZExtValue(); + const int GCParamArgsStart = DeoptArgsStart + 1 + NumDeoptArgs; const int GCParamArgsEnd = StatepointCS.arg_size(); Assert(GCParamArgsStart <= BaseIndex && BaseIndex < GCParamArgsEnd, "gc.relocate: statepoint base index doesn't fall within the "