summaryrefslogtreecommitdiffstats
path: root/source/slang/ir.cpp
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2018-04-18 17:22:44 -0700
committerGitHub <noreply@github.com>2018-04-18 17:22:44 -0700
commit17fa424a195ed562e0c9d87cee57577c90c1fc37 (patch)
tree710d045b7b4228d750dd989689d5a1a63044bb93 /source/slang/ir.cpp
parentc3a27c0e5a5b36b5a14566394d1694419632b76c (diff)
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<X>`. 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.
Diffstat (limited to 'source/slang/ir.cpp')
-rw-r--r--source/slang/ir.cpp30
1 files changed, 25 insertions, 5 deletions
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);