aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Christopher <echristo@apple.com>2010-04-16 23:37:20 +0000
committerEric Christopher <echristo@apple.com>2010-04-16 23:37:20 +0000
commit551754c4958086cc6910da7c950f2875e212f5cf (patch)
tree0287e856d7bde9ea8c3e629ffb889a78b778f634
parentf2548caaa8b290aa598bf49c27dff72f7751ba5c (diff)
Revert 101465, it broke internal OpenGL testing.
Probably the best way to know that all getOperand() calls have been handled is to replace that API instead of updating. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101579 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Instructions.h10
-rw-r--r--include/llvm/IntrinsicInst.h62
-rw-r--r--include/llvm/Support/CallSite.h16
-rw-r--r--lib/Analysis/BasicAliasAnalysis.cpp22
-rw-r--r--lib/Analysis/ConstantFolding.cpp4
-rw-r--r--lib/Analysis/IPA/GlobalsModRef.cpp2
-rw-r--r--lib/Analysis/MemoryBuiltins.cpp4
-rw-r--r--lib/Analysis/MemoryDependenceAnalysis.cpp18
-rw-r--r--lib/Analysis/ValueTracking.cpp4
-rw-r--r--lib/Bitcode/Writer/BitcodeWriter.cpp15
-rw-r--r--lib/CodeGen/DwarfEHPrepare.cpp10
-rw-r--r--lib/CodeGen/GCStrategy.cpp6
-rw-r--r--lib/CodeGen/IntrinsicLowering.cpp46
-rw-r--r--lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp13
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp264
-rw-r--r--lib/CodeGen/ShadowStackGC.cpp14
-rw-r--r--lib/CodeGen/SjLjEHPrepare.cpp2
-rw-r--r--lib/Target/CBackend/CBackend.cpp44
-rw-r--r--lib/Target/CppBackend/CPPBackend.cpp21
-rw-r--r--lib/Target/X86/X86FastISel.cpp12
-rw-r--r--lib/Target/X86/X86ISelLowering.cpp4
-rw-r--r--lib/Transforms/IPO/GlobalOpt.cpp26
-rw-r--r--lib/Transforms/IPO/LowerSetJmp.cpp8
-rw-r--r--lib/Transforms/InstCombine/InstCombineCalls.cpp159
-rw-r--r--lib/Transforms/InstCombine/InstCombineCompares.cpp6
-rw-r--r--lib/Transforms/InstCombine/InstCombineShifts.cpp2
-rw-r--r--lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp16
-rw-r--r--lib/Transforms/InstCombine/InstructionCombining.cpp10
-rw-r--r--lib/Transforms/Instrumentation/ProfilingUtils.cpp8
-rw-r--r--lib/Transforms/Scalar/CodeGenPrepare.cpp2
-rw-r--r--lib/Transforms/Scalar/DeadStoreElimination.cpp12
-rw-r--r--lib/Transforms/Scalar/GVN.cpp6
-rw-r--r--lib/Transforms/Scalar/MemCpyOptimizer.cpp2
-rw-r--r--lib/Transforms/Scalar/ScalarReplAggregates.cpp16
-rw-r--r--lib/Transforms/Scalar/SimplifyLibCalls.cpp150
-rw-r--r--lib/Transforms/Scalar/TailRecursionElimination.cpp4
-rw-r--r--lib/Transforms/Utils/AddrModeMatcher.cpp4
-rw-r--r--lib/Transforms/Utils/BuildLibCalls.cpp38
-rw-r--r--lib/Transforms/Utils/InlineFunction.cpp2
-rw-r--r--lib/VMCore/AsmWriter.cpp11
-rw-r--r--lib/VMCore/AutoUpgrade.cpp31
-rw-r--r--lib/VMCore/Instructions.cpp24
-rw-r--r--lib/VMCore/IntrinsicInst.cpp6
-rw-r--r--lib/VMCore/Verifier.cpp31
44 files changed, 588 insertions, 579 deletions
diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h
index d6dd94d9e9..413a595ab3 100644
--- a/include/llvm/Instructions.h
+++ b/include/llvm/Instructions.h
@@ -1031,17 +1031,17 @@ public:
/// indirect function invocation.
///
Function *getCalledFunction() const {
- return dyn_cast<Function>(Op<-1>());
+ return dyn_cast<Function>(Op<0>());
}
/// getCalledValue - Get a pointer to the function that is invoked by this
/// instruction.
- const Value *getCalledValue() const { return Op<-1>(); }
- Value *getCalledValue() { return Op<-1>(); }
+ const Value *getCalledValue() const { return Op<0>(); }
+ Value *getCalledValue() { return Op<0>(); }
/// setCalledFunction - Set the function called.
void setCalledFunction(Value* Fn) {
- Op<-1>() = Fn;
+ Op<0>() = Fn;
}
// Methods for support type inquiry through isa, cast, and dyn_cast:
@@ -1071,7 +1071,7 @@ CallInst::CallInst(Value *Func, InputIterator ArgBegin, InputIterator ArgEnd,
->getElementType())->getReturnType(),
Instruction::Call,
OperandTraits<CallInst>::op_end(this) - (ArgEnd - ArgBegin + 1),
- unsigned(ArgEnd - ArgBegin + 1), InsertAtEnd) {
+ (unsigned)(ArgEnd - ArgBegin + 1), InsertAtEnd) {
init(Func, ArgBegin, ArgEnd, NameStr,
typename std::iterator_traits<InputIterator>::iterator_category());
}
diff --git a/include/llvm/IntrinsicInst.h b/include/llvm/IntrinsicInst.h
index 1e8bf8b5c9..5b0e90f5cc 100644
--- a/include/llvm/IntrinsicInst.h
+++ b/include/llvm/IntrinsicInst.h
@@ -43,7 +43,7 @@ namespace llvm {
Intrinsic::ID getIntrinsicID() const {
return (Intrinsic::ID)getCalledFunction()->getIntrinsicID();
}
-
+
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const IntrinsicInst *) { return true; }
static inline bool classof(const CallInst *I) {
@@ -74,7 +74,7 @@ namespace llvm {
static inline bool classof(const Value *V) {
return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
}
-
+
static Value *StripCast(Value *C);
};
@@ -83,7 +83,7 @@ namespace llvm {
class DbgDeclareInst : public DbgInfoIntrinsic {
public:
Value *getAddress() const;
- MDNode *getVariable() const { return cast<MDNode>(getOperand(1)); }
+ MDNode *getVariable() const { return cast<MDNode>(getOperand(2)); }
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const DbgDeclareInst *) { return true; }
@@ -103,9 +103,9 @@ namespace llvm {
Value *getValue();
uint64_t getOffset() const {
return cast<ConstantInt>(
- const_cast<Value*>(getOperand(1)))->getZExtValue();
+ const_cast<Value*>(getOperand(2)))->getZExtValue();
}
- MDNode *getVariable() const { return cast<MDNode>(getOperand(2)); }
+ MDNode *getVariable() const { return cast<MDNode>(getOperand(3)); }
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const DbgValueInst *) { return true; }
@@ -121,19 +121,19 @@ namespace llvm {
///
class MemIntrinsic : public IntrinsicInst {
public:
- Value *getRawDest() const { return const_cast<Value*>(getOperand(0)); }
+ Value *getRawDest() const { return const_cast<Value*>(getOperand(1)); }
- Value *getLength() const { return const_cast<Value*>(getOperand(2)); }
+ Value *getLength() const { return const_cast<Value*>(getOperand(3)); }
ConstantInt *getAlignmentCst() const {
- return cast<ConstantInt>(const_cast<Value*>(getOperand(3)));
+ return cast<ConstantInt>(const_cast<Value*>(getOperand(4)));
}
-
+
unsigned getAlignment() const {
return getAlignmentCst()->getZExtValue();
}
ConstantInt *getVolatileCst() const {
- return cast<ConstantInt>(const_cast<Value*>(getOperand(4)));
+ return cast<ConstantInt>(const_cast<Value*>(getOperand(5)));
}
bool isVolatile() const {
return getVolatileCst()->getZExtValue() != 0;
@@ -149,27 +149,27 @@ namespace llvm {
void setDest(Value *Ptr) {
assert(getRawDest()->getType() == Ptr->getType() &&
"setDest called with pointer of wrong type!");
- setOperand(0, Ptr);
+ setOperand(1, Ptr);
}
void setLength(Value *L) {
assert(getLength()->getType() == L->getType() &&
"setLength called with value of wrong type!");
- setOperand(2, L);
+ setOperand(3, L);
}
-
+
void setAlignment(Constant* A) {
- setOperand(3, A);
+ setOperand(4, A);
}
void setVolatile(Constant* V) {
- setOperand(4, V);
+ setOperand(5, V);
}
const Type *getAlignmentType() const {
- return getOperand(3)->getType();
+ return getOperand(4)->getType();
}
-
+
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const MemIntrinsic *) { return true; }
static inline bool classof(const IntrinsicInst *I) {
@@ -192,14 +192,14 @@ namespace llvm {
public:
/// get* - Return the arguments to the instruction.
///
- Value *getValue() const { return const_cast<Value*>(getOperand(1)); }
-
+ Value *getValue() const { return const_cast<Value*>(getOperand(2)); }
+
void setValue(Value *Val) {
assert(getValue()->getType() == Val->getType() &&
- "setValue called with value of wrong type!");
- setOperand(1, Val);
+ "setSource called with pointer of wrong type!");
+ setOperand(2, Val);
}
-
+
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const MemSetInst *) { return true; }
static inline bool classof(const IntrinsicInst *I) {
@@ -209,26 +209,26 @@ namespace llvm {
return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
}
};
-
+
/// MemTransferInst - This class wraps the llvm.memcpy/memmove intrinsics.
///
class MemTransferInst : public MemIntrinsic {
public:
/// get* - Return the arguments to the instruction.
///
- Value *getRawSource() const { return const_cast<Value*>(getOperand(1)); }
-
+ Value *getRawSource() const { return const_cast<Value*>(getOperand(2)); }
+
/// getSource - This is just like getRawSource, but it strips off any cast
/// instructions that feed it, giving the original input. The returned
/// value is guaranteed to be a pointer.
Value *getSource() const { return getRawSource()->stripPointerCasts(); }
-
+
void setSource(Value *Ptr) {
assert(getRawSource()->getType() == Ptr->getType() &&
"setSource called with pointer of wrong type!");
- setOperand(1, Ptr);
+ setOperand(2, Ptr);
}
-
+
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const MemTransferInst *) { return true; }
static inline bool classof(const IntrinsicInst *I) {
@@ -239,8 +239,8 @@ namespace llvm {
return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
}
};
-
-
+
+
/// MemCpyInst - This class wraps the llvm.memcpy intrinsic.
///
class MemCpyInst : public MemTransferInst {
@@ -282,7 +282,7 @@ namespace llvm {
return isa<IntrinsicInst>(V) && classof(cast<IntrinsicInst>(V));
}
};
-
+
/// MemoryUseIntrinsic - This is the common base class for the memory use
/// marker intrinsics.
///
diff --git a/include/llvm/Support/CallSite.h b/include/llvm/Support/CallSite.h
index 7667ba03e3..0650b61fbc 100644
--- a/include/llvm/Support/CallSite.h
+++ b/include/llvm/Support/CallSite.h
@@ -255,21 +255,27 @@ public:
private:
/// Returns the operand number of the first argument
unsigned getArgumentOffset() const {
+ if (isCall())
+ return 1; // Skip Function (ATM)
+ else
return 0; // Args are at the front
}
unsigned getArgumentEndOffset() const {
if (isCall())
- return 1; // Skip Function
+ return 0; // Unchanged (ATM)
else
return 3; // Skip BB, BB, Function
}
IterTy getCallee() const {
- // FIXME: this is slow, since we do not have the fast versions
- // of the op_*() functions here. See CallSite::getCallee.
- //
- return arg_end();
+ // FIXME: this is slow, since we do not have the fast versions
+ // of the op_*() functions here. See CallSite::getCallee.
+ //
+ if (isCall())
+ return getInstruction()->op_begin(); // Unchanged (ATM)
+ else
+ return getInstruction()->op_end() - 3; // Skip BB, BB, Function
}
};
diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp
index 57422b2304..cfe7a1c0ca 100644
--- a/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/lib/Analysis/BasicAliasAnalysis.cpp
@@ -94,7 +94,7 @@ static bool isObjectSmallerThan(const Value *V, unsigned Size,
} else if (const CallInst* CI = extractMallocCall(V)) {
if (!isArrayMalloc(V, &TD))
// The size is the argument to the malloc call.
- if (const ConstantInt* C = dyn_cast<ConstantInt>(CI->getOperand(0)))
+ if (const ConstantInt* C = dyn_cast<ConstantInt>(CI->getOperand(1)))
return (C->getZExtValue() < Size);
return false;
} else if (const Argument *A = dyn_cast<Argument>(V)) {
@@ -318,10 +318,10 @@ BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
case Intrinsic::memcpy:
case Intrinsic::memmove: {
unsigned Len = ~0U;
- if (ConstantInt *LenCI = dyn_cast<ConstantInt>(II->getOperand(2)))
+ if (ConstantInt *LenCI = dyn_cast<ConstantInt>(II->getOperand(3)))
Len = LenCI->getZExtValue();
- Value *Dest = II->getOperand(0);
- Value *Src = II->getOperand(1);
+ Value *Dest = II->getOperand(1);
+ Value *Src = II->getOperand(2);
if (isNoAlias(Dest, Len, P, Size)) {
if (isNoAlias(Src, Len, P, Size))
return NoModRef;
@@ -332,9 +332,9 @@ BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
case Intrinsic::memset:
// Since memset is 'accesses arguments' only, the AliasAnalysis base class
// will handle it for the variable length case.
- if (ConstantInt *LenCI = dyn_cast<ConstantInt>(II->getOperand(2))) {
+ if (ConstantInt *LenCI = dyn_cast<ConstantInt>(II->getOperand(3))) {
unsigned Len = LenCI->getZExtValue();
- Value *Dest = II->getOperand(0);
+ Value *Dest = II->getOperand(1);
if (isNoAlias(Dest, Len, P, Size))
return NoModRef;
}
@@ -352,7 +352,7 @@ BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
case Intrinsic::atomic_load_umax:
case Intrinsic::atomic_load_umin:
if (TD) {
- Value *Op1 = II->getOperand(0);
+ Value *Op1 = II->getOperand(1);
unsigned Op1Size = TD->getTypeStoreSize(Op1->getType());
if (isNoAlias(Op1, Op1Size, P, Size))
return NoModRef;
@@ -361,14 +361,14 @@ BasicAliasAnalysis::getModRefInfo(CallSite CS, Value *P, unsigned Size) {
case Intrinsic::lifetime_start:
case Intrinsic::lifetime_end:
case Intrinsic::invariant_start: {
- unsigned PtrSize = cast<ConstantInt>(II->getOperand(0))->getZExtValue();
- if (isNoAlias(II->getOperand(1), PtrSize, P, Size))
+ unsigned PtrSize = cast<ConstantInt>(II->getOperand(1))->getZExtValue();
+ if (isNoAlias(II->getOperand(2), PtrSize, P, Size))
return NoModRef;
break;
}
case Intrinsic::invariant_end: {
- unsigned PtrSize = cast<ConstantInt>(II->getOperand(1))->getZExtValue();
- if (isNoAlias(II->getOperand(2), PtrSize, P, Size))
+ unsigned PtrSize = cast<ConstantInt>(II->getOperand(2))->getZExtValue();
+ if (isNoAlias(II->getOperand(3), PtrSize, P, Size))
return NoModRef;
break;
}
diff --git a/lib/Analysis/ConstantFolding.cpp b/lib/Analysis/ConstantFolding.cpp
index 0723443018..37cda02210 100644
--- a/lib/Analysis/ConstantFolding.cpp
+++ b/lib/Analysis/ConstantFolding.cpp
@@ -772,9 +772,9 @@ Constant *llvm::ConstantFoldInstOperands(unsigned Opcode, const Type *DestTy,
case Instruction::ICmp:
case Instruction::FCmp: assert(0 && "Invalid for compares");
case Instruction::Call:
- if (Function *F = dyn_cast<Function>(Ops[NumOps - 1]))
+ if (Function *F = dyn_cast<Function>(Ops[0]))
if (canConstantFoldCallTo(F))
- return ConstantFoldCall(F, Ops, NumOps - 1);
+ return ConstantFoldCall(F, Ops+1, NumOps-1);
return 0;
case Instruction::PtrToInt:
// If the input is a inttoptr, eliminate the pair. This requires knowing
diff --git a/lib/Analysis/IPA/GlobalsModRef.cpp b/lib/Analysis/IPA/GlobalsModRef.cpp
index a6403d04ce..b14afa3231 100644
--- a/lib/Analysis/IPA/GlobalsModRef.cpp
+++ b/lib/Analysis/IPA/GlobalsModRef.cpp
@@ -252,7 +252,7 @@ bool GlobalsModRef::AnalyzeUsesOfPointer(Value *V,
} else if (CallInst *CI = dyn_cast<CallInst>(*UI)) {
// Make sure that this is just the function being called, not that it is
// passing into the function.
- for (unsigned i = 0, e = CI->getNumOperands() - 1; i != e; ++i)
+ for (unsigned i = 1, e = CI->getNumOperands(); i != e; ++i)
if (CI->getOperand(i) == V) return true;
} else if (InvokeInst *II = dyn_cast<InvokeInst>(*UI)) {
// Make sure that this is just the function being called, not that it is
diff --git a/lib/Analysis/MemoryBuiltins.cpp b/lib/Analysis/MemoryBuiltins.cpp
index d677a69021..89f9743daa 100644
--- a/lib/Analysis/MemoryBuiltins.cpp
+++ b/lib/Analysis/MemoryBuiltins.cpp
@@ -103,7 +103,7 @@ static Value *computeArraySize(const CallInst *CI, const TargetData *TD,
// If malloc calls' arg can be determined to be a multiple of ElementSize,
// return the multiple. Otherwise, return NULL.
- Value *MallocArg = CI->getOperand(0);
+ Value *MallocArg = CI->getOperand(1);
Value *Multiple = NULL;
if (ComputeMultiple(MallocArg, ElementSize, Multiple,
LookThroughSExt))
@@ -120,7 +120,7 @@ const CallInst *llvm::isArrayMalloc(const Value *I, const TargetData *TD) {
Value *ArraySize = computeArraySize(CI, TD);
if (ArraySize &&
- ArraySize != ConstantInt::get(CI->getOperand(0)->getType(), 1))
+ ArraySize != ConstantInt::get(CI->getOperand(1)->getType(), 1))
return CI;
// CI is a non-array malloc or we can't figure out that it is an array malloc.
diff --git a/lib/Analysis/MemoryDependenceAnalysis.cpp b/lib/Analysis/MemoryDependenceAnalysis.cpp
index d9d085aee6..2aa2f17877 100644
--- a/lib/Analysis/MemoryDependenceAnalysis.cpp
+++ b/lib/Analysis/MemoryDependenceAnalysis.cpp
@@ -117,7 +117,7 @@ getCallSiteDependencyFrom(CallSite CS, bool isReadOnlyCall,
Pointer = V->getOperand(0);
PointerSize = AA->getTypeStoreSize(V->getType());
} else if (isFreeCall(Inst)) {
- Pointer = Inst->getOperand(0);
+ Pointer = Inst->getOperand(1);
// calls to free() erase the entire structure
PointerSize = ~0ULL;
} else if (isa<CallInst>(Inst) || isa<InvokeInst>(Inst)) {
@@ -197,9 +197,9 @@ getPointerDependencyFrom(Value *MemPtr, uint64_t MemSize, bool isLoad,
// pointer, not on query pointers that are indexed off of them. It'd
// be nice to handle that at some point.
AliasAnalysis::AliasResult R =
- AA->alias(II->getOperand(2), ~0U, MemPtr, ~0U);
+ AA->alias(II->getOperand(3), ~0U, MemPtr, ~0U);
if (R == AliasAnalysis::MustAlias) {
- InvariantTag = II->getOperand(0);
+ InvariantTag = II->getOperand(1);
continue;
}
@@ -210,7 +210,7 @@ getPointerDependencyFrom(Value *MemPtr, uint64_t MemSize, bool isLoad,
// pointer, not on query pointers that are indexed off of them. It'd
// be nice to handle that at some point.
AliasAnalysis::AliasResult R =
- AA->alias(II->getOperand(1), ~0U, MemPtr, ~0U);
+ AA->alias(II->getOperand(2), ~0U, MemPtr, ~0U);
if (R == AliasAnalysis::MustAlias)
return MemDepResult::getDef(II);
}
@@ -366,7 +366,7 @@ MemDepResult MemoryDependenceAnalysis::getDependency(Instruction *QueryInst) {
MemSize = AA->getTypeStoreSize(LI->getType());
}
} else if (isFreeCall(QueryInst)) {
- MemPtr = QueryInst->getOperand(0);
+ MemPtr = QueryInst->getOperand(1);
// calls to free() erase the entire structure, not just a field.
MemSize = ~0UL;
} else if (isa<CallInst>(QueryInst) || isa<InvokeInst>(QueryInst)) {
@@ -378,13 +378,13 @@ MemDepResult MemoryDependenceAnalysis::getDependency(Instruction *QueryInst) {
case Intrinsic::lifetime_start:
case Intrinsic::lifetime_end:
case Intrinsic::invariant_start:
- MemPtr = QueryInst->getOperand(1);
- MemSize = cast<ConstantInt>(QueryInst->getOperand(0))->getZExtValue();
- break;
- case Intrinsic::invariant_end:
MemPtr = QueryInst->getOperand(2);
MemSize = cast<ConstantInt>(QueryInst->getOperand(1))->getZExtValue();
break;
+ case Intrinsic::invariant_end:
+ MemPtr = QueryInst->getOperand(3);
+ MemSize = cast<ConstantInt>(QueryInst->getOperand(2))->getZExtValue();
+ break;
default:
CallSite QueryCS = CallSite::get(QueryInst);
bool isReadOnly = AA->onlyReadsMemory(QueryCS);
diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp
index 8c156532f8..7e8ec2e061 100644
--- a/lib/Analysis/ValueTracking.cpp
+++ b/lib/Analysis/ValueTracking.cpp
@@ -953,7 +953,7 @@ bool llvm::CannotBeNegativeZero(const Value *V, unsigned Depth) {
if (const IntrinsicInst *II = dyn_cast<IntrinsicInst>(I))
// sqrt(-0.0) = -0.0, no other negative results are possible.
if (II->getIntrinsicID() == Intrinsic::sqrt)
- return CannotBeNegativeZero(II->getOperand(0), Depth+1);
+ return CannotBeNegativeZero(II->getOperand(1), Depth+1);
if (const CallInst *CI = dyn_cast<CallInst>(I))
if (const Function *F = CI->getCalledFunction()) {
@@ -966,7 +966,7 @@ bool llvm::CannotBeNegativeZero(const Value *V, unsigned Depth) {
if (F->getName() == "fabsl") return true;
if (F->getName() == "sqrt" || F->getName() == "sqrtf" ||
F->getName() == "sqrtl")
- return CannotBeNegativeZero(CI->getOperand(0), Depth+1);
+ return CannotBeNegativeZero(CI->getOperand(1), Depth+1);
}
}
diff --git a/lib/Bitcode/Writer/BitcodeWriter.cpp b/lib/Bitcode/Writer/BitcodeWriter.cpp
index 0a7db2b938..9bda6dca3d 100644
--- a/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -1134,23 +1134,24 @@ static void WriteInstruction(const Instruction &I, unsigned InstID,
Vals.push_back(cast<StoreInst>(I).isVolatile());
break;
case Instruction::Call: {
- const CallInst &CI = cast<CallInst>(I);
- const PointerType *PTy = cast<PointerType>(CI.getCalledValue()->getType());
+ const PointerType *PTy = cast<PointerType>(I.getOperand(0)->getType());
const FunctionType *FTy = cast<FunctionType>(PTy->getElementType());
Code = bitc::FUNC_CODE_INST_CALL;
- Vals.push_back(VE.getAttributeID(CI.getAttributes()));
- Vals.push_back((CI.getCallingConv() << 1) | unsigned(CI.isTailCall()));
- PushValueAndType(CI.getCalledValue(), InstID, Vals, VE); // Callee
+ const CallInst *CI = cast<CallInst>(&I);
+ Vals.push_back(VE.getAttributeID(CI->getAttributes()));
+ Vals.push_back((CI->getCallingConv() << 1) | unsigned(CI->isTailCall()));
+ PushValueAndType(CI->getOperand(0), InstID, Vals, VE); // Callee
// 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+1))); // fixed param.
// Emit type/value pairs for varargs params.
if (FTy->isVarArg()) {
- for (unsigned i = FTy->getNumParams(), e = I.getNumOperands()-1;
+ unsigned NumVarargs = I.getNumOperands()-1-FTy->getNumParams();
+ for (unsigned i = I.getNumOperands()-NumVarargs, e = I.getNumOperands();
i != e; ++i)
PushValueAndType(I.getOperand(i), InstID, Vals, VE); // varargs
}
diff --git a/lib/CodeGen/DwarfEHPrepare.cpp b/lib/CodeGen/DwarfEHPrepare.cpp
index df337436af..d1261a3565 100644
--- a/lib/CodeGen/DwarfEHPrepare.cpp
+++ b/lib/CodeGen/DwarfEHPrepare.cpp
@@ -198,7 +198,7 @@ FindAllCleanupSelectors(SmallPtrSet<IntrinsicInst*, 32> &Sels) {
bool IsCleanUp = (NumOps == 3);
if (!IsCleanUp)
- if (ConstantInt *CI = dyn_cast<ConstantInt>(SI->getOperand(2)))
+ if (ConstantInt *CI = dyn_cast<ConstantInt>(SI->getOperand(3)))
IsCleanUp = (CI->getZExtValue() == 0);
if (IsCleanUp)
@@ -237,7 +237,7 @@ bool DwarfEHPrepare::CleanupSelectors() {
if (!Sel || Sel->getParent()->getParent() != F) continue;
// Index of the ".llvm.eh.catch.all.value" variable.
- unsigned OpIdx = Sel->getNumOperands() - 2;
+ unsigned OpIdx = Sel->getNumOperands() - 1;
GlobalVariable *GV = dyn_cast<GlobalVariable>(Sel->getOperand(OpIdx));
if (GV != EHCatchAllValue) continue;
Sel->setOperand(OpIdx, EHCatchAllValue->getInitializer());
@@ -366,7 +366,7 @@ bool DwarfEHPrepare::HandleURoRInvokes() {
bool IsCleanUp = (NumOps == 3);
if (!IsCleanUp)
- if (ConstantInt *CI = dyn_cast<ConstantInt>(II->getOperand(2)))
+ if (ConstantInt *CI = dyn_cast<ConstantInt>(II->getOperand(3)))
IsCleanUp = (CI->getZExtValue() == 0);
if (IsCleanUp)
@@ -390,8 +390,8 @@ bool DwarfEHPrepare::HandleURoRInvokes() {
// Use the exception object pointer and the personality function
// from the original selector.
- Args.push_back(II->getOperand(0)); // Exception object pointer.
- Args.push_back(II->getOperand(1)); // Personality function.
+ Args.push_back(II->getOperand(1)); // Exception object pointer.
+ Args.push_back(II->getOperand(2)); // Personality function.
Args.push_back(EHCatchAllValue->getInitializer()); // Catch-all indicator.
CallInst *NewSelector =
diff --git a/lib/CodeGen/GCStrategy.cpp b/lib/CodeGen/GCStrategy.cpp
index 97826cdf2a..790cb21648 100644
--- a/lib/CodeGen/GCStrategy.cpp
+++ b/lib/CodeGen/GCStrategy.cpp
@@ -271,7 +271,7 @@ bool LowerIntrinsics::PerformDefaultLowering(Function &F, GCStrategy &S) {
case Intrinsic::gcwrite:
if (LowerWr) {
// Replace a write barrier with a simple store.
- Value *St = new StoreInst(CI->getOperand(0), CI->getOperand(2), CI);
+ Value *St = new StoreInst(CI->getOperand(1), CI->getOperand(3), CI);
CI->replaceAllUsesWith(St);
CI->eraseFromParent();
}
@@ -279,7 +279,7 @@ bool LowerIntrinsics::PerformDefaultLowering(Function &F, GCStrategy &S) {
case Intrinsic::gcread:
if (LowerRd) {
// Replace a read barrier with a simple load.
- Value *Ld = new LoadInst(CI->getOperand(1), "", CI);