修正了 TPC 的一些错误,包括 Test 维护后 TPV 无法重新编译或重编译后越界的部分问题
This commit is contained in:
@@ -536,7 +536,15 @@ class AssignHandle(BaseHandle):
|
||||
if DefVal.type != expected_type:
|
||||
if isinstance(expected_type, ir.IntType) and isinstance(DefVal.type, ir.IntType):
|
||||
if DefVal.type.width < expected_type.width:
|
||||
DefVal = Gen.builder.zext(DefVal, expected_type, name=f"zext_default_{arg_idx}")
|
||||
if DefVal.type.width == 1:
|
||||
# i1 是布尔值,无符号语义,必须 zext
|
||||
DefVal = Gen.builder.zext(DefVal, expected_type, name=f"zext_default_{arg_idx}")
|
||||
else:
|
||||
is_unsigned: bool = Gen._check_node_unsigned(arg_def[def_idx]) or id(DefVal) in Gen._unsigned_results
|
||||
if is_unsigned:
|
||||
DefVal = Gen.builder.zext(DefVal, expected_type, name=f"zext_default_{arg_idx}")
|
||||
else:
|
||||
DefVal = Gen.builder.sext(DefVal, expected_type, name=f"sext_default_{arg_idx}")
|
||||
elif DefVal.type.width > expected_type.width:
|
||||
DefVal = Gen.builder.trunc(DefVal, expected_type, name=f"trunc_default_{arg_idx}")
|
||||
CallArgs.append(DefVal)
|
||||
@@ -802,6 +810,21 @@ class AssignHandle(BaseHandle):
|
||||
(isinstance(_ObjPointee, ir.IdentifiedStructType) and isinstance(_TargetStruct, ir.IdentifiedStructType) and
|
||||
(_ObjPointee.name == _TargetStruct.name or
|
||||
Gen._extract_short_name(_ObjPointee.name) == Gen._extract_short_name(_TargetStruct.name)))))
|
||||
# opaque 泛型结构体 → 特化版本 bitcast
|
||||
# 当 ObjVal 的 pointee 是 opaque 基础泛型结构体(如 GSList,来自跨模块 stub),
|
||||
# 而 ClassName 是特化版本(如 GSList[BasicBlock])时,两者 short name 不同
|
||||
# (GSList vs GSList[BasicBlock]),_MatchesStruct 失败。
|
||||
# 验证特化 short name 以 基础名+'[' 开头,bitcast 到特化版本使后续 GEP 能正确访问字段。
|
||||
if (not _MatchesStruct
|
||||
and isinstance(ObjVal.type, ir.PointerType)
|
||||
and isinstance(_ObjPointee, ir.IdentifiedStructType)
|
||||
and isinstance(_TargetStruct, ir.IdentifiedStructType)
|
||||
and '[' in ClassName):
|
||||
_BaseShort: str = Gen._extract_short_name(_ObjPointee.name)
|
||||
_SpecShort: str = Gen._extract_short_name(_TargetStruct.name)
|
||||
if _BaseShort and _SpecShort.startswith(_BaseShort + '['):
|
||||
ObjVal = Gen.builder.bitcast(ObjVal, ir.PointerType(_TargetStruct), name=f"cast_spec_{ClassName}")
|
||||
_MatchesStruct = True
|
||||
if isinstance(ObjVal.type, ir.PointerType) and _MatchesStruct:
|
||||
if IsUnion:
|
||||
NestedStructName: str = f"{ClassName}_{AttrName}"
|
||||
|
||||
Reference in New Issue
Block a user