[llvm-commits] [llvm] r96591 - in /llvm/trunk/lib/Target/PIC16/PIC16Passes: PIC16Cloner.cpp PIC16Cloner.h

Sanjiv Gupta sanjiv.gupta at microchip.com
Thu Feb 18 10:00:35 PST 2010


Author: sgupta
Date: Thu Feb 18 12:00:35 2010
New Revision: 96591

URL: http://llvm.org/viewvc/llvm-project?rev=96591&view=rev
Log:
Remap the call sites of a shared function  in interrupt line functions.

Modified:
    llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp
    llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.h

Modified: llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp?rev=96591&r1=96590&r2=96591&view=diff

==============================================================================
--- llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp (original)
+++ llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp Thu Feb 18 12:00:35 2010
@@ -270,3 +270,27 @@
 }
 
 
+// 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);
+    }
+  }
+}
+
+
+

Modified: llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.h?rev=96591&r1=96590&r2=96591&view=diff

==============================================================================
--- llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.h (original)
+++ llvm/trunk/lib/Target/PIC16/PIC16Passes/PIC16Cloner.h Thu Feb 18 12:00:35 2010
@@ -55,6 +55,9 @@
     // 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);





More information about the llvm-commits mailing list