[LLVMdev] Exception Handling Tables Question

Bill Wendling isanbard at gmail.com
Sun Sep 13 20:49:32 PDT 2009


I have a question concerning the exception handling tables that we  
generate.

Right now we generate call sites for all of the code in a function,  
even for code that cannot (or at least shouldn't) throw an exception.  
E.g., for this code:

#include <cstdio>

struct Cleanup {
    ~Cleanup(void) {
      printf("in cleanup\n");
    }
};

static void inline_me(void) {
    Cleanup C;
    throw 0;
}

int main(void) {
    try {
      inline_me();
    } catch (...) {
      printf("in catch all\n");
    }
    return 0;
}

(assume it's all been inlined), the EH handling table for "main" goes  
from Leh_func_begin1 to Leh_func_end1, marking off each region whether  
it can throw or not. From my reading of the Exception Tables  
documentation, this is unnecessary – at least for C++. If a call  
throws and it doesn't have an entry in the unwind table, then the  
"terminate()" function is called. Is it fair to assume that there is a  
similar mechanism for other languages? The reason to ask this is that  
it could make the EH tables smaller and less cluttered if we elide  
those areas which we know don't throw (the functions called are marked  
'nounwind', etc.).

-bw





More information about the llvm-dev mailing list