diff options
author | Gabor Greif <ggreif@gmail.com> | 2010-04-16 01:16:20 +0000 |
---|---|---|
committer | Gabor Greif <ggreif@gmail.com> | 2010-04-16 01:16:20 +0000 |
commit | 607a7ab3da72a2eb53553a520507cbb8068dd1d8 (patch) | |
tree | a24f057eee6bdd4edd74d509424b13bed1dda2de /lib/VMCore | |
parent | 5f0378251c4b682b51d194fce45da1587ed9c97b (diff) | |
download | external_llvm-607a7ab3da72a2eb53553a520507cbb8068dd1d8.zip external_llvm-607a7ab3da72a2eb53553a520507cbb8068dd1d8.tar.gz external_llvm-607a7ab3da72a2eb53553a520507cbb8068dd1d8.tar.bz2 |
back out r101423 and r101397, they break llvm-gcc self-host on darwin10
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101434 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r-- | lib/VMCore/AsmWriter.cpp | 11 | ||||
-rw-r--r-- | lib/VMCore/AutoUpgrade.cpp | 31 | ||||
-rw-r--r-- | lib/VMCore/Instructions.cpp | 24 | ||||
-rw-r--r-- | lib/VMCore/IntrinsicInst.cpp | 6 | ||||
-rw-r--r-- | lib/VMCore/Verifier.cpp | 31 |
5 files changed, 51 insertions, 52 deletions
diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index d732176..6c1aa5e 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -1847,7 +1847,6 @@ void AssemblyWriter::printInstruction(const Instruction &I) { default: Out << " cc" << CI->getCallingConv(); break; } - Operand = CI->getCalledValue(); const PointerType *PTy = cast<PointerType>(Operand->getType()); const FunctionType *FTy = cast<FunctionType>(PTy->getElementType()); const Type *RetTy = FTy->getReturnType(); @@ -1871,10 +1870,10 @@ void AssemblyWriter::printInstruction(const Instruction &I) { writeOperand(Operand, true); } Out << '('; - for (unsigned op = 0, Eop = CI->getNumOperands() - 1; op < Eop; ++op) { - if (op > 0) + for (unsigned op = 1, Eop = I.getNumOperands(); op < Eop; ++op) { + if (op > 1) Out << ", "; - writeParamOperand(CI->getOperand(op), PAL.getParamAttributes(op + 1)); + writeParamOperand(I.getOperand(op), PAL.getParamAttributes(op)); } Out << ')'; if (PAL.getFnAttributes() != Attribute::None) @@ -1918,10 +1917,10 @@ void AssemblyWriter::printInstruction(const Instruction &I) { writeOperand(Operand, true); } Out << '('; - for (unsigned op = 0, Eop = II->getNumOperands() - 3; op < Eop; ++op) { + for (unsigned op = 0, Eop = I.getNumOperands() - 3; op < Eop; ++op) { if (op) Out << ", "; - writeParamOperand(II->getOperand(op), PAL.getParamAttributes(op + 1)); + writeParamOperand(I.getOperand(op), PAL.getParamAttributes(op + 1)); } Out << ')'; diff --git a/lib/VMCore/AutoUpgrade.cpp b/lib/VMCore/AutoUpgrade.cpp index 743553f..4d06b66 100644 --- a/lib/VMCore/AutoUpgrade.cpp +++ b/lib/VMCore/AutoUpgrade.cpp @@ -338,11 +338,11 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) { if (isLoadH || isLoadL || isMovL || isMovSD || isShufPD || isUnpckhPD || isUnpcklPD || isPunpckhQPD || isPunpcklQPD) { std::vector<Constant*> Idxs; - Value *Op0 = CI->getOperand(0); + Value *Op0 = CI->getOperand(1); ShuffleVectorInst *SI = NULL; if (isLoadH || isLoadL) { Value *Op1 = UndefValue::get(Op0->getType()); - Value *Addr = new BitCastInst(CI->getOperand(1), + Value *Addr = new BitCastInst(CI->getOperand(2), Type::getDoublePtrTy(C), "upgraded.", CI); Value *Load = new LoadInst(Addr, "upgraded.", false, 8, CI); @@ -375,7 +375,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) { SI = new ShuffleVectorInst(ZeroV, Op0, Mask, "upgraded.", CI); } else if (isMovSD || isUnpckhPD || isUnpcklPD || isPunpckhQPD || isPunpcklQPD) { - Value *Op1 = CI->getOperand(1); + Value *Op1 = CI->getOperand(2); if (isMovSD) { Idxs.push_back(ConstantInt::get(Type::getInt32Ty(C), 2)); Idxs.push_back(ConstantInt::get(Type::getInt32Ty(C), 1)); @@ -389,8 +389,8 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) { Value *Mask = ConstantVector::get(Idxs); SI = new ShuffleVectorInst(Op0, Op1, Mask, "upgraded.", CI); } else if (isShufPD) { - Value *Op1 = CI->getOperand(1); - unsigned MaskVal = cast<ConstantInt>(CI->getOperand(2))->getZExtValue(); + Value *Op1 = CI->getOperand(2); + unsigned MaskVal = cast<ConstantInt>(CI->getOperand(3))->getZExtValue(); Idxs.push_back(ConstantInt::get(Type::getInt32Ty(C), MaskVal & 1)); Idxs.push_back(ConstantInt::get(Type::getInt32Ty(C), ((MaskVal >> 1) & 1)+2)); @@ -410,8 +410,8 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) { CI->eraseFromParent(); } else if (F->getName() == "llvm.x86.sse41.pmulld") { // Upgrade this set of intrinsics into vector multiplies. - Instruction *Mul = BinaryOperator::CreateMul(CI->getOperand(0), - CI->getOperand(1), + Instruction *Mul = BinaryOperator::CreateMul(CI->getOperand(1), + CI->getOperand(2), CI->getName(), CI); // Fix up all the uses with our new multiply. @@ -438,10 +438,10 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) { case Intrinsic::x86_mmx_psrl_w: { Value *Operands[2]; - Operands[0] = CI->getOperand(0); + Operands[0] = CI->getOperand(1); // Cast the second parameter to the correct type. - BitCastInst *BC = new BitCastInst(CI->getOperand(1), + BitCastInst *BC = new BitCastInst(CI->getOperand(2), NewFn->getFunctionType()->getParamType(1), "upgraded.", CI); Operands[1] = BC; @@ -465,9 +465,9 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) { case Intrinsic::ctlz: case Intrinsic::ctpop: case Intrinsic::cttz: { - // Build a small vector of the 0..(N-1) operands, which are the + // Build a small vector of the 1..(N-1) operands, which are the // parameters. - SmallVector<Value*, 8> Operands(CI->op_begin(), CI->op_end() - 1); + SmallVector<Value*, 8> Operands(CI->op_begin()+1, CI->op_end()); // Construct a new CallInst CallInst *NewCI = CallInst::Create(NewFn, Operands.begin(), Operands.end(), @@ -502,7 +502,7 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) { case Intrinsic::eh_selector: case Intrinsic::eh_typeid_for: { // Only the return type changed. - SmallVector<Value*, 8> Operands(CI->op_begin(), CI->op_end() - 1); + SmallVector<Value*, 8> Operands(CI->op_begin() + 1, CI->op_end()); CallInst *NewCI = CallInst::Create(NewFn, Operands.begin(), Operands.end(), "upgraded." + CI->getName(), CI); NewCI->setTailCall(CI->isTailCall()); @@ -525,8 +525,8 @@ void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) { case Intrinsic::memset: { // Add isVolatile const llvm::Type *I1Ty = llvm::Type::getInt1Ty(CI->getContext()); - Value *Operands[5] = { CI->getOperand(0), CI->getOperand(1), - CI->getOperand(2), CI->getOperand(3), + Value *Operands[5] = { CI->getOperand(1), CI->getOperand(2), + CI->getOperand(3), CI->getOperand(4), llvm::ConstantInt::get(I1Ty, 0) }; CallInst *NewCI = CallInst::Create(NewFn, Operands, Operands+5, CI->getName(), CI); @@ -608,8 +608,7 @@ void llvm::CheckDebugInfoIntrinsics(Module *M) { if (Function *Declare = M->getFunction("llvm.dbg.declare")) { if (!Declare->use_empty()) { DbgDeclareInst *DDI = cast<DbgDeclareInst>(Declare->use_back()); - if (!isa<MDNode>(DDI->getOperand(0)) || - !isa<MDNode>(DDI->getOperand(1))) { + if (!isa<MDNode>(DDI->getOperand(1)) ||!isa<MDNode>(DDI->getOperand(2))) { while (!Declare->use_empty()) { CallInst *CI = cast<CallInst>(Declare->use_back()); CI->eraseFromParent(); diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index 6aef9c7..d5c89c9 100644 --- a/lib/VMCore/Instructions.cpp +++ b/lib/VMCore/Instructions.cpp @@ -33,7 +33,7 @@ using namespace llvm; User::op_iterator CallSite::getCallee() const { Instruction *II(getInstruction()); return isCall() - ? cast<CallInst>(II)->op_end() - 1 // Skip Function + ? cast<CallInst>(II)->op_begin() : cast<InvokeInst>(II)->op_end() - 3; // Skip BB, BB, Function } @@ -231,7 +231,8 @@ CallInst::~CallInst() { void CallInst::init(Value *Func, Value* const *Params, unsigned NumParams) { assert(NumOperands == NumParams+1 && "NumOperands not set up?"); - Op<-1>() = Func; + Use *OL = OperandList; + OL[0] = Func; const FunctionType *FTy = cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType()); @@ -240,21 +241,20 @@ void CallInst::init(Value *Func, Value* const *Params, unsigned NumParams) { assert((NumParams == FTy->getNumParams() || (FTy->isVarArg() && NumParams > FTy->getNumParams())) && "Calling a function with bad signature!"); - - Use *OL = OperandList; for (unsigned i = 0; i != NumParams; ++i) { assert((i >= FTy->getNumParams() || FTy->getParamType(i) == Params[i]->getType()) && "Calling a function with a bad signature!"); - OL[i] = Params[i]; + OL[i+1] = Params[i]; } } void CallInst::init(Value *Func, Value *Actual1, Value *Actual2) { assert(NumOperands == 3 && "NumOperands not set up?"); - Op<-1>() = Func; - Op<0>() = Actual1; - Op<1>() = Actual2; + Use *OL = OperandList; + OL[0] = Func; + OL[1] = Actual1; + OL[2] = Actual2; const FunctionType *FTy = cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType()); @@ -273,8 +273,9 @@ void CallInst::init(Value *Func, Value *Actual1, Value *Actual2) { void CallInst::init(Value *Func, Value *Actual) { assert(NumOperands == 2 && "NumOperands not set up?"); - Op<-1>() = Func; - Op<0>() = Actual; + Use *OL = OperandList; + OL[0] = Func; + OL[1] = Actual; const FunctionType *FTy = cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType()); @@ -290,7 +291,8 @@ void CallInst::init(Value *Func, Value *Actual) { void CallInst::init(Value *Func) { assert(NumOperands == 1 && "NumOperands not set up?"); - Op<-1>() = Func; + Use *OL = OperandList; + OL[0] = Func; const FunctionType *FTy = cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType()); diff --git a/lib/VMCore/IntrinsicInst.cpp b/lib/VMCore/IntrinsicInst.cpp index 098d232..c37d5b0 100644 --- a/lib/VMCore/IntrinsicInst.cpp +++ b/lib/VMCore/IntrinsicInst.cpp @@ -54,7 +54,7 @@ Value *DbgInfoIntrinsic::StripCast(Value *C) { /// Value *DbgDeclareInst::getAddress() const { - if (MDNode* MD = cast_or_null<MDNode>(getOperand(0))) + if (MDNode* MD = cast_or_null<MDNode>(getOperand(1))) return MD->getOperand(0); else return NULL; @@ -65,9 +65,9 @@ Value *DbgDeclareInst::getAddress() const { /// const Value *DbgValueInst::getValue() const { - return cast<MDNode>(getOperand(0))->getOperand(0); + return cast<MDNode>(getOperand(1))->getOperand(0); } Value *DbgValueInst::getValue() { - return cast<MDNode>(getOperand(0))->getOperand(0); + return cast<MDNode>(getOperand(1))->getOperand(0); } diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index e2f7302..daf74bf 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -1396,7 +1396,7 @@ void Verifier::visitInstruction(Instruction &I) { if (Function *F = dyn_cast<Function>(I.getOperand(i))) { // Check to make sure that the "address of" an intrinsic function is never // taken. - Assert1(!F->isIntrinsic() || (i + 1 == e && isa<CallInst>(I)), + Assert1(!F->isIntrinsic() || (i == 0 && isa<CallInst>(I)), "Cannot take the address of an intrinsic!", &I); Assert1(F->getParent() == Mod, "Referencing function in another module!", &I); @@ -1479,8 +1479,7 @@ void Verifier::visitInstruction(Instruction &I) { "Instruction does not dominate all uses!", Op, &I); } } else if (isa<InlineAsm>(I.getOperand(i))) { - Assert1((i + 1 == e && isa<CallInst>(I)) || - (i + 3 == e && isa<InvokeInst>(I)), + Assert1((i == 0 && isa<CallInst>(I)) || (i + 3 == e && isa<InvokeInst>(I)), "Cannot take the address of an inline asm!", &I); } } @@ -1615,16 +1614,16 @@ void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) { default: break; case Intrinsic::dbg_declare: { // llvm.dbg.declare - Assert1(CI.getOperand(0) && isa<MDNode>(CI.getOperand(0)), + Assert1(CI.getOperand(1) && isa<MDNode>(CI.getOperand(1)), "invalid llvm.dbg.declare intrinsic call 1", &CI); - MDNode *MD = cast<MDNode>(CI.getOperand(0)); + MDNode *MD = cast<MDNode>(CI.getOperand(1)); Assert1(MD->getNumOperands() == 1, "invalid llvm.dbg.declare intrinsic call 2", &CI); } break; case Intrinsic::memcpy: case Intrinsic::memmove: case Intrinsic::memset: - Assert1(isa<ConstantInt>(CI.getOperand(3)), + Assert1(isa<ConstantInt>(CI.getOperand(4)), "alignment argument of memory intrinsics must be a constant int", &CI); break; @@ -1633,10 +1632,10 @@ void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) { case Intrinsic::gcread: if (ID == Intrinsic::gcroot) { AllocaInst *AI = - dyn_cast<AllocaInst>(CI.getOperand(0)->stripPointerCasts()); + dyn_cast<AllocaInst>(CI.getOperand(1)->stripPointerCasts()); Assert1(AI && AI->getType()->getElementType()->isPointerTy(), "llvm.gcroot parameter #1 must be a pointer alloca.", &CI); - Assert1(isa<Constant>(CI.getOperand(1)), + Assert1(isa<Constant>(CI.getOperand(2)), "llvm.gcroot parameter #2 must be a constant.", &CI); } @@ -1644,32 +1643,32 @@ void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) { "Enclosing function does not use GC.", &CI); break; case Intrinsic::init_trampoline: - Assert1(isa<Function>(CI.getOperand(1)->stripPointerCasts()), + Assert1(isa<Function>(CI.getOperand(2)->stripPointerCasts()), "llvm.init_trampoline parameter #2 must resolve to a function.", &CI); break; case Intrinsic::prefetch: - Assert1(isa<ConstantInt>(CI.getOperand(1)) && - isa<ConstantInt>(CI.getOperand(2)) && - cast<ConstantInt>(CI.getOperand(1))->getZExtValue() < 2 && - cast<ConstantInt>(CI.getOperand(2))->getZExtValue() < 4, + Assert1(isa<ConstantInt>(CI.getOperand(2)) && + isa<ConstantInt>(CI.getOperand(3)) && + cast<ConstantInt>(CI.getOperand(2))->getZExtValue() < 2 && + cast<ConstantInt>(CI.getOperand(3))->getZExtValue() < 4, "invalid arguments to llvm.prefetch", &CI); break; case Intrinsic::stackprotector: - Assert1(isa<AllocaInst>(CI.getOperand(1)->stripPointerCasts()), + Assert1(isa<AllocaInst>(CI.getOperand(2)->stripPointerCasts()), "llvm.stackprotector parameter #2 must resolve to an alloca.", &CI); break; case Intrinsic::lifetime_start: case Intrinsic::lifetime_end: case Intrinsic::invariant_start: - Assert1(isa<ConstantInt>(CI.getOperand(0)), + Assert1(isa<ConstantInt>(CI.getOperand(1)), "size argument of memory use markers must be a constant integer", &CI); break; case Intrinsic::invariant_end: - Assert1(isa<ConstantInt>(CI.getOperand(1)), + Assert1(isa<ConstantInt>(CI.getOperand(2)), "llvm.invariant.end parameter #2 must be a constant integer", &CI); break; } |