aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineBasicBlock.cpp
diff options
context:
space:
mode:
authorAaron Ballman <aaron@aaronballman.com>2024-05-15 10:55:34 -0400
committerGitHub <noreply@github.com>2024-05-15 10:55:34 -0400
commitdceaa0f4491ebe30c0b0f1bc7fa5ec365b60ced6 (patch)
tree1cf566ff9674960c4c249293ed5932b4a8f882cd /llvm/lib/CodeGen/MachineBasicBlock.cpp
parent8a4cbeada930bf11fe740a2038bd5a3230712284 (diff)
downloadllvm-dceaa0f4491ebe30c0b0f1bc7fa5ec365b60ced6.zip
llvm-dceaa0f4491ebe30c0b0f1bc7fa5ec365b60ced6.tar.gz
llvm-dceaa0f4491ebe30c0b0f1bc7fa5ec365b60ced6.tar.bz2
[Support] Use malloc instead of non-throwing new (#92157)
When allocating a memory buffer, we use a non-throwing new so that we can explicitly handle memory buffers that are too large to fit into memory. However, when exceptions are disabled, LLVM installs a custom new handler (https://github.com/llvm/llvm-project/blob/90109d444839683b09f0aafdc50b749cb4b3203b/llvm/lib/Support/InitLLVM.cpp#L61) that explicitly crashes when we run out of memory (https://github.com/llvm/llvm-project/blob/de14b749fee41d4ded711e771e43043ae3100cb3/llvm/lib/Support/ErrorHandling.cpp#L188) and that means this particular out-of-memory situation cannot be gracefully handled. This was discovered while working on #embed (https://github.com/llvm/llvm-project/pull/68620) on Windows and resulted in a crash rather than the preprocessor issuing a diagnostic as expected. This patch switches away from the non-throwing new to a call to malloc (and free), which will return a null pointer without calling a custom new handler. It is the only instance in Clang or LLVM that I could find which used a non-throwing new, so I did not think we would need anything more involved than this change. Testing this would be highly platform dependent and so it does not come with test coverage. And because it doesn't change behavior that users are likely to be able to observe, it does not come with a release note.
Diffstat (limited to 'llvm/lib/CodeGen/MachineBasicBlock.cpp')
0 files changed, 0 insertions, 0 deletions