diff options
author | Sanjiv Gupta <sanjiv.gupta@microchip.com> | 2010-02-18 18:00:35 +0000 |
---|---|---|
committer | Sanjiv Gupta <sanjiv.gupta@microchip.com> | 2010-02-18 18:00:35 +0000 |
commit | a124a46748357b9e654adce7a50318a5f0648e48 (patch) | |
tree | ede1b7dbbc0016bbac8f0cd9f04ef451bbf01270 | |
parent | e5faca7cda3e24626dd79447f72bc068f71724a5 (diff) | |
download | bcm5719-llvm-a124a46748357b9e654adce7a50318a5f0648e48.tar.gz bcm5719-llvm-a124a46748357b9e654adce7a50318a5f0648e48.zip |
Remap the call sites of a shared function in interrupt line functions.
llvm-svn: 96591
-rw-r--r-- | llvm/lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp | 24 | ||||
-rw-r--r-- | llvm/lib/Target/PIC16/PIC16Passes/PIC16Cloner.h | 3 |
2 files changed, 27 insertions, 0 deletions
diff --git a/llvm/lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp b/llvm/lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp index 8e0d51be5d2..b5cb6056793 100644 --- a/llvm/lib/Target/PIC16/PIC16Passes/PIC16Cloner.cpp +++ b/llvm/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/llvm/lib/Target/PIC16/PIC16Passes/PIC16Cloner.h b/llvm/lib/Target/PIC16/PIC16Passes/PIC16Cloner.h index 6e7b1629314..24c11527b03 100644 --- a/llvm/lib/Target/PIC16/PIC16Passes/PIC16Cloner.h +++ b/llvm/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); |