summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bytecode
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2006-01-19 07:02:16 +0000
committerReid Spencer <rspencer@reidspencer.com>2006-01-19 07:02:16 +0000
commitbf31906660714fa1cdac4b521663e7636456870a (patch)
tree0770b9b19aa22a40506ccf93622c450a75a4e071 /llvm/lib/Bytecode
parent75b9567671bdd2b20b4f062d222da42945959b87 (diff)
downloadbcm5719-llvm-bf31906660714fa1cdac4b521663e7636456870a.tar.gz
bcm5719-llvm-bf31906660714fa1cdac4b521663e7636456870a.zip
1. Identify bytecode modules that have upgraded intrinsics by setting a
boolean flag if we read a function prototype that needs upgrading. 2. Don't upgrade the CallInst instruction until after its been inserted into the basic block, and only if we know that we have seen an upgraded intrinsic function. llvm-svn: 25448
Diffstat (limited to 'llvm/lib/Bytecode')
-rw-r--r--llvm/lib/Bytecode/Reader/Reader.cpp26
1 files changed, 19 insertions, 7 deletions
diff --git a/llvm/lib/Bytecode/Reader/Reader.cpp b/llvm/lib/Bytecode/Reader/Reader.cpp
index 55e16062306..6c91a4ad6a7 100644
--- a/llvm/lib/Bytecode/Reader/Reader.cpp
+++ b/llvm/lib/Bytecode/Reader/Reader.cpp
@@ -670,6 +670,7 @@ void BytecodeReader::ParseInstruction(std::vector<unsigned> &Oprnds,
getValue(iType, Oprnds[0]),
getValue(iType, Oprnds[1]));
+ bool isCall = false;
switch (Opcode) {
default:
if (Result == 0)
@@ -857,13 +858,9 @@ void BytecodeReader::ParseInstruction(std::vector<unsigned> &Oprnds,
}
Result = new CallInst(F, Params);
- if (CallInst* newCI = UpgradeIntrinsicCall(cast<CallInst>(Result))) {
- Result->replaceAllUsesWith(newCI);
- Result->eraseFromParent();
- Result = newCI;
- }
if (isTailCall) cast<CallInst>(Result)->setTailCall();
if (CallingConv) cast<CallInst>(Result)->setCallingConv(CallingConv);
+ isCall = true;
break;
}
case 56: // Invoke with encoded CC
@@ -1034,6 +1031,15 @@ void BytecodeReader::ParseInstruction(std::vector<unsigned> &Oprnds,
break;
} // end switch(Opcode)
+ BB->getInstList().push_back(Result);
+
+ if (this->hasUpgradedIntrinsicFunctions && isCall)
+ if (Instruction* inst = UpgradeIntrinsicCall(cast<CallInst>(Result))) {
+ Result->replaceAllUsesWith(inst);
+ Result->eraseFromParent();
+ Result = inst;
+ }
+
unsigned TypeSlot;
if (Result->getType() == InstTy)
TypeSlot = iType;
@@ -1041,7 +1047,6 @@ void BytecodeReader::ParseInstruction(std::vector<unsigned> &Oprnds,
TypeSlot = getTypeSlot(Result->getType());
insertValue(Result, TypeSlot, FunctionValues);
- BB->getInstList().push_back(Result);
}
/// Get a particular numbered basic block, which might be a forward reference.
@@ -2026,7 +2031,14 @@ void BytecodeReader::ParseModuleGlobalInfo() {
// Insert the place holder.
Function *Func = new Function(FTy, GlobalValue::ExternalLinkage,
"", TheModule);
- UpgradeIntrinsicFunction(Func);
+
+ // Replace with upgraded intrinsic function, if applicable.
+ if (Function* upgrdF = UpgradeIntrinsicFunction(Func)) {
+ hasUpgradedIntrinsicFunctions = true;
+ Func->eraseFromParent();
+ Func = upgrdF;
+ }
+
insertValue(Func, (FnSignature & (~0U >> 1)) >> 5, ModuleValues);
// Flags are not used yet.
OpenPOWER on IntegriCloud