Remap the call sites of a shared function in interrupt line functions.
authorSanjiv Gupta <sanjiv.gupta@microchip.com>
Thu, 18 Feb 2010 18:00:35 +0000 (18:00 +0000)
committerSanjiv Gupta <sanjiv.gupta@microchip.com>
Thu, 18 Feb 2010 18:00:35 +0000 (18:00 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96591 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp
lib/Target/PIC16/PIC16Passes/PIC16Cloner.h

index 8e0d51be5d2e18f1e276d22ca3c084bf3c6c07cd..b5cb605679390b0f2972b4a47850a5d7f920395b 100644 (file)
@@ -270,3 +270,27 @@ PIC16Cloner::cloneFunction(Function *OrgF) {
 }
 
 
+// Remap the call sites of shared functions, that are in IL.
+// Change the IL call site of a shared function to its clone.
+//
+void PIC16Cloner::
+remapAllSites(Function *Caller, Function *OrgF, Function *Clone) {
+  // First find the caller to update. If the caller itself is cloned
+  // then use the cloned caller. Otherwise use it.
+  cloned_map_iterator cm_it = ClonedFunctionMap.find(Caller);
+  if (cm_it != ClonedFunctionMap.end())
+    Caller = cm_it->second;
+
+  // For the lack of a better call site finding mechanism, iterate over 
+  // all insns to find the uses of original fn.
+  for (Function::iterator BI = Caller->begin(); BI != Caller->end(); ++BI) {
+    BasicBlock &BB = *BI;
+    for (BasicBlock::iterator II = BB.begin(); II != BB.end(); ++II) {
+      if (II->getNumOperands() > 0 && II->getOperand(0) == OrgF)
+          II->setOperand(0, Clone);
+    }
+  }
+}
+
+
+
index 6e7b162931405dc765be3fbb8c5b9032329f3ce0..24c11527b03c53b3e2a6d5dd863ff4acce30159f 100644 (file)
@@ -55,6 +55,9 @@ namespace llvm {
     // Clone all shared functions.
     void cloneSharedFunctions(CallGraphNode *isrCGN);
 
+    // Remap all call sites to the shared function.
+    void remapAllSites(Function *Caller, Function *OrgF, Function *Clone);
+
     // Error reporting for PIC16Pass
     void reportError(string ErrorString, vector<string> &Values);
     void reportError(string ErrorString);