LLVM API Documentation
00001 //===-- FunctionLoweringInfo.cpp ------------------------------------------===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This implements routines for translating functions from LLVM IR into 00011 // Machine IR. 00012 // 00013 //===----------------------------------------------------------------------===// 00014 00015 #include "llvm/CodeGen/FunctionLoweringInfo.h" 00016 #include "llvm/ADT/PostOrderIterator.h" 00017 #include "llvm/CodeGen/Analysis.h" 00018 #include "llvm/CodeGen/MachineFrameInfo.h" 00019 #include "llvm/CodeGen/MachineFunction.h" 00020 #include "llvm/CodeGen/MachineInstrBuilder.h" 00021 #include "llvm/CodeGen/MachineModuleInfo.h" 00022 #include "llvm/CodeGen/MachineRegisterInfo.h" 00023 #include "llvm/IR/DataLayout.h" 00024 #include "llvm/IR/DebugInfo.h" 00025 #include "llvm/IR/DerivedTypes.h" 00026 #include "llvm/IR/Function.h" 00027 #include "llvm/IR/Instructions.h" 00028 #include "llvm/IR/IntrinsicInst.h" 00029 #include "llvm/IR/LLVMContext.h" 00030 #include "llvm/IR/Module.h" 00031 #include "llvm/Support/Debug.h" 00032 #include "llvm/Support/ErrorHandling.h" 00033 #include "llvm/Support/MathExtras.h" 00034 #include "llvm/Target/TargetFrameLowering.h" 00035 #include "llvm/Target/TargetInstrInfo.h" 00036 #include "llvm/Target/TargetLowering.h" 00037 #include "llvm/Target/TargetOptions.h" 00038 #include "llvm/Target/TargetRegisterInfo.h" 00039 #include "llvm/Target/TargetSubtargetInfo.h" 00040 #include <algorithm> 00041 using namespace llvm; 00042 00043 #define DEBUG_TYPE "function-lowering-info" 00044 00045 /// isUsedOutsideOfDefiningBlock - Return true if this instruction is used by 00046 /// PHI nodes or outside of the basic block that defines it, or used by a 00047 /// switch or atomic instruction, which may expand to multiple basic blocks. 00048 static bool isUsedOutsideOfDefiningBlock(const Instruction *I) { 00049 if (I->use_empty()) return false; 00050 if (isa<PHINode>(I)) return true; 00051 const BasicBlock *BB = I->getParent(); 00052 for (const User *U : I->users()) 00053 if (cast<Instruction>(U)->getParent() != BB || isa<PHINode>(U)) 00054 return true; 00055 00056 return false; 00057 } 00058 00059 void FunctionLoweringInfo::set(const Function &fn, MachineFunction &mf, 00060 SelectionDAG *DAG) { 00061 const TargetLowering *TLI = TM.getSubtargetImpl()->getTargetLowering(); 00062 00063 Fn = &fn; 00064 MF = &mf; 00065 RegInfo = &MF->getRegInfo(); 00066 00067 // Check whether the function can return without sret-demotion. 00068 SmallVector<ISD::OutputArg, 4> Outs; 00069 GetReturnInfo(Fn->getReturnType(), Fn->getAttributes(), Outs, *TLI); 00070 CanLowerReturn = TLI->CanLowerReturn(Fn->getCallingConv(), *MF, 00071 Fn->isVarArg(), 00072 Outs, Fn->getContext()); 00073 00074 // Initialize the mapping of values to registers. This is only set up for 00075 // instruction values that are used outside of the block that defines 00076 // them. 00077 Function::const_iterator BB = Fn->begin(), EB = Fn->end(); 00078 for (; BB != EB; ++BB) 00079 for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); 00080 I != E; ++I) { 00081 if (const AllocaInst *AI = dyn_cast<AllocaInst>(I)) { 00082 // Static allocas can be folded into the initial stack frame adjustment. 00083 if (AI->isStaticAlloca()) { 00084 const ConstantInt *CUI = cast<ConstantInt>(AI->getArraySize()); 00085 Type *Ty = AI->getAllocatedType(); 00086 uint64_t TySize = TLI->getDataLayout()->getTypeAllocSize(Ty); 00087 unsigned Align = 00088 std::max((unsigned)TLI->getDataLayout()->getPrefTypeAlignment(Ty), 00089 AI->getAlignment()); 00090 00091 TySize *= CUI->getZExtValue(); // Get total allocated size. 00092 if (TySize == 0) TySize = 1; // Don't create zero-sized stack objects. 00093 00094 StaticAllocaMap[AI] = 00095 MF->getFrameInfo()->CreateStackObject(TySize, Align, false, AI); 00096 00097 } else { 00098 unsigned Align = std::max( 00099 (unsigned)TLI->getDataLayout()->getPrefTypeAlignment( 00100 AI->getAllocatedType()), 00101 AI->getAlignment()); 00102 unsigned StackAlign = 00103 TM.getSubtargetImpl()->getFrameLowering()->getStackAlignment(); 00104 if (Align <= StackAlign) 00105 Align = 0; 00106 // Inform the Frame Information that we have variable-sized objects. 00107 MF->getFrameInfo()->CreateVariableSizedObject(Align ? Align : 1, AI); 00108 } 00109 } 00110 00111 // Look for inline asm that clobbers the SP register. 00112 if (isa<CallInst>(I) || isa<InvokeInst>(I)) { 00113 ImmutableCallSite CS(I); 00114 if (isa<InlineAsm>(CS.getCalledValue())) { 00115 unsigned SP = TLI->getStackPointerRegisterToSaveRestore(); 00116 std::vector<TargetLowering::AsmOperandInfo> Ops = 00117 TLI->ParseConstraints(CS); 00118 for (size_t I = 0, E = Ops.size(); I != E; ++I) { 00119 TargetLowering::AsmOperandInfo &Op = Ops[I]; 00120 if (Op.Type == InlineAsm::isClobber) { 00121 // Clobbers don't have SDValue operands, hence SDValue(). 00122 TLI->ComputeConstraintToUse(Op, SDValue(), DAG); 00123 std::pair<unsigned, const TargetRegisterClass*> PhysReg = 00124 TLI->getRegForInlineAsmConstraint(Op.ConstraintCode, 00125 Op.ConstraintVT); 00126 if (PhysReg.first == SP) 00127 MF->getFrameInfo()->setHasInlineAsmWithSPAdjust(true); 00128 } 00129 } 00130 } 00131 } 00132 00133 // Look for calls to the @llvm.va_start intrinsic. We can omit some 00134 // prologue boilerplate for variadic functions that don't examine their 00135 // arguments. 00136 if (const auto *II = dyn_cast<IntrinsicInst>(I)) { 00137 if (II->getIntrinsicID() == Intrinsic::vastart) 00138 MF->getFrameInfo()->setHasVAStart(true); 00139 } 00140 00141 // If we have a musttail call in a variadic funciton, we need to ensure we 00142 // forward implicit register parameters. 00143 if (const auto *CI = dyn_cast<CallInst>(I)) { 00144 if (CI->isMustTailCall() && Fn->isVarArg()) 00145 MF->getFrameInfo()->setHasMustTailInVarArgFunc(true); 00146 } 00147 00148 // Mark values used outside their block as exported, by allocating 00149 // a virtual register for them. 00150 if (isUsedOutsideOfDefiningBlock(I)) 00151 if (!isa<AllocaInst>(I) || 00152 !StaticAllocaMap.count(cast<AllocaInst>(I))) 00153 InitializeRegForValue(I); 00154 00155 // Collect llvm.dbg.declare information. This is done now instead of 00156 // during the initial isel pass through the IR so that it is done 00157 // in a predictable order. 00158 if (const DbgDeclareInst *DI = dyn_cast<DbgDeclareInst>(I)) { 00159 MachineModuleInfo &MMI = MF->getMMI(); 00160 DIVariable DIVar(DI->getVariable()); 00161 assert((!DIVar || DIVar.isVariable()) && 00162 "Variable in DbgDeclareInst should be either null or a DIVariable."); 00163 if (MMI.hasDebugInfo() && 00164 DIVar && 00165 !DI->getDebugLoc().isUnknown()) { 00166 // Don't handle byval struct arguments or VLAs, for example. 00167 // Non-byval arguments are handled here (they refer to the stack 00168 // temporary alloca at this point). 00169 const Value *Address = DI->getAddress(); 00170 if (Address) { 00171 if (const BitCastInst *BCI = dyn_cast<BitCastInst>(Address)) 00172 Address = BCI->getOperand(0); 00173 if (const AllocaInst *AI = dyn_cast<AllocaInst>(Address)) { 00174 DenseMap<const AllocaInst *, int>::iterator SI = 00175 StaticAllocaMap.find(AI); 00176 if (SI != StaticAllocaMap.end()) { // Check for VLAs. 00177 int FI = SI->second; 00178 MMI.setVariableDbgInfo(DI->getVariable(), 00179 FI, DI->getDebugLoc()); 00180 } 00181 } 00182 } 00183 } 00184 } 00185 } 00186 00187 // Create an initial MachineBasicBlock for each LLVM BasicBlock in F. This 00188 // also creates the initial PHI MachineInstrs, though none of the input 00189 // operands are populated. 00190 for (BB = Fn->begin(); BB != EB; ++BB) { 00191 MachineBasicBlock *MBB = mf.CreateMachineBasicBlock(BB); 00192 MBBMap[BB] = MBB; 00193 MF->push_back(MBB); 00194 00195 // Transfer the address-taken flag. This is necessary because there could 00196 // be multiple MachineBasicBlocks corresponding to one BasicBlock, and only 00197 // the first one should be marked. 00198 if (BB->hasAddressTaken()) 00199 MBB->setHasAddressTaken(); 00200 00201 // Create Machine PHI nodes for LLVM PHI nodes, lowering them as 00202 // appropriate. 00203 for (BasicBlock::const_iterator I = BB->begin(); 00204 const PHINode *PN = dyn_cast<PHINode>(I); ++I) { 00205 if (PN->use_empty()) continue; 00206 00207 // Skip empty types 00208 if (PN->getType()->isEmptyTy()) 00209 continue; 00210 00211 DebugLoc DL = PN->getDebugLoc(); 00212 unsigned PHIReg = ValueMap[PN]; 00213 assert(PHIReg && "PHI node does not have an assigned virtual register!"); 00214 00215 SmallVector<EVT, 4> ValueVTs; 00216 ComputeValueVTs(*TLI, PN->getType(), ValueVTs); 00217 for (unsigned vti = 0, vte = ValueVTs.size(); vti != vte; ++vti) { 00218 EVT VT = ValueVTs[vti]; 00219 unsigned NumRegisters = TLI->getNumRegisters(Fn->getContext(), VT); 00220 const TargetInstrInfo *TII = MF->getSubtarget().getInstrInfo(); 00221 for (unsigned i = 0; i != NumRegisters; ++i) 00222 BuildMI(MBB, DL, TII->get(TargetOpcode::PHI), PHIReg + i); 00223 PHIReg += NumRegisters; 00224 } 00225 } 00226 } 00227 00228 // Mark landing pad blocks. 00229 for (BB = Fn->begin(); BB != EB; ++BB) 00230 if (const InvokeInst *Invoke = dyn_cast<InvokeInst>(BB->getTerminator())) 00231 MBBMap[Invoke->getSuccessor(1)]->setIsLandingPad(); 00232 } 00233 00234 /// clear - Clear out all the function-specific state. This returns this 00235 /// FunctionLoweringInfo to an empty state, ready to be used for a 00236 /// different function. 00237 void FunctionLoweringInfo::clear() { 00238 assert(CatchInfoFound.size() == CatchInfoLost.size() && 00239 "Not all catch info was assigned to a landing pad!"); 00240 00241 MBBMap.clear(); 00242 ValueMap.clear(); 00243 StaticAllocaMap.clear(); 00244 #ifndef NDEBUG 00245 CatchInfoLost.clear(); 00246 CatchInfoFound.clear(); 00247 #endif 00248 LiveOutRegInfo.clear(); 00249 VisitedBBs.clear(); 00250 ArgDbgValues.clear(); 00251 ByValArgFrameIndexMap.clear(); 00252 RegFixups.clear(); 00253 } 00254 00255 /// CreateReg - Allocate a single virtual register for the given type. 00256 unsigned FunctionLoweringInfo::CreateReg(MVT VT) { 00257 return RegInfo->createVirtualRegister( 00258 TM.getSubtargetImpl()->getTargetLowering()->getRegClassFor(VT)); 00259 } 00260 00261 /// CreateRegs - Allocate the appropriate number of virtual registers of 00262 /// the correctly promoted or expanded types. Assign these registers 00263 /// consecutive vreg numbers and return the first assigned number. 00264 /// 00265 /// In the case that the given value has struct or array type, this function 00266 /// will assign registers for each member or element. 00267 /// 00268 unsigned FunctionLoweringInfo::CreateRegs(Type *Ty) { 00269 const TargetLowering *TLI = TM.getSubtargetImpl()->getTargetLowering(); 00270 00271 SmallVector<EVT, 4> ValueVTs; 00272 ComputeValueVTs(*TLI, Ty, ValueVTs); 00273 00274 unsigned FirstReg = 0; 00275 for (unsigned Value = 0, e = ValueVTs.size(); Value != e; ++Value) { 00276 EVT ValueVT = ValueVTs[Value]; 00277 MVT RegisterVT = TLI->getRegisterType(Ty->getContext(), ValueVT); 00278 00279 unsigned NumRegs = TLI->getNumRegisters(Ty->getContext(), ValueVT); 00280 for (unsigned i = 0; i != NumRegs; ++i) { 00281 unsigned R = CreateReg(RegisterVT); 00282 if (!FirstReg) FirstReg = R; 00283 } 00284 } 00285 return FirstReg; 00286 } 00287 00288 /// GetLiveOutRegInfo - Gets LiveOutInfo for a register, returning NULL if the 00289 /// register is a PHI destination and the PHI's LiveOutInfo is not valid. If 00290 /// the register's LiveOutInfo is for a smaller bit width, it is extended to 00291 /// the larger bit width by zero extension. The bit width must be no smaller 00292 /// than the LiveOutInfo's existing bit width. 00293 const FunctionLoweringInfo::LiveOutInfo * 00294 FunctionLoweringInfo::GetLiveOutRegInfo(unsigned Reg, unsigned BitWidth) { 00295 if (!LiveOutRegInfo.inBounds(Reg)) 00296 return nullptr; 00297 00298 LiveOutInfo *LOI = &LiveOutRegInfo[Reg]; 00299 if (!LOI->IsValid) 00300 return nullptr; 00301 00302 if (BitWidth > LOI->KnownZero.getBitWidth()) { 00303 LOI->NumSignBits = 1; 00304 LOI->KnownZero = LOI->KnownZero.zextOrTrunc(BitWidth); 00305 LOI->KnownOne = LOI->KnownOne.zextOrTrunc(BitWidth); 00306 } 00307 00308 return LOI; 00309 } 00310 00311 /// ComputePHILiveOutRegInfo - Compute LiveOutInfo for a PHI's destination 00312 /// register based on the LiveOutInfo of its operands. 00313 void FunctionLoweringInfo::ComputePHILiveOutRegInfo(const PHINode *PN) { 00314 Type *Ty = PN->getType(); 00315 if (!Ty->isIntegerTy() || Ty->isVectorTy()) 00316 return; 00317 00318 const TargetLowering *TLI = TM.getSubtargetImpl()->getTargetLowering(); 00319 00320 SmallVector<EVT, 1> ValueVTs; 00321 ComputeValueVTs(*TLI, Ty, ValueVTs); 00322 assert(ValueVTs.size() == 1 && 00323 "PHIs with non-vector integer types should have a single VT."); 00324 EVT IntVT = ValueVTs[0]; 00325 00326 if (TLI->getNumRegisters(PN->getContext(), IntVT) != 1) 00327 return; 00328 IntVT = TLI->getTypeToTransformTo(PN->getContext(), IntVT); 00329 unsigned BitWidth = IntVT.getSizeInBits(); 00330 00331 unsigned DestReg = ValueMap[PN]; 00332 if (!TargetRegisterInfo::isVirtualRegister(DestReg)) 00333 return; 00334 LiveOutRegInfo.grow(DestReg); 00335 LiveOutInfo &DestLOI = LiveOutRegInfo[DestReg]; 00336 00337 Value *V = PN->getIncomingValue(0); 00338 if (isa<UndefValue>(V) || isa<ConstantExpr>(V)) { 00339 DestLOI.NumSignBits = 1; 00340 APInt Zero(BitWidth, 0); 00341 DestLOI.KnownZero = Zero; 00342 DestLOI.KnownOne = Zero; 00343 return; 00344 } 00345 00346 if (ConstantInt *CI = dyn_cast<ConstantInt>(V)) { 00347 APInt Val = CI->getValue().zextOrTrunc(BitWidth); 00348 DestLOI.NumSignBits = Val.getNumSignBits(); 00349 DestLOI.KnownZero = ~Val; 00350 DestLOI.KnownOne = Val; 00351 } else { 00352 assert(ValueMap.count(V) && "V should have been placed in ValueMap when its" 00353 "CopyToReg node was created."); 00354 unsigned SrcReg = ValueMap[V]; 00355 if (!TargetRegisterInfo::isVirtualRegister(SrcReg)) { 00356 DestLOI.IsValid = false; 00357 return; 00358 } 00359 const LiveOutInfo *SrcLOI = GetLiveOutRegInfo(SrcReg, BitWidth); 00360 if (!SrcLOI) { 00361 DestLOI.IsValid = false; 00362 return; 00363 } 00364 DestLOI = *SrcLOI; 00365 } 00366 00367 assert(DestLOI.KnownZero.getBitWidth() == BitWidth && 00368 DestLOI.KnownOne.getBitWidth() == BitWidth && 00369 "Masks should have the same bit width as the type."); 00370 00371 for (unsigned i = 1, e = PN->getNumIncomingValues(); i != e; ++i) { 00372 Value *V = PN->getIncomingValue(i); 00373 if (isa<UndefValue>(V) || isa<ConstantExpr>(V)) { 00374 DestLOI.NumSignBits = 1; 00375 APInt Zero(BitWidth, 0); 00376 DestLOI.KnownZero = Zero; 00377 DestLOI.KnownOne = Zero; 00378 return; 00379 } 00380 00381 if (ConstantInt *CI = dyn_cast<ConstantInt>(V)) { 00382 APInt Val = CI->getValue().zextOrTrunc(BitWidth); 00383 DestLOI.NumSignBits = std::min(DestLOI.NumSignBits, Val.getNumSignBits()); 00384 DestLOI.KnownZero &= ~Val; 00385 DestLOI.KnownOne &= Val; 00386 continue; 00387 } 00388 00389 assert(ValueMap.count(V) && "V should have been placed in ValueMap when " 00390 "its CopyToReg node was created."); 00391 unsigned SrcReg = ValueMap[V]; 00392 if (!TargetRegisterInfo::isVirtualRegister(SrcReg)) { 00393 DestLOI.IsValid = false; 00394 return; 00395 } 00396 const LiveOutInfo *SrcLOI = GetLiveOutRegInfo(SrcReg, BitWidth); 00397 if (!SrcLOI) { 00398 DestLOI.IsValid = false; 00399 return; 00400 } 00401 DestLOI.NumSignBits = std::min(DestLOI.NumSignBits, SrcLOI->NumSignBits); 00402 DestLOI.KnownZero &= SrcLOI->KnownZero; 00403 DestLOI.KnownOne &= SrcLOI->KnownOne; 00404 } 00405 } 00406 00407 /// setArgumentFrameIndex - Record frame index for the byval 00408 /// argument. This overrides previous frame index entry for this argument, 00409 /// if any. 00410 void FunctionLoweringInfo::setArgumentFrameIndex(const Argument *A, 00411 int FI) { 00412 ByValArgFrameIndexMap[A] = FI; 00413 } 00414 00415 /// getArgumentFrameIndex - Get frame index for the byval argument. 00416 /// If the argument does not have any assigned frame index then 0 is 00417 /// returned. 00418 int FunctionLoweringInfo::getArgumentFrameIndex(const Argument *A) { 00419 DenseMap<const Argument *, int>::iterator I = 00420 ByValArgFrameIndexMap.find(A); 00421 if (I != ByValArgFrameIndexMap.end()) 00422 return I->second; 00423 DEBUG(dbgs() << "Argument does not have assigned frame index!\n"); 00424 return 0; 00425 } 00426 00427 /// ComputeUsesVAFloatArgument - Determine if any floating-point values are 00428 /// being passed to this variadic function, and set the MachineModuleInfo's 00429 /// usesVAFloatArgument flag if so. This flag is used to emit an undefined 00430 /// reference to _fltused on Windows, which will link in MSVCRT's 00431 /// floating-point support. 00432 void llvm::ComputeUsesVAFloatArgument(const CallInst &I, 00433 MachineModuleInfo *MMI) 00434 { 00435 FunctionType *FT = cast<FunctionType>( 00436 I.getCalledValue()->getType()->getContainedType(0)); 00437 if (FT->isVarArg() && !MMI->usesVAFloatArgument()) { 00438 for (unsigned i = 0, e = I.getNumArgOperands(); i != e; ++i) { 00439 Type* T = I.getArgOperand(i)->getType(); 00440 for (po_iterator<Type*> i = po_begin(T), e = po_end(T); 00441 i != e; ++i) { 00442 if (i->isFloatingPointTy()) { 00443 MMI->setUsesVAFloatArgument(true); 00444 return; 00445 } 00446 } 00447 } 00448 } 00449 } 00450 00451 /// AddCatchInfo - Extract the personality and type infos from an eh.selector 00452 /// call, and add them to the specified machine basic block. 00453 void llvm::AddCatchInfo(const CallInst &I, MachineModuleInfo *MMI, 00454 MachineBasicBlock *MBB) { 00455 // Inform the MachineModuleInfo of the personality for this landing pad. 00456 const ConstantExpr *CE = cast<ConstantExpr>(I.getArgOperand(1)); 00457 assert(CE->getOpcode() == Instruction::BitCast && 00458 isa<Function>(CE->getOperand(0)) && 00459 "Personality should be a function"); 00460 MMI->addPersonality(MBB, cast<Function>(CE->getOperand(0))); 00461 00462 // Gather all the type infos for this landing pad and pass them along to 00463 // MachineModuleInfo. 00464 std::vector<const GlobalVariable *> TyInfo; 00465 unsigned N = I.getNumArgOperands(); 00466 00467 for (unsigned i = N - 1; i > 1; --i) { 00468 if (const ConstantInt *CI = dyn_cast<ConstantInt>(I.getArgOperand(i))) { 00469 unsigned FilterLength = CI->getZExtValue(); 00470 unsigned FirstCatch = i + FilterLength + !FilterLength; 00471 assert(FirstCatch <= N && "Invalid filter length"); 00472 00473 if (FirstCatch < N) { 00474 TyInfo.reserve(N - FirstCatch); 00475 for (unsigned j = FirstCatch; j < N; ++j) 00476 TyInfo.push_back(ExtractTypeInfo(I.getArgOperand(j))); 00477 MMI->addCatchTypeInfo(MBB, TyInfo); 00478 TyInfo.clear(); 00479 } 00480 00481 if (!FilterLength) { 00482 // Cleanup. 00483 MMI->addCleanup(MBB); 00484 } else { 00485 // Filter. 00486 TyInfo.reserve(FilterLength - 1); 00487 for (unsigned j = i + 1; j < FirstCatch; ++j) 00488 TyInfo.push_back(ExtractTypeInfo(I.getArgOperand(j))); 00489 MMI->addFilterTypeInfo(MBB, TyInfo); 00490 TyInfo.clear(); 00491 } 00492 00493 N = i; 00494 } 00495 } 00496 00497 if (N > 2) { 00498 TyInfo.reserve(N - 2); 00499 for (unsigned j = 2; j < N; ++j) 00500 TyInfo.push_back(ExtractTypeInfo(I.getArgOperand(j))); 00501 MMI->addCatchTypeInfo(MBB, TyInfo); 00502 } 00503 } 00504 00505 /// AddLandingPadInfo - Extract the exception handling information from the 00506 /// landingpad instruction and add them to the specified machine module info. 00507 void llvm::AddLandingPadInfo(const LandingPadInst &I, MachineModuleInfo &MMI, 00508 MachineBasicBlock *MBB) { 00509 MMI.addPersonality(MBB, 00510 cast<Function>(I.getPersonalityFn()->stripPointerCasts())); 00511 00512 if (I.isCleanup()) 00513 MMI.addCleanup(MBB); 00514 00515 // FIXME: New EH - Add the clauses in reverse order. This isn't 100% correct, 00516 // but we need to do it this way because of how the DWARF EH emitter 00517 // processes the clauses. 00518 for (unsigned i = I.getNumClauses(); i != 0; --i) { 00519 Value *Val = I.getClause(i - 1); 00520 if (I.isCatch(i - 1)) { 00521 MMI.addCatchTypeInfo(MBB, 00522 dyn_cast<GlobalVariable>(Val->stripPointerCasts())); 00523 } else { 00524 // Add filters in a list. 00525 Constant *CVal = cast<Constant>(Val); 00526 SmallVector<const GlobalVariable*, 4> FilterList; 00527 for (User::op_iterator 00528 II = CVal->op_begin(), IE = CVal->op_end(); II != IE; ++II) 00529 FilterList.push_back(cast<GlobalVariable>((*II)->stripPointerCasts())); 00530 00531 MMI.addFilterTypeInfo(MBB, FilterList); 00532 } 00533 } 00534 }