[llvm-dev] inlining in exception handing region

via llvm-dev llvm-dev at lists.llvm.org
Fri Sep 11 12:24:23 PDT 2015


Hello,

While I was investigating C++ benchmarks, I was aware of that some small
functions with the throw statement were not inlined because the exception
handling code increased the inline cost. In the c++ example below, the
inline cost of fCallee is high mainly because of instructions for the
throw statement, and note that the constructor of MyException is even
inlined in fCallee.

Assuming that the exception handling code is rarely executed, would it
make sense to prevent CallSites in exception handling region (e.g., the
constructor of MyException) from being inlined so that we can avoid code
size blow-up in exception handling region and indirectly give more
inlining opportunity to the small unwinding functions containing exception
handling code?

class MyBaseException {
  int idx;
  int limit;
  const char* msg;
  public :
    MyBaseException(int i, int l, const char* m);
    ~MyBaseException();
    void handle(const char*m, int i, int l);
};

class MyException : MyBaseException
{
  public:
    MyException(int i, int l, const char* m): MyBaseException(i, l, m) {
      handle(m, i, l);
    }
};

int *Agg;

int fCallee(int idx, int limit) {
  if (idx >= limit)
    throw MyException(idx, limit, "error");
  return Agg[idx];
}

int fCaller(int i, int l) {
  return fCallee(i, l);
}

Thanks,
Jun



More information about the llvm-dev mailing list