[llvm-commits] CVS: llvm/lib/Bytecode/Reader/Reader.cpp

Reid Spencer reid at x10sys.com
Wed Jan 18 23:02:27 PST 2006



Changes in directory llvm/lib/Bytecode/Reader:

Reader.cpp updated: 1.179 -> 1.180
---
Log message:

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.


---
Diffs of the changes:  (+19 -7)

 Reader.cpp |   26 +++++++++++++++++++-------
 1 files changed, 19 insertions(+), 7 deletions(-)


Index: llvm/lib/Bytecode/Reader/Reader.cpp
diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.179 llvm/lib/Bytecode/Reader/Reader.cpp:1.180
--- llvm/lib/Bytecode/Reader/Reader.cpp:1.179	Wed Jan 18 19:21:04 2006
+++ llvm/lib/Bytecode/Reader/Reader.cpp	Thu Jan 19 01:02:16 2006
@@ -670,6 +670,7 @@
                                     getValue(iType, Oprnds[0]),
                                     getValue(iType, Oprnds[1]));
 
+  bool isCall = false;
   switch (Opcode) {
   default:
     if (Result == 0)
@@ -857,13 +858,9 @@
     }
 
     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 @@
     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 @@
     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 @@
     // 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.






More information about the llvm-commits mailing list