[llvm] 7b66629 - [IR] Remove static variables from Type::getWasm_ExternrefTy/getWasm_FuncrefTy. (#150323)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 23 15:56:59 PDT 2025


Author: Craig Topper
Date: 2025-07-23T15:56:55-07:00
New Revision: 7b66629497ea5b6cde1772fab161c028e8c972a7

URL: https://github.com/llvm/llvm-project/commit/7b66629497ea5b6cde1772fab161c028e8c972a7
DIFF: https://github.com/llvm/llvm-project/commit/7b66629497ea5b6cde1772fab161c028e8c972a7.diff

LOG: [IR] Remove static variables from Type::getWasm_ExternrefTy/getWasm_FuncrefTy. (#150323)

These 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.

Added: 
    

Modified: 
    llvm/lib/IR/Type.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/IR/Type.cpp b/llvm/lib/IR/Type.cpp
index 6302614bcb357..9c34662340352 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);
 }
 
 //===----------------------------------------------------------------------===//


        


More information about the llvm-commits mailing list