[PATCH] D34753: [Support] - Add bad alloc error handler for handling allocation malfunctions

Matthias Braun via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 5 10:40:43 PDT 2017


MatzeB added a comment.

In general: This may warrant an RFC to llvm-dev to discuss the scope of these patches. I feel that making all of LLVM abort gracefully in out of memory situations will be hard/unmaintainable. I believe the trick would be to limit the scope. Remembering your EuroLLVM talk it seemed that you would only need IR construction in the long running server process so you can hand over that IR to shorter lived/restartable worker processes doing the actual code generation. So the scope may be limited to this use case avoiding the need to fix all the transformation passes to recover gracefully.

Specifically about this patch: So a failing malloc would now call the handler, but a failing `new` would throw an exception (or more likely `abort()` in the default no-exceptions configuration of LLVM. Maybe we should rather: Use `new` instead of `malloc` wherever possible. I'm not sure why this particular code uses malloc at all? For the cases that still use `malloc` (only good reason I can think of would be using `realloc` later) maybe we can trigger the same C++ exception as a failing new?


https://reviews.llvm.org/D34753





More information about the llvm-commits mailing list