Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1 | //===-- llvm/CodeGen/MachineModuleInfo.cpp ----------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 081ce94 | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "llvm/CodeGen/MachineModuleInfo.h" |
| 11 | |
| 12 | #include "llvm/Constants.h" |
Chris Lattner | e333017 | 2010-03-14 01:41:15 +0000 | [diff] [blame] | 13 | #include "llvm/DerivedTypes.h" |
| 14 | #include "llvm/GlobalVariable.h" |
| 15 | #include "llvm/Intrinsics.h" |
| 16 | #include "llvm/Instructions.h" |
| 17 | #include "llvm/Module.h" |
Evan Cheng | 833501d | 2008-06-30 07:31:25 +0000 | [diff] [blame] | 18 | #include "llvm/Analysis/ValueTracking.h" |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 19 | #include "llvm/CodeGen/MachineFunctionPass.h" |
| 20 | #include "llvm/CodeGen/MachineFunction.h" |
Evan Cheng | 1b42ac1 | 2008-09-22 22:21:38 +0000 | [diff] [blame] | 21 | #include "llvm/CodeGen/Passes.h" |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 22 | #include "llvm/Target/TargetInstrInfo.h" |
| 23 | #include "llvm/Target/TargetMachine.h" |
| 24 | #include "llvm/Target/TargetOptions.h" |
Chris Lattner | e333017 | 2010-03-14 01:41:15 +0000 | [diff] [blame] | 25 | #include "llvm/MC/MCAsmInfo.h" |
| 26 | #include "llvm/MC/MCSymbol.h" |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 27 | #include "llvm/Support/Dwarf.h" |
Edwin Török | 675d562 | 2009-07-11 20:10:48 +0000 | [diff] [blame] | 28 | #include "llvm/Support/ErrorHandling.h" |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 29 | using namespace llvm; |
| 30 | using namespace llvm::dwarf; |
| 31 | |
| 32 | // Handle the Pass registration stuff necessary to use TargetData's. |
Dan Gohman | 089efff | 2008-05-13 00:00:25 +0000 | [diff] [blame] | 33 | static RegisterPass<MachineModuleInfo> |
Chris Lattner | f485345 | 2010-03-13 20:55:24 +0000 | [diff] [blame] | 34 | X("machinemoduleinfo", "Machine Module Information"); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 35 | char MachineModuleInfo::ID = 0; |
| 36 | |
Chris Lattner | 72ba672 | 2009-09-15 22:44:26 +0000 | [diff] [blame] | 37 | // Out of line virtual method. |
| 38 | MachineModuleInfoImpl::~MachineModuleInfoImpl() {} |
| 39 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 40 | //===----------------------------------------------------------------------===// |
Eric Christopher | 8460363 | 2009-08-26 21:27:09 +0000 | [diff] [blame] | 41 | |
Chris Lattner | f485345 | 2010-03-13 20:55:24 +0000 | [diff] [blame] | 42 | MachineModuleInfo::MachineModuleInfo(const MCAsmInfo &MAI) |
| 43 | : ImmutablePass(&ID), Context(MAI), |
| 44 | ObjFileMMI(0), CurCallSite(0), CallsEHReturn(0), CallsUnwindInit(0), |
| 45 | DbgInfoAvailable(false) { |
Eric Christopher | c87d5ae | 2009-08-26 21:30:49 +0000 | [diff] [blame] | 46 | // Always emit some info, by default "no personality" info. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 47 | Personalities.push_back(NULL); |
| 48 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 49 | |
Chris Lattner | f485345 | 2010-03-13 20:55:24 +0000 | [diff] [blame] | 50 | MachineModuleInfo::MachineModuleInfo() |
| 51 | : ImmutablePass(&ID), Context(*(MCAsmInfo*)0) { |
| 52 | assert(0 && "This MachineModuleInfo constructor should never be called, MMI " |
| 53 | "should always be explicitly constructed by LLVMTargetMachine"); |
| 54 | abort(); |
| 55 | } |
| 56 | |
Chris Lattner | 72ba672 | 2009-09-15 22:44:26 +0000 | [diff] [blame] | 57 | MachineModuleInfo::~MachineModuleInfo() { |
Chris Lattner | 16fcdf9 | 2009-09-16 05:26:00 +0000 | [diff] [blame] | 58 | delete ObjFileMMI; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | /// doInitialization - Initialize the state for a new module. |
| 62 | /// |
| 63 | bool MachineModuleInfo::doInitialization() { |
| 64 | return false; |
| 65 | } |
| 66 | |
| 67 | /// doFinalization - Tear down the state after completion of a module. |
| 68 | /// |
| 69 | bool MachineModuleInfo::doFinalization() { |
| 70 | return false; |
| 71 | } |
| 72 | |
Chris Lattner | e333017 | 2010-03-14 01:41:15 +0000 | [diff] [blame] | 73 | /// getLabelSym - Turn a label ID into a symbol. |
| 74 | MCSymbol *MachineModuleInfo::getLabelSym(unsigned ID) { |
| 75 | return Context.GetOrCreateTemporarySymbol |
| 76 | (Twine(Context.getAsmInfo().getPrivateGlobalPrefix()) + "Label" +Twine(ID)); |
| 77 | } |
| 78 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 79 | /// EndFunction - Discard function meta information. |
| 80 | /// |
| 81 | void MachineModuleInfo::EndFunction() { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 82 | // Clean up frame info. |
| 83 | FrameMoves.clear(); |
Eric Christopher | 8460363 | 2009-08-26 21:27:09 +0000 | [diff] [blame] | 84 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 85 | // Clean up exception info. |
| 86 | LandingPads.clear(); |
Jim Grosbach | 1db5d98 | 2010-01-28 01:45:32 +0000 | [diff] [blame] | 87 | CallSiteMap.clear(); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 88 | TypeInfos.clear(); |
| 89 | FilterIds.clear(); |
| 90 | FilterEnds.clear(); |
| 91 | CallsEHReturn = 0; |
| 92 | CallsUnwindInit = 0; |
Devang Patel | f57e106 | 2009-10-08 20:41:17 +0000 | [diff] [blame] | 93 | VariableDbgInfo.clear(); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 94 | } |
| 95 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 96 | /// AnalyzeModule - Scan the module for global debug information. |
| 97 | /// |
| 98 | void MachineModuleInfo::AnalyzeModule(Module &M) { |
Chris Lattner | 1e0e0d1 | 2009-07-20 06:14:25 +0000 | [diff] [blame] | 99 | // Insert functions in the llvm.used array (but not llvm.compiler.used) into |
| 100 | // UsedFunctions. |
Dale Johannesen | 3dadeb3 | 2008-01-16 19:59:28 +0000 | [diff] [blame] | 101 | GlobalVariable *GV = M.getGlobalVariable("llvm.used"); |
| 102 | if (!GV || !GV->hasInitializer()) return; |
| 103 | |
| 104 | // Should be an array of 'i8*'. |
| 105 | ConstantArray *InitList = dyn_cast<ConstantArray>(GV->getInitializer()); |
| 106 | if (InitList == 0) return; |
| 107 | |
Chris Lattner | 2616560 | 2009-07-20 06:05:50 +0000 | [diff] [blame] | 108 | for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i) |
| 109 | if (Function *F = |
| 110 | dyn_cast<Function>(InitList->getOperand(i)->stripPointerCasts())) |
| 111 | UsedFunctions.insert(F); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 112 | } |
| 113 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 114 | //===-EH-------------------------------------------------------------------===// |
| 115 | |
| 116 | /// getOrCreateLandingPadInfo - Find or create an LandingPadInfo for the |
| 117 | /// specified MachineBasicBlock. |
Bill Wendling | 4de8de5 | 2008-07-03 22:53:42 +0000 | [diff] [blame] | 118 | LandingPadInfo &MachineModuleInfo::getOrCreateLandingPadInfo |
| 119 | (MachineBasicBlock *LandingPad) { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 120 | unsigned N = LandingPads.size(); |
| 121 | for (unsigned i = 0; i < N; ++i) { |
| 122 | LandingPadInfo &LP = LandingPads[i]; |
| 123 | if (LP.LandingPadBlock == LandingPad) |
| 124 | return LP; |
| 125 | } |
Eric Christopher | 8460363 | 2009-08-26 21:27:09 +0000 | [diff] [blame] | 126 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 127 | LandingPads.push_back(LandingPadInfo(LandingPad)); |
| 128 | return LandingPads[N]; |
| 129 | } |
| 130 | |
| 131 | /// addInvoke - Provide the begin and end labels of an invoke style call and |
| 132 | /// associate it with a try landing pad block. |
| 133 | void MachineModuleInfo::addInvoke(MachineBasicBlock *LandingPad, |
Chris Lattner | e333017 | 2010-03-14 01:41:15 +0000 | [diff] [blame] | 134 | MCSymbol *BeginLabel, MCSymbol *EndLabel) { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 135 | LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad); |
| 136 | LP.BeginLabels.push_back(BeginLabel); |
| 137 | LP.EndLabels.push_back(EndLabel); |
| 138 | } |
| 139 | |
| 140 | /// addLandingPad - Provide the label of a try LandingPad block. |
| 141 | /// |
| 142 | unsigned MachineModuleInfo::addLandingPad(MachineBasicBlock *LandingPad) { |
Chris Lattner | e333017 | 2010-03-14 01:41:15 +0000 | [diff] [blame] | 143 | unsigned LandingPadID = NextLabelID(); |
| 144 | MCSymbol *LandingPadLabel = getLabelSym(LandingPadID); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 145 | LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad); |
Eric Christopher | 8460363 | 2009-08-26 21:27:09 +0000 | [diff] [blame] | 146 | LP.LandingPadLabel = LandingPadLabel; |
Chris Lattner | e333017 | 2010-03-14 01:41:15 +0000 | [diff] [blame] | 147 | return LandingPadID; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | /// addPersonality - Provide the personality function for the exception |
| 151 | /// information. |
| 152 | void MachineModuleInfo::addPersonality(MachineBasicBlock *LandingPad, |
| 153 | Function *Personality) { |
| 154 | LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad); |
| 155 | LP.Personality = Personality; |
| 156 | |
Bill Wendling | 4de8de5 | 2008-07-03 22:53:42 +0000 | [diff] [blame] | 157 | for (unsigned i = 0; i < Personalities.size(); ++i) |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 158 | if (Personalities[i] == Personality) |
| 159 | return; |
Eric Christopher | 8460363 | 2009-08-26 21:27:09 +0000 | [diff] [blame] | 160 | |
Eric Christopher | c87d5ae | 2009-08-26 21:30:49 +0000 | [diff] [blame] | 161 | // If this is the first personality we're adding go |
| 162 | // ahead and add it at the beginning. |
| 163 | if (Personalities[0] == NULL) |
| 164 | Personalities[0] = Personality; |
| 165 | else |
| 166 | Personalities.push_back(Personality); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 167 | } |
| 168 | |
| 169 | /// addCatchTypeInfo - Provide the catch typeinfo for a landing pad. |
| 170 | /// |
| 171 | void MachineModuleInfo::addCatchTypeInfo(MachineBasicBlock *LandingPad, |
| 172 | std::vector<GlobalVariable *> &TyInfo) { |
| 173 | LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad); |
| 174 | for (unsigned N = TyInfo.size(); N; --N) |
| 175 | LP.TypeIds.push_back(getTypeIDFor(TyInfo[N - 1])); |
| 176 | } |
| 177 | |
| 178 | /// addFilterTypeInfo - Provide the filter typeinfo for a landing pad. |
| 179 | /// |
| 180 | void MachineModuleInfo::addFilterTypeInfo(MachineBasicBlock *LandingPad, |
| 181 | std::vector<GlobalVariable *> &TyInfo) { |
| 182 | LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad); |
Bill Wendling | 993b3dd | 2008-07-07 21:41:57 +0000 | [diff] [blame] | 183 | std::vector<unsigned> IdsInFilter(TyInfo.size()); |
Bill Wendling | 4de8de5 | 2008-07-03 22:53:42 +0000 | [diff] [blame] | 184 | for (unsigned I = 0, E = TyInfo.size(); I != E; ++I) |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 185 | IdsInFilter[I] = getTypeIDFor(TyInfo[I]); |
| 186 | LP.TypeIds.push_back(getFilterIDFor(IdsInFilter)); |
| 187 | } |
| 188 | |
Duncan Sands | 923fdb1 | 2007-08-27 15:47:50 +0000 | [diff] [blame] | 189 | /// addCleanup - Add a cleanup action for a landing pad. |
| 190 | /// |
| 191 | void MachineModuleInfo::addCleanup(MachineBasicBlock *LandingPad) { |
| 192 | LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad); |
| 193 | LP.TypeIds.push_back(0); |
| 194 | } |
| 195 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 196 | /// TidyLandingPads - Remap landing pad labels and remove any deleted landing |
| 197 | /// pads. |
| 198 | void MachineModuleInfo::TidyLandingPads() { |
| 199 | for (unsigned i = 0; i != LandingPads.size(); ) { |
| 200 | LandingPadInfo &LandingPad = LandingPads[i]; |
Chris Lattner | e333017 | 2010-03-14 01:41:15 +0000 | [diff] [blame] | 201 | if (LandingPad.LandingPadLabel && !LandingPad.LandingPadLabel->isDefined()) |
Chris Lattner | 5e42343 | 2010-03-09 01:51:43 +0000 | [diff] [blame] | 202 | LandingPad.LandingPadLabel = 0; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 203 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 204 | // Special case: we *should* emit LPs with null LP MBB. This indicates |
Duncan Sands | 4ff179f | 2007-12-19 07:36:31 +0000 | [diff] [blame] | 205 | // "nounwind" case. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 206 | if (!LandingPad.LandingPadLabel && LandingPad.LandingPadBlock) { |
| 207 | LandingPads.erase(LandingPads.begin() + i); |
| 208 | continue; |
| 209 | } |
Duncan Sands | 241a0c9 | 2007-09-05 11:27:52 +0000 | [diff] [blame] | 210 | |
Chris Lattner | e333017 | 2010-03-14 01:41:15 +0000 | [diff] [blame] | 211 | for (unsigned j = 0, e = LandingPads[i].BeginLabels.size(); j != e; ++j) { |
| 212 | MCSymbol *BeginLabel = LandingPad.BeginLabels[j]; |
| 213 | MCSymbol *EndLabel = LandingPad.EndLabels[j]; |
| 214 | if (BeginLabel->isDefined() && EndLabel->isDefined()) continue; |
| 215 | |
| 216 | LandingPad.BeginLabels.erase(LandingPad.BeginLabels.begin() + j); |
| 217 | LandingPad.EndLabels.erase(LandingPad.EndLabels.begin() + j); |
| 218 | --j, --e; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 219 | } |
Duncan Sands | 241a0c9 | 2007-09-05 11:27:52 +0000 | [diff] [blame] | 220 | |
| 221 | // Remove landing pads with no try-ranges. |
Dan Gohman | 301f405 | 2008-01-29 13:02:09 +0000 | [diff] [blame] | 222 | if (LandingPads[i].BeginLabels.empty()) { |
Duncan Sands | 241a0c9 | 2007-09-05 11:27:52 +0000 | [diff] [blame] | 223 | LandingPads.erase(LandingPads.begin() + i); |
| 224 | continue; |
| 225 | } |
| 226 | |
| 227 | // If there is no landing pad, ensure that the list of typeids is empty. |
| 228 | // If the only typeid is a cleanup, this is the same as having no typeids. |
| 229 | if (!LandingPad.LandingPadBlock || |
| 230 | (LandingPad.TypeIds.size() == 1 && !LandingPad.TypeIds[0])) |
| 231 | LandingPad.TypeIds.clear(); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 232 | ++i; |
| 233 | } |
| 234 | } |
| 235 | |
Eric Christopher | 8460363 | 2009-08-26 21:27:09 +0000 | [diff] [blame] | 236 | /// getTypeIDFor - Return the type id for the specified typeinfo. This is |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 237 | /// function wide. |
| 238 | unsigned MachineModuleInfo::getTypeIDFor(GlobalVariable *TI) { |
Bill Wendling | 4de8de5 | 2008-07-03 22:53:42 +0000 | [diff] [blame] | 239 | for (unsigned i = 0, N = TypeInfos.size(); i != N; ++i) |
| 240 | if (TypeInfos[i] == TI) return i + 1; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 241 | |
| 242 | TypeInfos.push_back(TI); |
| 243 | return TypeInfos.size(); |
| 244 | } |
| 245 | |
| 246 | /// getFilterIDFor - Return the filter id for the specified typeinfos. This is |
| 247 | /// function wide. |
Bill Wendling | 0e679b8 | 2008-06-27 01:27:56 +0000 | [diff] [blame] | 248 | int MachineModuleInfo::getFilterIDFor(std::vector<unsigned> &TyIds) { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 249 | // If the new filter coincides with the tail of an existing filter, then |
| 250 | // re-use the existing filter. Folding filters more than this requires |
| 251 | // re-ordering filters and/or their elements - probably not worth it. |
| 252 | for (std::vector<unsigned>::iterator I = FilterEnds.begin(), |
| 253 | E = FilterEnds.end(); I != E; ++I) { |
Bill Wendling | 0e679b8 | 2008-06-27 01:27:56 +0000 | [diff] [blame] | 254 | unsigned i = *I, j = TyIds.size(); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 255 | |
| 256 | while (i && j) |
| 257 | if (FilterIds[--i] != TyIds[--j]) |
| 258 | goto try_next; |
| 259 | |
| 260 | if (!j) |
| 261 | // The new filter coincides with range [i, end) of the existing filter. |
| 262 | return -(1 + i); |
Bill Wendling | 0e679b8 | 2008-06-27 01:27:56 +0000 | [diff] [blame] | 263 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 264 | try_next:; |
| 265 | } |
| 266 | |
| 267 | // Add the new filter. |
Bill Wendling | 0e679b8 | 2008-06-27 01:27:56 +0000 | [diff] [blame] | 268 | int FilterID = -(1 + FilterIds.size()); |
| 269 | FilterIds.reserve(FilterIds.size() + TyIds.size() + 1); |
| 270 | for (unsigned I = 0, N = TyIds.size(); I != N; ++I) |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 271 | FilterIds.push_back(TyIds[I]); |
Bill Wendling | 0e679b8 | 2008-06-27 01:27:56 +0000 | [diff] [blame] | 272 | FilterEnds.push_back(FilterIds.size()); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 273 | FilterIds.push_back(0); // terminator |
| 274 | return FilterID; |
| 275 | } |
| 276 | |
| 277 | /// getPersonality - Return the personality function for the current function. |
| 278 | Function *MachineModuleInfo::getPersonality() const { |
| 279 | // FIXME: Until PR1414 will be fixed, we're using 1 personality function per |
| 280 | // function |
| 281 | return !LandingPads.empty() ? LandingPads[0].Personality : NULL; |
| 282 | } |
| 283 | |
| 284 | /// getPersonalityIndex - Return unique index for current personality |
Eric Christopher | e92cc8d | 2009-08-26 21:44:57 +0000 | [diff] [blame] | 285 | /// function. NULL/first personality function should always get zero index. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 286 | unsigned MachineModuleInfo::getPersonalityIndex() const { |
| 287 | const Function* Personality = NULL; |
Eric Christopher | 8460363 | 2009-08-26 21:27:09 +0000 | [diff] [blame] | 288 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 289 | // Scan landing pads. If there is at least one non-NULL personality - use it. |
Bill Wendling | 4de8de5 | 2008-07-03 22:53:42 +0000 | [diff] [blame] | 290 | for (unsigned i = 0; i != LandingPads.size(); ++i) |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 291 | if (LandingPads[i].Personality) { |
| 292 | Personality = LandingPads[i].Personality; |
| 293 | break; |
| 294 | } |
Eric Christopher | 8460363 | 2009-08-26 21:27:09 +0000 | [diff] [blame] | 295 | |
Bill Wendling | 4de8de5 | 2008-07-03 22:53:42 +0000 | [diff] [blame] | 296 | for (unsigned i = 0; i < Personalities.size(); ++i) { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 297 | if (Personalities[i] == Personality) |
| 298 | return i; |
Bill Wendling | 4de8de5 | 2008-07-03 22:53:42 +0000 | [diff] [blame] | 299 | } |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 300 | |
Eric Christopher | e92cc8d | 2009-08-26 21:44:57 +0000 | [diff] [blame] | 301 | // This will happen if the current personality function is |
| 302 | // in the zero index. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 303 | return 0; |
| 304 | } |
| 305 | |