diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2010-01-05 13:12:22 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2010-01-05 13:12:22 +0000 |
commit | f012705c7e4ca8cf90b6b734ce1d5355daca5ba5 (patch) | |
tree | d1bcdd1cfc5ddc28894a9b9d6cbb2875d922e437 | |
parent | 804272c8d6fd960c47c8cbc1603aba3fe5a65ea8 (diff) | |
download | external_llvm-f012705c7e4ca8cf90b6b734ce1d5355daca5ba5.zip external_llvm-f012705c7e4ca8cf90b6b734ce1d5355daca5ba5.tar.gz external_llvm-f012705c7e4ca8cf90b6b734ce1d5355daca5ba5.tar.bz2 |
Avoid going through the LLVMContext for type equality where it's safe to dereference the type pointer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92726 91177308-0d34-0410-b5e6-96231b3b80d8
25 files changed, 46 insertions, 58 deletions
diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp index 15a9832..01cd531 100644 --- a/lib/AsmParser/LLParser.cpp +++ b/lib/AsmParser/LLParser.cpp @@ -1715,8 +1715,7 @@ Value *LLParser::PerFunctionState::GetVal(const std::string &Name, } // Don't make placeholders with invalid type. - if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty) && - Ty != Type::getLabelTy(F.getContext())) { + if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty) && !Ty->isLabelTy()) { P.Error(Loc, "invalid use of a non-first-class type"); return 0; } @@ -1757,8 +1756,7 @@ Value *LLParser::PerFunctionState::GetVal(unsigned ID, const Type *Ty, return 0; } - if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty) && - Ty != Type::getLabelTy(F.getContext())) { + if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty) && !Ty->isLabelTy()) { P.Error(Loc, "invalid use of a non-first-class type"); return 0; } @@ -2663,8 +2661,7 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) { AttrListPtr PAL = AttrListPtr::get(Attrs.begin(), Attrs.end()); - if (PAL.paramHasAttr(1, Attribute::StructRet) && - RetType != Type::getVoidTy(Context)) + if (PAL.paramHasAttr(1, Attribute::StructRet) && !RetType->isVoidTy()) return Error(RetTypeLoc, "functions with 'sret' argument must return void"); const FunctionType *FT = diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index 7dffafa..98243e0 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -808,7 +808,7 @@ bool BitcodeReader::ParseMetadata() { const Type *Ty = getTypeByID(Record[i], false); if (Ty->isMetadataTy()) Elts.push_back(MDValueList.getValueFwdRef(Record[i+1])); - else if (Ty != Type::getVoidTy(Context)) + else if (!Ty->isVoidTy()) Elts.push_back(ValueList.getValueFwdRef(Record[i+1], Ty)); else Elts.push_back(NULL); @@ -2238,7 +2238,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) { } // Non-void values get registered in the value table for future use. - if (I && I->getType() != Type::getVoidTy(Context)) + if (I && !I->getType()->isVoidTy()) ValueList.AssignValue(I, NextValueNo++); } diff --git a/lib/Bitcode/Writer/ValueEnumerator.cpp b/lib/Bitcode/Writer/ValueEnumerator.cpp index d8128db..861de84 100644 --- a/lib/Bitcode/Writer/ValueEnumerator.cpp +++ b/lib/Bitcode/Writer/ValueEnumerator.cpp @@ -382,7 +382,7 @@ void ValueEnumerator::incorporateFunction(const Function &F) { // Add all of the instructions. for (Function::const_iterator BB = F.begin(), E = F.end(); BB != E; ++BB) { for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I!=E; ++I) { - if (I->getType() != Type::getVoidTy(F.getContext())) + if (!I->getType()->isVoidTy()) EnumerateValue(I); } } diff --git a/lib/CodeGen/IntrinsicLowering.cpp b/lib/CodeGen/IntrinsicLowering.cpp index 3585df2..9997a48 100644 --- a/lib/CodeGen/IntrinsicLowering.cpp +++ b/lib/CodeGen/IntrinsicLowering.cpp @@ -349,12 +349,12 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) { case Intrinsic::setjmp: { Value *V = ReplaceCallWith("setjmp", CI, CI->op_begin() + 1, CI->op_end(), Type::getInt32Ty(Context)); - if (CI->getType() != Type::getVoidTy(Context)) + if (!CI->getType()->isVoidTy()) CI->replaceAllUsesWith(V); break; } case Intrinsic::sigsetjmp: - if (CI->getType() != Type::getVoidTy(Context)) + if (!CI->getType()->isVoidTy()) CI->replaceAllUsesWith(Constant::getNullValue(CI->getType())); break; @@ -508,7 +508,7 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) { } case Intrinsic::flt_rounds: // Lower to "round to the nearest" - if (CI->getType() != Type::getVoidTy(Context)) + if (!CI->getType()->isVoidTy()) CI->replaceAllUsesWith(ConstantInt::get(CI->getType(), 1)); break; case Intrinsic::invariant_start: diff --git a/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp b/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp index e3b25c2..4868c9e 100644 --- a/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp +++ b/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp @@ -113,7 +113,7 @@ void llvm::ComputeValueVTs(const TargetLowering &TLI, const Type *Ty, return; } // Interpret void as zero return values. - if (Ty == Type::getVoidTy(Ty->getContext())) + if (Ty->isVoidTy()) return; // Base case: we can get an EVT for this LLVM IR type. ValueVTs.push_back(TLI.getValueType(Ty)); diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 8811f4a..5e3a3b5 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -3169,7 +3169,7 @@ void SelectionDAGBuilder::visitTargetIntrinsic(CallInst &I, } else if (!HasChain) { Result = DAG.getNode(ISD::INTRINSIC_WO_CHAIN, getCurDebugLoc(), VTs, &Ops[0], Ops.size()); - } else if (I.getType() != Type::getVoidTy(*DAG.getContext())) { + } else if (!I.getType()->isVoidTy()) { Result = DAG.getNode(ISD::INTRINSIC_W_CHAIN, getCurDebugLoc(), VTs, &Ops[0], Ops.size()); } else { @@ -3188,7 +3188,7 @@ void SelectionDAGBuilder::visitTargetIntrinsic(CallInst &I, DAG.setRoot(Chain); } - if (I.getType() != Type::getVoidTy(*DAG.getContext())) { + if (!I.getType()->isVoidTy()) { if (const VectorType *PTy = dyn_cast<VectorType>(I.getType())) { EVT VT = TLI.getValueType(PTy); Result = DAG.getNode(ISD::BIT_CONVERT, getCurDebugLoc(), VT, Result); @@ -5937,7 +5937,7 @@ void SelectionDAGBuilder::visitInlineAsm(CallSite CS) { // The return value of the call is this value. As such, there is no // corresponding argument. - assert(CS.getType() != Type::getVoidTy(*DAG.getContext()) && + assert(!CS.getType()->isVoidTy() && "Bad inline asm!"); if (const StructType *STy = dyn_cast<StructType>(CS.getType())) { OpVT = TLI.getValueType(STy->getElementType(ResNo)); @@ -6107,8 +6107,7 @@ void SelectionDAGBuilder::visitInlineAsm(CallSite CS) { OpInfo.CallOperandVal)); } else { // This is the result value of the call. - assert(CS.getType() != Type::getVoidTy(*DAG.getContext()) && - "Bad inline asm!"); + assert(!CS.getType()->isVoidTy() && "Bad inline asm!"); // Concatenate this output onto the outputs list. RetValRegs.append(OpInfo.AssignedRegs); } diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 61b971e..3073dfe 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -792,7 +792,7 @@ void SelectionDAGISel::SelectAllBasicBlocks(Function &Fn, BI->dump(); } - if (BI->getType() != Type::getVoidTy(*CurDAG->getContext())) { + if (!BI->getType()->isVoidTy()) { unsigned &R = FuncInfo->ValueMap[BI]; if (!R) R = FuncInfo->CreateRegForValue(BI); diff --git a/lib/ExecutionEngine/ExecutionEngine.cpp b/lib/ExecutionEngine/ExecutionEngine.cpp index 6a154cc..35e6922 100644 --- a/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/lib/ExecutionEngine/ExecutionEngine.cpp @@ -343,9 +343,7 @@ int ExecutionEngine::runFunctionAsMain(Function *Fn, // Check main() type unsigned NumArgs = Fn->getFunctionType()->getNumParams(); const FunctionType *FTy = Fn->getFunctionType(); - const Type* PPInt8Ty = - PointerType::getUnqual(PointerType::getUnqual( - Type::getInt8Ty(Fn->getContext()))); + const Type* PPInt8Ty = Type::getInt8PtrTy(Fn->getContext())->getPointerTo(); switch (NumArgs) { case 3: if (FTy->getParamType(2) != PPInt8Ty) { @@ -364,7 +362,7 @@ int ExecutionEngine::runFunctionAsMain(Function *Fn, // FALLS THROUGH case 0: if (!isa<IntegerType>(FTy->getReturnType()) && - FTy->getReturnType() != Type::getVoidTy(FTy->getContext())) { + !FTy->getReturnType()->isVoidTy()) { llvm_report_error("Invalid return type of main() supplied"); } break; diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp index a26fc36..73f5558 100644 --- a/lib/ExecutionEngine/Interpreter/Execution.cpp +++ b/lib/ExecutionEngine/Interpreter/Execution.cpp @@ -602,7 +602,7 @@ void Interpreter::popStackAndReturnValueToCaller(const Type *RetTy, ExecutionContext &CallingSF = ECStack.back(); if (Instruction *I = CallingSF.Caller.getInstruction()) { // Save result... - if (CallingSF.Caller.getType() != Type::getVoidTy(RetTy->getContext())) + if (!CallingSF.Caller.getType()->isVoidTy()) SetValue(I, Result, CallingSF); if (InvokeInst *II = dyn_cast<InvokeInst> (I)) SwitchToNewBasicBlock (II->getNormalDest (), CallingSF); diff --git a/lib/ExecutionEngine/JIT/JIT.cpp b/lib/ExecutionEngine/JIT/JIT.cpp index ebc2567..3eafe5f 100644 --- a/lib/ExecutionEngine/JIT/JIT.cpp +++ b/lib/ExecutionEngine/JIT/JIT.cpp @@ -411,8 +411,7 @@ GenericValue JIT::runFunction(Function *F, // Handle some common cases first. These cases correspond to common `main' // prototypes. - if (RetTy == Type::getInt32Ty(F->getContext()) || - RetTy == Type::getVoidTy(F->getContext())) { + if (RetTy == Type::getInt32Ty(F->getContext()) || RetTy->isVoidTy()) { switch (ArgValues.size()) { case 3: if (FTy->getParamType(0) == Type::getInt32Ty(F->getContext()) && @@ -548,7 +547,7 @@ GenericValue JIT::runFunction(Function *F, "", StubBB); TheCall->setCallingConv(F->getCallingConv()); TheCall->setTailCall(); - if (TheCall->getType() != Type::getVoidTy(F->getContext())) + if (!TheCall->getType()->isVoidTy()) // Return result of the call. ReturnInst::Create(F->getContext(), TheCall, StubBB); else diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp index ac17c22..54a96cf 100644 --- a/lib/Transforms/IPO/GlobalOpt.cpp +++ b/lib/Transforms/IPO/GlobalOpt.cpp @@ -1929,7 +1929,7 @@ GlobalVariable *GlobalOpt::FindGlobalCtors(Module &M) { const PointerType *PFTy = dyn_cast<PointerType>(STy->getElementType(1)); if (!PFTy) return 0; const FunctionType *FTy = dyn_cast<FunctionType>(PFTy->getElementType()); - if (!FTy || FTy->getReturnType() != Type::getVoidTy(M.getContext()) || + if (!FTy || !FTy->getReturnType()->isVoidTy() || FTy->isVarArg() || FTy->getNumParams() != 0) return 0; diff --git a/lib/Transforms/IPO/MergeFunctions.cpp b/lib/Transforms/IPO/MergeFunctions.cpp index 7043871..fa8845b 100644 --- a/lib/Transforms/IPO/MergeFunctions.cpp +++ b/lib/Transforms/IPO/MergeFunctions.cpp @@ -498,7 +498,7 @@ static void ThunkGToF(Function *F, Function *G) { CallInst *CI = CallInst::Create(F, Args.begin(), Args.end(), "", BB); CI->setTailCall(); CI->setCallingConv(F->getCallingConv()); - if (NewG->getReturnType() == Type::getVoidTy(F->getContext())) { + if (NewG->getReturnType()->isVoidTy()) { ReturnInst::Create(F->getContext(), BB); } else if (CI->getType() != NewG->getReturnType()) { Value *BCI = new BitCastInst(CI, NewG->getReturnType(), "", BB); diff --git a/lib/Transforms/IPO/StructRetPromotion.cpp b/lib/Transforms/IPO/StructRetPromotion.cpp index 9f659d5..dda32d0 100644 --- a/lib/Transforms/IPO/StructRetPromotion.cpp +++ b/lib/Transforms/IPO/StructRetPromotion.cpp @@ -96,8 +96,7 @@ CallGraphNode *SRETPromotion::PromoteReturn(CallGraphNode *CGN) { DEBUG(dbgs() << "SretPromotion: Looking at sret function " << F->getName() << "\n"); - assert(F->getReturnType() == Type::getVoidTy(F->getContext()) && - "Invalid function return type"); + assert(F->getReturnType()->isVoidTy() && "Invalid function return type"); Function::arg_iterator AI = F->arg_begin(); const llvm::PointerType *FArgType = dyn_cast<PointerType>(AI->getType()); assert(FArgType && "Invalid sret parameter type"); @@ -358,7 +357,7 @@ bool SRETPromotion::nestedStructType(const StructType *STy) { unsigned Num = STy->getNumElements(); for (unsigned i = 0; i < Num; i++) { const Type *Ty = STy->getElementType(i); - if (!Ty->isSingleValueType() && Ty != Type::getVoidTy(STy->getContext())) + if (!Ty->isSingleValueType() && !Ty->isVoidTy()) return true; } return false; diff --git a/lib/Transforms/InstCombine/InstCombineCasts.cpp b/lib/Transforms/InstCombine/InstCombineCasts.cpp index 404f3b6..36d5d46 100644 --- a/lib/Transforms/InstCombine/InstCombineCasts.cpp +++ b/lib/Transforms/InstCombine/InstCombineCasts.cpp @@ -1027,7 +1027,7 @@ static Value *LookThroughFPExtensions(Value *V) { // See if the value can be truncated to float and then reextended. if (Value *V = FitsInFPType(CFP, APFloat::IEEEsingle)) return V; - if (CFP->getType() == Type::getDoubleTy(V->getContext())) + if (CFP->getType()->isDoubleTy()) return V; // Won't shrink. if (Value *V = FitsInFPType(CFP, APFloat::IEEEdouble)) return V; diff --git a/lib/Transforms/Utils/BasicBlockUtils.cpp b/lib/Transforms/Utils/BasicBlockUtils.cpp index 840fe3e..ac29de6 100644 --- a/lib/Transforms/Utils/BasicBlockUtils.cpp +++ b/lib/Transforms/Utils/BasicBlockUtils.cpp @@ -252,7 +252,7 @@ void llvm::RemoveSuccessor(TerminatorInst *TI, unsigned SuccNum) { Value *RetVal = 0; // Create a value to return... if the function doesn't return null... - if (BB->getParent()->getReturnType() != Type::getVoidTy(TI->getContext())) + if (!BB->getParent()->getReturnType()->isVoidTy()) RetVal = Constant::getNullValue(BB->getParent()->getReturnType()); // Create the return... diff --git a/lib/Transforms/Utils/CodeExtractor.cpp b/lib/Transforms/Utils/CodeExtractor.cpp index 3dc3300..1cd63c6 100644 --- a/lib/Transforms/Utils/CodeExtractor.cpp +++ b/lib/Transforms/Utils/CodeExtractor.cpp @@ -593,7 +593,7 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer, // this should be rewritten as a `ret' // Check if the function should return a value - if (OldFnRetTy == Type::getVoidTy(Context)) { + if (OldFnRetTy->isVoidTy()) { ReturnInst::Create(Context, 0, TheSwitch); // Return void } else if (OldFnRetTy == TheSwitch->getCondition()->getType()) { // return what we have diff --git a/lib/Transforms/Utils/InstructionNamer.cpp b/lib/Transforms/Utils/InstructionNamer.cpp index 7f11acf..090af95 100644 --- a/lib/Transforms/Utils/InstructionNamer.cpp +++ b/lib/Transforms/Utils/InstructionNamer.cpp @@ -32,7 +32,7 @@ namespace { bool runOnFunction(Function &F) { for (Function::arg_iterator AI = F.arg_begin(), AE = F.arg_end(); AI != AE; ++AI) - if (!AI->hasName() && AI->getType() != Type::getVoidTy(F.getContext())) + if (!AI->hasName() && !AI->getType()->isVoidTy()) AI->setName("arg"); for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) { @@ -40,7 +40,7 @@ namespace { BB->setName("bb"); for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I) - if (!I->hasName() && I->getType() != Type::getVoidTy(F.getContext())) + if (!I->hasName() && !I->getType()->isVoidTy()) I->setName("tmp"); } return true; diff --git a/lib/Transforms/Utils/LowerInvoke.cpp b/lib/Transforms/Utils/LowerInvoke.cpp index 6e6e8d2..766c4d9 100644 --- a/lib/Transforms/Utils/LowerInvoke.cpp +++ b/lib/Transforms/Utils/LowerInvoke.cpp @@ -255,7 +255,7 @@ bool LowerInvoke::insertCheapEHSupport(Function &F) { // Insert a return instruction. This really should be a "barrier", as it // is unreachable. ReturnInst::Create(F.getContext(), - F.getReturnType() == Type::getVoidTy(F.getContext()) ? + F.getReturnType()->isVoidTy() ? 0 : Constant::getNullValue(F.getReturnType()), UI); // Remove the unwind instruction now. diff --git a/lib/Transforms/Utils/SSI.cpp b/lib/Transforms/Utils/SSI.cpp index 1c4afff..4e813dd 100644 --- a/lib/Transforms/Utils/SSI.cpp +++ b/lib/Transforms/Utils/SSI.cpp @@ -416,7 +416,7 @@ bool SSIEverything::runOnFunction(Function &F) { for (Function::iterator B = F.begin(), BE = F.end(); B != BE; ++B) for (BasicBlock::iterator I = B->begin(), E = B->end(); I != E; ++I) - if (I->getType() != Type::getVoidTy(F.getContext())) + if (!I->getType()->isVoidTy()) Insts.push_back(I); ssi.createSSI(Insts); diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp index 0608091..496535a 100644 --- a/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/lib/Transforms/Utils/SimplifyCFG.cpp @@ -753,7 +753,7 @@ HoistTerminator: // Okay, it is safe to hoist the terminator. Instruction *NT = I1->clone(); BIParent->getInstList().insert(BI, NT); - if (NT->getType() != Type::getVoidTy(BB1->getContext())) { + if (!NT->getType()->isVoidTy()) { I1->replaceAllUsesWith(NT); I2->replaceAllUsesWith(NT); NT->takeName(I1); diff --git a/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp b/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp index 30cb94d..3fa8b70 100644 --- a/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp +++ b/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp @@ -112,7 +112,7 @@ bool UnifyFunctionExitNodes::runOnFunction(Function &F) { "UnifiedReturnBlock", &F); PHINode *PN = 0; - if (F.getReturnType() == Type::getVoidTy(F.getContext())) { + if (F.getReturnType()->isVoidTy()) { ReturnInst::Create(F.getContext(), NULL, NewRetBlock); } else { // If the function doesn't return void... add a PHI node to the block... diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp index e04b6d6..f00f6ee 100644 --- a/lib/VMCore/Function.cpp +++ b/lib/VMCore/Function.cpp @@ -189,7 +189,7 @@ void Function::BuildLazyArguments() const { // Create the arguments vector, all arguments start out unnamed. const FunctionType *FT = getFunctionType(); for (unsigned i = 0, e = FT->getNumParams(); i != e; ++i) { - assert(FT->getParamType(i) != Type::getVoidTy(FT->getContext()) && + assert(!FT->getParamType(i)->isVoidTy() && "Cannot have void typed arguments!"); ArgumentList.push_back(new Argument(FT->getParamType(i))); } diff --git a/lib/VMCore/InlineAsm.cpp b/lib/VMCore/InlineAsm.cpp index 16de1af..ec21773 100644 --- a/lib/VMCore/InlineAsm.cpp +++ b/lib/VMCore/InlineAsm.cpp @@ -217,7 +217,7 @@ bool InlineAsm::Verify(const FunctionType *Ty, StringRef ConstStr) { switch (NumOutputs) { case 0: - if (Ty->getReturnType() != Type::getVoidTy(Ty->getContext())) return false; + if (!Ty->getReturnType()->isVoidTy()) return false; break; case 1: if (isa<StructType>(Ty->getReturnType())) return false; diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index 3e9950e..5a787a6 100644 --- a/lib/VMCore/Instructions.cpp +++ b/lib/VMCore/Instructions.cpp @@ -523,8 +523,7 @@ static Instruction *createMalloc(Instruction *InsertBefore, MCall->setCallingConv(F->getCallingConv()); if (!F->doesNotAlias(0)) F->setDoesNotAlias(0); } - assert(MCall->getType() != Type::getVoidTy(BB->getContext()) && - "Malloc has void return type"); + assert(!MCall->getType()->isVoidTy() && "Malloc has void return type"); return Result; } @@ -904,7 +903,7 @@ AllocaInst::AllocaInst(const Type *Ty, Value *ArraySize, : UnaryInstruction(PointerType::getUnqual(Ty), Alloca, getAISize(Ty->getContext(), ArraySize), InsertBefore) { setAlignment(0); - assert(Ty != Type::getVoidTy(Ty->getContext()) && "Cannot allocate void!"); + assert(!Ty->isVoidTy() && "Cannot allocate void!"); setName(Name); } @@ -913,7 +912,7 @@ AllocaInst::AllocaInst(const Type *Ty, Value *ArraySize, : UnaryInstruction(PointerType::getUnqual(Ty), Alloca, getAISize(Ty->getContext(), ArraySize), InsertAtEnd) { setAlignment(0); - assert(Ty != Type::getVoidTy(Ty->getContext()) && "Cannot allocate void!"); + assert(!Ty->isVoidTy() && "Cannot allocate void!"); setName(Name); } @@ -922,7 +921,7 @@ AllocaInst::AllocaInst(const Type *Ty, const Twine &Name, : UnaryInstruction(PointerType::getUnqual(Ty), Alloca, getAISize(Ty->getContext(), 0), InsertBefore) { setAlignment(0); - assert(Ty != Type::getVoidTy(Ty->getContext()) && "Cannot allocate void!"); + assert(!Ty->isVoidTy() && "Cannot allocate void!"); setName(Name); } @@ -931,7 +930,7 @@ AllocaInst::AllocaInst(const Type *Ty, const Twine &Name, : UnaryInstruction(PointerType::getUnqual(Ty), Alloca, getAISize(Ty->getContext(), 0), InsertAtEnd) { setAlignment(0); - assert(Ty != Type::getVoidTy(Ty->getContext()) && "Cannot allocate void!"); + assert(!Ty->isVoidTy() && "Cannot allocate void!"); setName(Name); } @@ -940,7 +939,7 @@ AllocaInst::AllocaInst(const Type *Ty, Value *ArraySize, unsigned Align, : UnaryInstruction(PointerType::getUnqual(Ty), Alloca, getAISize(Ty->getContext(), ArraySize), InsertBefore) { setAlignment(Align); - assert(Ty != Type::getVoidTy(Ty->getContext()) && "Cannot allocate void!"); + assert(!Ty->isVoidTy() && "Cannot allocate void!"); setName(Name); } @@ -949,7 +948,7 @@ AllocaInst::AllocaInst(const Type *Ty, Value *ArraySize, unsigned Align, : UnaryInstruction(PointerType::getUnqual(Ty), Alloca, getAISize(Ty->getContext(), ArraySize), InsertAtEnd) { setAlignment(Align); - assert(Ty != Type::getVoidTy(Ty->getContext()) && "Cannot allocate void!"); + assert(!Ty->isVoidTy() && "Cannot allocate void!"); setName(Name); } diff --git a/lib/VMCore/Value.cpp b/lib/VMCore/Value.cpp index cc9c066..ecf2d4b 100644 --- a/lib/VMCore/Value.cpp +++ b/lib/VMCore/Value.cpp @@ -44,14 +44,12 @@ Value::Value(const Type *ty, unsigned scid) SubclassOptionalData(0), SubclassData(0), VTy(checkType(ty)), UseList(0), Name(0) { if (isa<CallInst>(this) || isa<InvokeInst>(this)) - assert((VTy->isFirstClassType() || - VTy == Type::getVoidTy(ty->getContext()) || + assert((VTy->isFirstClassType() || VTy->isVoidTy() || isa<OpaqueType>(ty) || VTy->getTypeID() == Type::StructTyID) && "invalid CallInst type!"); else if (!isa<Constant>(this) && !isa<BasicBlock>(this)) - assert((VTy->isFirstClassType() || - VTy == Type::getVoidTy(ty->getContext()) || - isa<OpaqueType>(ty)) && + assert((VTy->isFirstClassType() || VTy->isVoidTy() || + isa<OpaqueType>(ty)) && "Cannot create non-first-class values except for constants!"); } @@ -181,8 +179,7 @@ void Value::setName(const Twine &NewName) { if (getName() == StringRef(NameStr, NameLen)) return; - assert(getType() != Type::getVoidTy(getContext()) && - "Cannot assign a name to void values!"); + assert(!getType()->isVoidTy() && "Cannot assign a name to void values!"); // Get the symbol table to update for this object. ValueSymbolTable *ST; |