diff options
author | Bill Wendling <isanbard@gmail.com> | 2011-09-19 22:08:36 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2011-09-19 22:08:36 +0000 |
commit | 58e58fead14da629836d4094fc7c0a8facc88ffa (patch) | |
tree | 129a866c8a3f83375843ee815438a63fff211c6a /clang/lib/CodeGen | |
parent | eb1bd24134e37f5d6bb5a389fa6c076ab23075ec (diff) | |
download | bcm5719-llvm-58e58fead14da629836d4094fc7c0a8facc88ffa.tar.gz bcm5719-llvm-58e58fead14da629836d4094fc7c0a8facc88ffa.zip |
The eh.selector intrinsic isn't used anymore. Replace the check here with a
check for the landingpad instruction instead. This check looks at each of the
clauses in the landingpad instruction. If it's a catch clause, it compares the
name directly with the global. If it's a filter clause, it has to look through
each value in the filer to see if any have the prefix.
llvm-svn: 140075
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r-- | clang/lib/CodeGen/CGException.cpp | 46 |
1 files changed, 30 insertions, 16 deletions
diff --git a/clang/lib/CodeGen/CGException.cpp b/clang/lib/CodeGen/CGException.cpp index 14a89cff3f9..a8d7c5a78d2 100644 --- a/clang/lib/CodeGen/CGException.cpp +++ b/clang/lib/CodeGen/CGException.cpp @@ -239,21 +239,36 @@ static bool PersonalityHasOnlyCXXUses(llvm::Constant *Fn) { continue; } - // Otherwise, it has to be a selector call. - if (!isa<llvm::EHSelectorInst>(User)) return false; + // Otherwise, it has to be a landingpad instruction. + llvm::LandingPadInst *LPI = dyn_cast<llvm::LandingPadInst>(User); + if (!LPI) return false; - llvm::EHSelectorInst *Selector = cast<llvm::EHSelectorInst>(User); - for (unsigned I = 2, E = Selector->getNumArgOperands(); I != E; ++I) { + for (unsigned I = 0, E = LPI->getNumClauses(); I != E; ++I) { // Look for something that would've been returned by the ObjC // runtime's GetEHType() method. - llvm::GlobalVariable *GV - = dyn_cast<llvm::GlobalVariable>(Selector->getArgOperand(I)); - if (!GV) continue; - - // ObjC EH selector entries are always global variables with - // names starting like this. - if (GV->getName().startswith("OBJC_EHTYPE")) - return false; + llvm::Value *Val = LPI->getClause(I)->stripPointerCasts(); + if (LPI->isCatch(I)) { + // Check if the catch value has the ObjC prefix. + llvm::GlobalVariable *GV = cast<llvm::GlobalVariable>(Val); + + // ObjC EH selector entries are always global variables with + // names starting like this. + if (GV->getName().startswith("OBJC_EHTYPE")) + return false; + } else { + // Check if any of the filter values have the ObjC prefix. + llvm::Constant *CVal = cast<llvm::Constant>(Val); + for (llvm::User::op_iterator + II = CVal->op_begin(), IE = CVal->op_end(); II != IE; ++II) { + llvm::GlobalVariable *GV = + cast<llvm::GlobalVariable>((*II)->stripPointerCasts()); + + // ObjC EH selector entries are always global variables with + // names starting like this. + if (GV->getName().startswith("OBJC_EHTYPE")) + return false; + } + } } } @@ -811,10 +826,9 @@ llvm::BasicBlock *CodeGenFunction::EmitLandingPad() { // If we have an EH filter, we need to add those handlers in the // right place in the landingpad, which is to say, at the end. } else if (hasFilter) { - // Create a filter expression: an integer constant saying how many - // filters there are (+1 to avoid ambiguity with 0 for cleanup), - // followed by the filter types. The personality routine only - // lands here if the filter doesn't match. + // Create a filter expression: a constant array indicating which filter + // types there are. The personality routine only lands here if the filter + // doesn't match. llvm::SmallVector<llvm::Constant*, 8> Filters; llvm::ArrayType *AType = llvm::ArrayType::get(!filterTypes.empty() ? |