diff options
| author | Yong He <yonghe@outlook.com> | 2023-02-17 13:23:27 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-17 13:23:27 -0800 |
| commit | 051607368e8d3dd55d2ad2b2200ef656244ec70d (patch) | |
| tree | c1a6ce8d7551e5a74e36349d43ee4c05ae6ed21c /source/slang/slang-lower-to-ir.cpp | |
| parent | 79049bc7617be0d20f6ed5d9d1dfe75006aa675a (diff) | |
Fixed crash when lowering IR for no_diff struct member. (#2658)
* Fixed crash when lowering IR for no_diff struct member.
* Improve `setInsertBeforeOrdinaryInst` and `setInsertAfterOrdinaryInst`.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-lower-to-ir.cpp')
| -rw-r--r-- | source/slang/slang-lower-to-ir.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp index f78dd39e5..aa2dc4efb 100644 --- a/source/slang/slang-lower-to-ir.cpp +++ b/source/slang/slang-lower-to-ir.cpp @@ -3320,6 +3320,7 @@ struct ExprLoweringVisitorBase : ExprVisitor<Derived, LoweredValInfo> LoweredValInfo getSimpleDefaultVal(IRType* type) { + type = (IRType*)unwrapAttributedType(type); if(auto basicType = as<IRBasicType>(type)) { switch( basicType->getBaseType() ) @@ -3355,8 +3356,18 @@ struct ExprLoweringVisitorBase : ExprVisitor<Derived, LoweredValInfo> UNREACHABLE_RETURN(LoweredValInfo()); } + Type* getOriginalTypeFromModifiedType(Type* type) + { + auto innerType = type; + while (auto modifiedType = as<ModifiedType>(innerType)) + innerType = modifiedType->base; + return innerType; + } + LoweredValInfo getDefaultVal(Type* type) { + type = getOriginalTypeFromModifiedType(type); + auto irType = lowerType(context, type); if (auto basicType = as<BasicExpressionType>(type)) { @@ -7909,6 +7920,7 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> bool isClassType(IRType* type) { + type = (IRType*)unwrapAttributedType(type); if (auto specialize = as<IRSpecialize>(type)) { return findSpecializeReturnVal(specialize)->getOp() == kIROp_ClassType; |
