aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/PIC16
diff options
context:
space:
mode:
authorSanjiv Gupta <sanjiv.gupta@microchip.com>2010-02-18 18:00:35 +0000
committerSanjiv Gupta <sanjiv.gupta@microchip.com>2010-02-18 18:00:35 +0000
commit18c7a1834bffdc858cba7eff31913ca46db0e195 (patch)
tree6f26caece04216b1ca87db9e1dfb395b66238d1e /lib/Target/PIC16
parentbd426bbf8e9bc5e468e0051f97d594030544b2bc (diff)
downloadexternal_llvm-18c7a1834bffdc858cba7eff31913ca46db0e195.zip
external_llvm-18c7a1834bffdc858cba7eff31913ca46db0e195.tar.gz
external_llvm-18c7a1834bffdc858cba7eff31913ca46db0e195.tar.bz2
Remap the call sites of a shared function in interrupt line functions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96591 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/PIC16')
-rw-r--r--lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp24
-rw-r--r--lib/Target/PIC16/PIC16Passes/PIC16Cloner.h3
2 files changed, 27 insertions, 0 deletions
diff --git a/lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp b/lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp
index 8e0d51b..b5cb605 100644
--- a/lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp
+++ b/lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp
@@ -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);
+ }
+ }
+}
+
+
+
diff --git a/lib/Target/PIC16/PIC16Passes/PIC16Cloner.h b/lib/Target/PIC16/PIC16Passes/PIC16Cloner.h
index 6e7b162..24c1152 100644
--- a/lib/Target/PIC16/PIC16Passes/PIC16Cloner.h
+++ b/lib/Target/PIC16/PIC16Passes/PIC16Cloner.h
@@ -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);