[llvm-commits] [llvm-gcc-4.2] r138984 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp

Duncan Sands baldrick at free.fr
Fri Sep 2 00:06:07 PDT 2011


Hi Bill,

> Update to use the new EH scheme.

thanks for doing this.

> +  Constant *CatchAllVal = 0;
> +  tree catch_all_type = lang_eh_catch_all();
> +  if (catch_all_type == NULL_TREE)
> +    // Use a C++ style null catch-all object.
> +    CatchAllVal = Constant::getNullValue(Type::getInt8PtrTy(Context));
> +  else
> +    // This language has a type that catches all others.
> +    CatchAllVal = cast<Constant>(Emit(catch_all_type, 0));

I think CatchAllVal is now useless and this should be removed.  See below for
more.

>         } else if (RegionKind>  0) {
>           // Catch.
>           tree TypeList = get_eh_type_list(region);
>
>           if (!TypeList) {
>             // Catch-all - push the catch-all object.
> -          assert(CatchAll&&  "Language did not define lang_eh_catch_all?");
> -          Args.push_back(CatchAll);
> +          LPadInst->addClause(CatchAllVal);
>             HasCatchAll = true;

All languages which can produce a null TypeList here use null for the catch all
(like in C++).  At least I think so.  So you can just push a null pointer here:
no need for CatchAllValue.

>           } else {
>             // Add the type infos.
>             for (; TypeList; TypeList = TREE_CHAIN(TypeList)) {
>               tree TType = lookup_type_for_runtime(TREE_VALUE(TypeList));
> -            Args.push_back(Emit(TType, 0));
> +            LPadInst->addClause(Emit(TType, 0));
>             }
>           }
>         } else {
> @@ -2281,30 +2301,26 @@
>
>       if (can_throw_external_1(i, false)) {
>         if (HasCleanup) {

Here I think you should just always set the cleanup flag if HasCleanup is true.
All the funky logic below is because of the bad interaction between the inliner
and exception handling we used to have: pushing the catch-all was a nasty hack
to more-or-less get things working.  It shouldn't be needed with the new scheme.

> -        if (Args.size() == 2 || USING_SJLJ_EXCEPTIONS || !lang_eh_catch_all) {
> +        if (LPadInst->getNumClauses() == 0 || USING_SJLJ_EXCEPTIONS || !lang_eh_catch_all) {
>             // Insert the sentinal indicating that this is a cleanup-only
>             // selector.  It may also be the representation of a catch-all for
>             // some languages.
> -          Args.push_back(ConstantInt::get(Type::getInt32Ty(Context), 0));
> +          LPadInst->setCleanup(true);
>           } else if (!HasCatchAll) {
>             // Some exceptions from this region may not be caught by any handler.
>             // Since invokes are required to branch to the unwind label no matter
>             // what exception is being unwound, append a catch-all.
> -          assert(CatchAll&&  "Language did not define lang_eh_catch_all?");
> -          Args.push_back(CatchAll);
> +          assert(CatchAllVal&&  "Language did not define lang_eh_catch_all?");
> +          LPadInst->addClause(CatchAllVal);
>           }
>         }
>       }

All the above can just be deleted (exception for setting the cleanup flag) as
mentioned above.

Ciao, Duncan.



More information about the llvm-commits mailing list