Skip to content

Commit b98ed51

Browse files
toppercmahesh-attarde
authored andcommitted
[IR] Remove static variables from Type::getWasm_ExternrefTy/getWasm_FuncrefTy. (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.
1 parent 2907dfe commit b98ed51

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

llvm/lib/IR/Type.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,14 +304,12 @@ IntegerType *Type::getIntNTy(LLVMContext &C, unsigned N) {
304304

305305
Type *Type::getWasm_ExternrefTy(LLVMContext &C) {
306306
// opaque pointer in addrspace(10)
307-
static PointerType *Ty = PointerType::get(C, 10);
308-
return Ty;
307+
return PointerType::get(C, 10);
309308
}
310309

311310
Type *Type::getWasm_FuncrefTy(LLVMContext &C) {
312311
// opaque pointer in addrspace(20)
313-
static PointerType *Ty = PointerType::get(C, 20);
314-
return Ty;
312+
return PointerType::get(C, 20);
315313
}
316314

317315
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)