From 2d60e1ec0ca2977910c4d8bf3652039d20139eaa Mon Sep 17 00:00:00 2001 From: Gabor Greif Date: Thu, 3 Sep 2009 02:02:59 +0000 Subject: [PATCH] back out my recent commit (r80858), it seems to break self-hosting buildbot's stage 2 configure llvm-svn: 80871 --- llvm/include/llvm/Instructions.h | 18 +++++------ llvm/include/llvm/Support/CallSite.h | 30 ++++--------------- llvm/lib/Analysis/IPA/Andersens.cpp | 2 +- llvm/lib/Analysis/IPA/GlobalsModRef.cpp | 2 +- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 4 +-- .../IPO/DeadArgumentElimination.cpp | 6 ++-- llvm/lib/Transforms/IPO/PruneEH.cpp | 2 +- .../lib/Transforms/Scalar/SimplifyCFGPass.cpp | 2 +- llvm/lib/Transforms/Utils/LowerInvoke.cpp | 4 +-- llvm/lib/VMCore/AsmWriter.cpp | 7 ++--- llvm/lib/VMCore/Instructions.cpp | 17 ++++------- llvm/lib/VMCore/Verifier.cpp | 2 +- 12 files changed, 35 insertions(+), 61 deletions(-) diff --git a/llvm/include/llvm/Instructions.h b/llvm/include/llvm/Instructions.h index ee5af697619f..e6f1c54483a1 100644 --- a/llvm/include/llvm/Instructions.h +++ b/llvm/include/llvm/Instructions.h @@ -2466,26 +2466,27 @@ public: /// indirect function invocation. /// Function *getCalledFunction() const { - return dyn_cast(Op<-3>()); + return dyn_cast(getOperand(0)); } /// getCalledValue - Get a pointer to the function that is invoked by this /// instruction - const Value *getCalledValue() const { return Op<-3>(); } - Value *getCalledValue() { return Op<-3>(); } + const Value *getCalledValue() const { return getOperand(0); } + Value *getCalledValue() { return getOperand(0); } // get*Dest - Return the destination basic blocks... BasicBlock *getNormalDest() const { - return cast(Op<-2>()); + return cast(getOperand(1)); } BasicBlock *getUnwindDest() const { - return cast(Op<-1>()); + return cast(getOperand(2)); } void setNormalDest(BasicBlock *B) { - Op<-2>() = B; + setOperand(1, B); } + void setUnwindDest(BasicBlock *B) { - Op<-1>() = B; + setOperand(2, B); } BasicBlock *getSuccessor(unsigned i) const { @@ -2495,7 +2496,7 @@ public: void setSuccessor(unsigned idx, BasicBlock *NewSucc) { assert(idx < 2 && "Successor # out of range for invoke!"); - *(&Op<-2>() + idx) = NewSucc; + setOperand(idx+1, NewSucc); } unsigned getNumSuccessors() const { return 2; } @@ -2508,7 +2509,6 @@ public: static inline bool classof(const Value *V) { return isa(V) && classof(cast(V)); } - private: virtual BasicBlock *getSuccessorV(unsigned idx) const; virtual unsigned getNumSuccessorsV() const; diff --git a/llvm/include/llvm/Support/CallSite.h b/llvm/include/llvm/Support/CallSite.h index 5bfcc6d84ffa..285b558afccb 100644 --- a/llvm/include/llvm/Support/CallSite.h +++ b/llvm/include/llvm/Support/CallSite.h @@ -118,7 +118,7 @@ public: /// Value *getCalledValue() const { assert(getInstruction() && "Not a call or invoke instruction!"); - return *getCallee(); + return getInstruction()->getOperand(0); } /// getCalledFunction - Return the function being called if this is a direct @@ -132,7 +132,7 @@ public: /// void setCalledFunction(Value *V) { assert(getInstruction() && "Not a call or invoke instruction!"); - *getCallee() = V; + getInstruction()->setOperand(0, V); } Value *getArgument(unsigned ArgNo) const { @@ -146,16 +146,6 @@ public: getInstruction()->setOperand(getArgumentOffset() + ArgNo, newVal); } - /// Given a value use iterator, returns the argument that corresponds to it. - /// Iterator must actually correspond to an argument. - unsigned getArgumentNo(Value::use_iterator I) const { - assert(getInstruction() && "Not a call or invoke instruction!"); - assert(arg_begin() <= &I.getUse() && &I.getUse() < arg_end() - && "Argument # out of range!"); - - return &I.getUse() - arg_begin(); - } - /// Given an operand number, returns the argument that corresponds to it. /// OperandNo must be a valid operand number that actually corresponds to an /// argument. @@ -181,7 +171,7 @@ public: return getInstruction()->op_begin() + getArgumentOffset(); } - arg_iterator arg_end() const { return getInstruction()->op_end() - getArgumentEndOffset(); } + arg_iterator arg_end() const { return getInstruction()->op_end(); } bool arg_empty() const { return arg_end() == arg_begin(); } unsigned arg_size() const { return unsigned(arg_end() - arg_begin()); } @@ -190,25 +180,17 @@ public: } bool isCallee(Value::use_iterator UI) const { - return getCallee() == &UI.getUse(); + return getInstruction()->op_begin() == &UI.getUse(); } + private: /// Returns the operand number of the first argument unsigned getArgumentOffset() const { if (isCall()) return 1; // Skip Function else - return 0; // Args are at the front + return 3; // Skip Function, BB, BB } - - unsigned getArgumentEndOffset() const { - if (isCall()) - return 0; // Unchanged - else - return 3; // Skip BB, BB, Function - } - - User::op_iterator getCallee() const; }; } // End llvm namespace diff --git a/llvm/lib/Analysis/IPA/Andersens.cpp b/llvm/lib/Analysis/IPA/Andersens.cpp index 6f21a4f2ed94..9de1fcc5c199 100644 --- a/llvm/lib/Analysis/IPA/Andersens.cpp +++ b/llvm/lib/Analysis/IPA/Andersens.cpp @@ -1018,7 +1018,7 @@ bool Andersens::AnalyzeUsesOfFunction(Value *V) { } else if (InvokeInst *II = dyn_cast(*UI)) { // Make sure that this is just the function being called, not that it is // passing into the function. - for (unsigned i = 0, e = II->getNumOperands() - 3; i != e; ++i) + for (unsigned i = 3, e = II->getNumOperands(); i != e; ++i) if (II->getOperand(i) == V) return true; } else if (ConstantExpr *CE = dyn_cast(*UI)) { if (CE->getOpcode() == Instruction::GetElementPtr || diff --git a/llvm/lib/Analysis/IPA/GlobalsModRef.cpp b/llvm/lib/Analysis/IPA/GlobalsModRef.cpp index bfc6e117bdc4..2e9884aa01b4 100644 --- a/llvm/lib/Analysis/IPA/GlobalsModRef.cpp +++ b/llvm/lib/Analysis/IPA/GlobalsModRef.cpp @@ -244,7 +244,7 @@ bool GlobalsModRef::AnalyzeUsesOfPointer(Value *V, } else if (InvokeInst *II = dyn_cast(*UI)) { // Make sure that this is just the function being called, not that it is // passing into the function. - for (unsigned i = 0, e = II->getNumOperands() - 3; i != e; ++i) + for (unsigned i = 3, e = II->getNumOperands(); i != e; ++i) if (II->getOperand(i) == V) return true; } else if (ConstantExpr *CE = dyn_cast(*UI)) { if (CE->getOpcode() == Instruction::GetElementPtr || diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index 3ea963174855..9cb57585762c 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -960,11 +960,11 @@ static void WriteInstruction(const Instruction &I, unsigned InstID, // Emit value #'s for the fixed parameters. for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i) - Vals.push_back(VE.getValueID(I.getOperand(i))); // fixed param. + Vals.push_back(VE.getValueID(I.getOperand(i+3))); // fixed param. // Emit type/value pairs for varargs params. if (FTy->isVarArg()) { - for (unsigned i = FTy->getNumParams(), e = I.getNumOperands()-3; + for (unsigned i = 3+FTy->getNumParams(), e = I.getNumOperands(); i != e; ++i) PushValueAndType(I.getOperand(i), InstID, Vals, VE); // vararg } diff --git a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp index ca11e2d8fd35..79a32f02aace 100644 --- a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp +++ b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp @@ -353,14 +353,14 @@ DAE::Liveness DAE::SurveyUse(Value::use_iterator U, UseVector &MaybeLiveUses, // argument, since if it was the function argument this would be an // indirect call and the we know can't be looking at a value of the // label type (for the invoke instruction). - unsigned ArgNo = CS.getArgumentNo(U); + unsigned ArgNo = CS.getArgumentNo(U.getOperandNo()); if (ArgNo >= F->getFunctionType()->getNumParams()) // The value is passed in through a vararg! Must be live. return Live; - assert(CS.getArgument(ArgNo) - == CS.getInstruction()->getOperand(U.getOperandNo()) + assert(CS.getArgument(ArgNo) + == CS.getInstruction()->getOperand(U.getOperandNo()) && "Argument is not where we expected it"); // Value passed to a normal call. It's only live when the corresponding diff --git a/llvm/lib/Transforms/IPO/PruneEH.cpp b/llvm/lib/Transforms/IPO/PruneEH.cpp index 4533f892f55b..daf81e9259da 100644 --- a/llvm/lib/Transforms/IPO/PruneEH.cpp +++ b/llvm/lib/Transforms/IPO/PruneEH.cpp @@ -169,7 +169,7 @@ bool PruneEH::SimplifyFunction(Function *F) { for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) { if (InvokeInst *II = dyn_cast(BB->getTerminator())) if (II->doesNotThrow()) { - SmallVector Args(II->op_begin(), II->op_end() - 3); + SmallVector Args(II->op_begin()+3, II->op_end()); // Insert a call instruction before the invoke. CallInst *Call = CallInst::Create(II->getCalledValue(), Args.begin(), Args.end(), "", II); diff --git a/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp b/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp index d565eb5e8343..29712b3c13de 100644 --- a/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp +++ b/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp @@ -78,7 +78,7 @@ static void ChangeToUnreachable(Instruction *I, LLVMContext &Context) { /// ChangeToCall - Convert the specified invoke into a normal call. static void ChangeToCall(InvokeInst *II) { BasicBlock *BB = II->getParent(); - SmallVector Args(II->op_begin(), II->op_end() - 3); + SmallVector Args(II->op_begin()+3, II->op_end()); CallInst *NewCall = CallInst::Create(II->getCalledValue(), Args.begin(), Args.end(), "", II); NewCall->takeName(II); diff --git a/llvm/lib/Transforms/Utils/LowerInvoke.cpp b/llvm/lib/Transforms/Utils/LowerInvoke.cpp index 788a2514db25..4ecf6d7ba260 100644 --- a/llvm/lib/Transforms/Utils/LowerInvoke.cpp +++ b/llvm/lib/Transforms/Utils/LowerInvoke.cpp @@ -228,7 +228,7 @@ bool LowerInvoke::insertCheapEHSupport(Function &F) { bool Changed = false; for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB) if (InvokeInst *II = dyn_cast(BB->getTerminator())) { - std::vector CallArgs(II->op_begin(), II->op_end() - 3); + std::vector CallArgs(II->op_begin()+3, II->op_end()); // Insert a normal call instruction... CallInst *NewCall = CallInst::Create(II->getCalledValue(), CallArgs.begin(), CallArgs.end(), "",II); @@ -300,7 +300,7 @@ void LowerInvoke::rewriteExpensiveInvoke(InvokeInst *II, unsigned InvokeNo, CatchSwitch->addCase(InvokeNoC, II->getUnwindDest()); // Insert a normal call instruction. - std::vector CallArgs(II->op_begin(), II->op_end() - 3); + std::vector CallArgs(II->op_begin()+3, II->op_end()); CallInst *NewCall = CallInst::Create(II->getCalledValue(), CallArgs.begin(), CallArgs.end(), "", II); diff --git a/llvm/lib/VMCore/AsmWriter.cpp b/llvm/lib/VMCore/AsmWriter.cpp index 5d5c2e36558c..5062075a46c2 100644 --- a/llvm/lib/VMCore/AsmWriter.cpp +++ b/llvm/lib/VMCore/AsmWriter.cpp @@ -1863,7 +1863,6 @@ void AssemblyWriter::printInstruction(const Instruction &I) { if (PAL.getFnAttributes() != Attribute::None) Out << ' ' << Attribute::getAsString(PAL.getFnAttributes()); } else if (const InvokeInst *II = dyn_cast(&I)) { - Operand = II->getCalledValue(); const PointerType *PTy = cast(Operand->getType()); const FunctionType *FTy = cast(PTy->getElementType()); const Type *RetTy = FTy->getReturnType(); @@ -1900,10 +1899,10 @@ void AssemblyWriter::printInstruction(const Instruction &I) { writeOperand(Operand, true); } Out << '('; - for (unsigned op = 0, Eop = I.getNumOperands() - 3; op < Eop; ++op) { - if (op) + for (unsigned op = 3, Eop = I.getNumOperands(); op < Eop; ++op) { + if (op > 3) Out << ", "; - writeParamOperand(I.getOperand(op), PAL.getParamAttributes(op + 1)); + writeParamOperand(I.getOperand(op), PAL.getParamAttributes(op-2)); } Out << ')'; diff --git a/llvm/lib/VMCore/Instructions.cpp b/llvm/lib/VMCore/Instructions.cpp index d5847ef49362..a12075fe0d9f 100644 --- a/llvm/lib/VMCore/Instructions.cpp +++ b/llvm/lib/VMCore/Instructions.cpp @@ -95,13 +95,6 @@ bool CallSite::hasArgument(const Value *Arg) const { return false; } -User::op_iterator CallSite::getCallee() const { - Instruction *II(getInstruction()); - return isCall() - ? cast(II)->op_begin() - : cast(II)->op_end() - 3; // Skip BB, BB, Function -} - #undef CALLSITE_DELEGATE_GETTER #undef CALLSITE_DELEGATE_SETTER @@ -442,9 +435,10 @@ bool CallInst::paramHasAttr(unsigned i, Attributes attr) const { void InvokeInst::init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException, Value* const *Args, unsigned NumArgs) { assert(NumOperands == 3+NumArgs && "NumOperands not set up?"); - Op<-3>() = Fn; - Op<-2>() = IfNormal; - Op<-1>() = IfException; + Use *OL = OperandList; + OL[0] = Fn; + OL[1] = IfNormal; + OL[2] = IfException; const FunctionType *FTy = cast(cast(Fn->getType())->getElementType()); FTy = FTy; // silence warning. @@ -453,13 +447,12 @@ void InvokeInst::init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException, (FTy->isVarArg() && NumArgs > FTy->getNumParams())) && "Calling a function with bad signature"); - Use *OL = OperandList; for (unsigned i = 0, e = NumArgs; i != e; i++) { assert((i >= FTy->getNumParams() || FTy->getParamType(i) == Args[i]->getType()) && "Invoking a function with a bad signature!"); - OL[i] = Args[i]; + OL[i+3] = Args[i]; } } diff --git a/llvm/lib/VMCore/Verifier.cpp b/llvm/lib/VMCore/Verifier.cpp index 99f54e5a975b..eed4e2d7a67d 100644 --- a/llvm/lib/VMCore/Verifier.cpp +++ b/llvm/lib/VMCore/Verifier.cpp @@ -1412,7 +1412,7 @@ void Verifier::visitInstruction(Instruction &I) { "Instruction does not dominate all uses!", Op, &I); } } else if (isa(I.getOperand(i))) { - Assert1((i == 0 && isa(I)) || (i + 3 == e && isa(I)), + Assert1(i == 0 && (isa(I) || isa(I)), "Cannot take the address of an inline asm!", &I); } }