clc: Declare LLVMContexts on the stack
authorJason Ekstrand <jason.ekstrand@collabora.com>
Wed, 13 Apr 2022 21:52:17 +0000 (16:52 -0500)
committerMarge Bot <emma+marge@anholt.net>
Thu, 14 Apr 2022 21:19:56 +0000 (21:19 +0000)
commit46d9b0e431a890e4f130f6cd3e2e150b152f51f1
tree6db189eed65e329c583b2755dd54815fc18c7955
parent6099e6ce9ac499719f4360d34a4c8841d01c02e7
clc: Declare LLVMContexts on the stack

This prevents more use-after-free errors.  Passing them around using
std::unique_ptr ensures that the LLVMContext gets destroyed but doesn't
ensure destruction order.  Declaring it on the stack ensures that the
context doesn't get destroyed until right before the the function
returns which is after any other LLVM stuff is destroyed.

Reviewed-by: Jesse Natalie <jenatali@microsoft.com>
Reviewed-by: Icecream95 <ixn@disroot.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15937>
src/compiler/clc/clc_helpers.cpp