aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Bitcode
diff options
context:
space:
mode:
authorGabor Greif <ggreif@gmail.com>2010-04-15 10:49:53 +0000
committerGabor Greif <ggreif@gmail.com>2010-04-15 10:49:53 +0000
commit165dac08d1bb8428b32a5f39cdd3dbee2888987f (patch)
treeb96c81333b16aa40af609dd54fa4ea51cfd1f743 /lib/Bitcode
parente6987587d62bb4de0f57e103f677f6bfb43a09f3 (diff)
downloadexternal_llvm-165dac08d1bb8428b32a5f39cdd3dbee2888987f.zip
external_llvm-165dac08d1bb8428b32a5f39cdd3dbee2888987f.tar.gz
external_llvm-165dac08d1bb8428b32a5f39cdd3dbee2888987f.tar.bz2
rotate CallInst operands, i.e. move callee to the back
of the operand array the motivation for this patch are laid out in my mail to llvm-commits: more efficient access to operands and callee, faster callgraph-construction, smaller compiler binary git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101364 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bitcode')
-rw-r--r--lib/Bitcode/Writer/BitcodeWriter.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/Bitcode/Writer/BitcodeWriter.cpp b/lib/Bitcode/Writer/BitcodeWriter.cpp
index 9bda6dc..0a7db2b 100644
--- a/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -1134,24 +1134,23 @@ static void WriteInstruction(const Instruction &I, unsigned InstID,
Vals.push_back(cast<StoreInst>(I).isVolatile());
break;
case Instruction::Call: {
- const PointerType *PTy = cast<PointerType>(I.getOperand(0)->getType());
+ const CallInst &CI = cast<CallInst>(I);
+ const PointerType *PTy = cast<PointerType>(CI.getCalledValue()->getType());
const FunctionType *FTy = cast<FunctionType>(PTy->getElementType());
Code = bitc::FUNC_CODE_INST_CALL;
- 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
+ Vals.push_back(VE.getAttributeID(CI.getAttributes()));
+ Vals.push_back((CI.getCallingConv() << 1) | unsigned(CI.isTailCall()));
+ PushValueAndType(CI.getCalledValue(), 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+1))); // fixed param.
+ Vals.push_back(VE.getValueID(I.getOperand(i))); // fixed param.
// Emit type/value pairs for varargs params.
if (FTy->isVarArg()) {
- unsigned NumVarargs = I.getNumOperands()-1-FTy->getNumParams();
- for (unsigned i = I.getNumOperands()-NumVarargs, e = I.getNumOperands();
+ for (unsigned i = FTy->getNumParams(), e = I.getNumOperands()-1;
i != e; ++i)
PushValueAndType(I.getOperand(i), InstID, Vals, VE); // varargs
}