From 17fa424a195ed562e0c9d87cee57577c90c1fc37 Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Wed, 18 Apr 2018 17:22:44 -0700 Subject: Fix output of `groupshared` with IR type system (#492) The basic problem was that the lowering logic was constructing (more or less) `Ptr<@GroupShared X>` instead of `@GroupShared Ptr`. There were also problems with passes not propagating through rates that should have been (e.g., legalization). I've added a test case to actually validate `groupshared` support. --- source/slang/ir.cpp | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'source/slang/ir.cpp') diff --git a/source/slang/ir.cpp b/source/slang/ir.cpp index 2615c1c07..397726b0a 100644 --- a/source/slang/ir.cpp +++ b/source/slang/ir.cpp @@ -548,6 +548,9 @@ namespace Slang // IRParentInst* mergeCandidateParentsForHoistableInst(IRParentInst* left, IRParentInst* right) { + // If the candidates are both the same, then who cares? + if(left == right) return left; + // If either `left` or `right` is a block, then we need to be // a bit careful, because blocks can see other values just using // the dominance relationship, without a direct parent-child relationship. @@ -4805,6 +4808,27 @@ namespace Slang IRGlobalValueWithCode* clonedValue, IRGlobalValueWithCode* originalValue); + IRRate* cloneRate( + IRSpecContextBase* context, + IRRate* rate) + { + return (IRRate*) cloneType(context, rate); + } + + void maybeSetClonedRate( + IRSpecContextBase* context, + IRBuilder* builder, + IRInst* clonedValue, + IRInst* originalValue) + { + if(auto rate = originalValue->getRate() ) + { + clonedValue->setFullType(builder->getRateQualifiedType( + cloneRate(context, rate), + clonedValue->getFullType())); + } + } + IRGlobalVar* cloneGlobalVarImpl( IRSpecContextBase* context, IRBuilder* builder, @@ -4814,11 +4838,7 @@ namespace Slang auto clonedVar = builder->createGlobalVar( cloneType(context, originalVar->getDataType()->getValueType())); - if(auto rate = originalVar->getRate() ) - { - clonedVar->setFullType(builder->getRateQualifiedType( - rate, clonedVar->getFullType())); - } + maybeSetClonedRate(context, builder, clonedVar, originalVar); registerClonedValue(context, clonedVar, originalValues); -- cgit v1.2.3