From 16cba1062f7cb5e53018ef0f81840bebac7fa64c Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Wed, 23 Jul 2025 13:32:17 -0700 Subject: [PATCH] [IR] Remove static variables from Type::getWasm_ExternrefTy/getWasm_FuncrefTy. The were caching pointers to memory owned by LLVMContext and can outlive the LLVMContext. The LLVMContext already caches pointer types so we shouldn't need any caching here. --- llvm/lib/IR/Type.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/llvm/lib/IR/Type.cpp b/llvm/lib/IR/Type.cpp index 5e1bf2863191c..07c4b066f5b65 100644 --- a/llvm/lib/IR/Type.cpp +++ b/llvm/lib/IR/Type.cpp @@ -304,14 +304,12 @@ IntegerType *Type::getIntNTy(LLVMContext &C, unsigned N) { Type *Type::getWasm_ExternrefTy(LLVMContext &C) { // opaque pointer in addrspace(10) - static PointerType *Ty = PointerType::get(C, 10); - return Ty; + return PointerType::get(C, 10); } Type *Type::getWasm_FuncrefTy(LLVMContext &C) { // opaque pointer in addrspace(20) - static PointerType *Ty = PointerType::get(C, 20); - return Ty; + return PointerType::get(C, 20); } //===----------------------------------------------------------------------===//