diff options
author | Chris Lattner <sabre@nondot.org> | 2005-03-22 00:09:45 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-03-22 00:09:45 +0000 |
commit | 612f0b74d49e4876cd2cc737ca6878327f1014eb (patch) | |
tree | 377d6c50fc0fe8a6bee211f5d2f4b20314c78ecb /lib/Analysis/DataStructure/DataStructure.cpp | |
parent | dc77036a82c92fea95defed3218f1086fbd6d22d (diff) |
move this out of line
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20751 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/DataStructure/DataStructure.cpp')
-rw-r--r-- | lib/Analysis/DataStructure/DataStructure.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/Analysis/DataStructure/DataStructure.cpp b/lib/Analysis/DataStructure/DataStructure.cpp index eab91d238f..e2edb1cb72 100644 --- a/lib/Analysis/DataStructure/DataStructure.cpp +++ b/lib/Analysis/DataStructure/DataStructure.cpp @@ -76,6 +76,34 @@ DSNode *DSNodeHandle::HandleForwarding() const { } //===----------------------------------------------------------------------===// +// DSScalarMap Implementation +//===----------------------------------------------------------------------===// + +DSNodeHandle &DSScalarMap::AddGlobal(GlobalValue *GV) { + assert(ValueMap.count(GV) == 0 && "GV already exists!"); + + // If the node doesn't exist, check to see if it's a global that is + // equated to another global in the program. + EquivalenceClasses<GlobalValue*>::iterator ECI = GlobalECs.findValue(GV); + if (ECI != GlobalECs.end()) { + GlobalValue *Leader = *GlobalECs.findLeader(ECI); + if (Leader != GV) { + GV = Leader; + iterator I = ValueMap.find(GV); + if (I != ValueMap.end()) + return I->second; + } + } + + // Okay, this is either not an equivalenced global or it is the leader, it + // will be inserted into the scalar map now. + GlobalSet.insert(GV); + + return ValueMap.insert(std::make_pair(GV, DSNodeHandle())).first->second; +} + + +//===----------------------------------------------------------------------===// // DSNode Implementation //===----------------------------------------------------------------------===// |