Skip to content

Conversation

@topperc
Copy link
Collaborator

@topperc topperc commented Jul 23, 2025

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.

…uncrefTy.

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.
@topperc topperc requested review from nikic and pmatos July 23, 2025 21:10
@llvmbot
Copy link
Member

llvmbot commented Jul 23, 2025

@llvm/pr-subscribers-llvm-ir

Author: Craig Topper (topperc)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/150323.diff

1 Files Affected:

  • (modified) llvm/lib/IR/Type.cpp (+2-4)
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);
 }
 
 //===----------------------------------------------------------------------===//

@topperc topperc merged commit 7b66629 into llvm:main Jul 23, 2025
11 checks passed
@topperc topperc deleted the pr/wasm-static branch July 23, 2025 22:56
mahesh-attarde pushed a commit to mahesh-attarde/llvm-project that referenced this pull request Jul 28, 2025
…uncrefTy. (llvm#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants