[llvm-commits] [llvm-gcc-4.0] r41485 - /llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp
Duncan Sands
baldrick at free.fr
Mon Aug 27 08:51:13 PDT 2007
Author: baldrick
Date: Mon Aug 27 10:51:13 2007
New Revision: 41485
URL: http://llvm.org/viewvc/llvm-project?rev=41485&view=rev
Log:
Filters are now specified by using the number of type infos
plus one. Always append a catch-all to the selector call,
unless it is pointless.
Modified:
llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp
Modified: llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp?rev=41485&r1=41484&r2=41485&view=diff
==============================================================================
--- llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.0/trunk/gcc/llvm-convert.cpp Mon Aug 27 10:51:13 2007
@@ -2039,6 +2039,7 @@
Args.push_back(CastToType(Instruction::BitCast, FuncCPPPersonality,
PointerType::get(Type::Int8Ty)));
+ bool CaughtAll = false;
for (std::vector<EHScope>::reverse_iterator I = CurrentEHScopes.rbegin(),
E = CurrentEHScopes.rend(); I != E; ++I) {
if (I->CatchExpr) {
@@ -2051,16 +2052,30 @@
EH_FILTER_EXPR) ? FilterExpr : CatchList;
}
- if (I->InfosType == FilterExpr)
+ if (I->InfosType == FilterExpr) {
// Filter - note the size.
- Args.push_back(ConstantInt::get(Type::Int32Ty, I->TypeInfos.size()));
+ Args.push_back(ConstantInt::get(Type::Int32Ty, I->TypeInfos.size()+1));
+ // An empty filter catches all exceptions.
+ if ((CaughtAll = !I->TypeInfos.size()))
+ break;
+ }
Args.reserve(Args.size() + I->TypeInfos.size());
- for (unsigned j = 0, N = I->TypeInfos.size(); j < N; ++j)
+ for (unsigned j = 0, N = I->TypeInfos.size(); j < N; ++j) {
Args.push_back(I->TypeInfos[j]);
+ // A null typeinfo indicates a catch-all.
+ if ((CaughtAll = I->TypeInfos[j]->isNullValue()))
+ break;
+ }
}
}
+ // Invokes are required to branch to the unwind label no matter what exception
+ // is being unwound. Enforce this by appending a catch-all.
+ // FIXME: The use of null as catch-all is C++ specific.
+ if (!CaughtAll)
+ Args.push_back(Constant::getNullValue(PointerType::get(Type::Int8Ty)));
+
Value *Select = Builder.CreateCall(FuncEHSelector, Args.begin(), Args.end(),
"eh_select");
Builder.CreateStore(Select, ExceptionSelectorValue);
More information about the llvm-commits
mailing list