fix(gen): life_of_expr 的构造分支按目标类型判定——目标为同型聚合值时判 LIFE_VALUE(值拷贝),不再误判帧逃逸
This commit is contained in:
1 parent
6cb1f525d9
commit
377c0db5d3
1 file changed
+8
-1
@@ -974,7 +974,14 @@ novirtual class AssignGenMixin:
|
||||
ct_ty: mlirlite.LLVMType* = self.Gen.StructGen.get_struct_type(ctor_nm)
|
||||
if ct_ty is not None:
|
||||
ct_en: GenTypes.StructEntry* = self.Gen.StructGen.find_struct_by_type(ct_ty)
|
||||
if ct_en is None or ct_en.HasNew == 0: return GenTypes.LIFE_FRAME
|
||||
if ct_en is None or ct_en.HasNew == 0:
|
||||
# 裸构造 `T(...)` 的存储是本帧入口 alloca,但**目标位置是同型聚合值**时语义是
|
||||
# 值拷贝:返回/写入会把整块聚合复制出去,拷贝与源帧无关 —— 判 LIFE_VALUE
|
||||
# (与上方裸数组名的口径一致)。只有裸构造退让成指针的位置(`&T(...)`、指针目标、
|
||||
# 异型聚合目标)才交出本帧地址,判 LIFE_FRAME。
|
||||
if target_ty is not None and self.Gen.ExprGenBase.is_ptr_type(target_ty) == 0:
|
||||
if self._stg_ty_equal(trans.Pool, ct_ty, target_ty) != 0: return GenTypes.LIFE_VALUE
|
||||
return GenTypes.LIFE_FRAME
|
||||
return GenTypes.LIFE_UNKNOWN
|
||||
if k == ast.ASTKind.New:
|
||||
# M2.4 `new`:生命期由描述符决定(§2.3 组合矩阵)
|
||||
|
||||
Reference in new issue
Block a user