summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-ir-clone.cpp20
-rw-r--r--source/slang/slang-ir-insts.h2
-rw-r--r--source/slang/slang-ir-link.cpp9
-rw-r--r--source/slang/slang-ir.cpp5
4 files changed, 26 insertions, 10 deletions
diff --git a/source/slang/slang-ir-clone.cpp b/source/slang/slang-ir-clone.cpp
index 6bbaefa26..66af405d6 100644
--- a/source/slang/slang-ir-clone.cpp
+++ b/source/slang/slang-ir-clone.cpp
@@ -51,6 +51,20 @@ IRInst* cloneInstAndOperands(IRCloneEnv* env, IRBuilder* builder, IRInst* oldIns
SLANG_ASSERT(builder);
SLANG_ASSERT(oldInst);
+ // We start by mapping the type of the orignal instruction
+ // to its replacement value, if any.
+ //
+ auto oldType = oldInst->getFullType();
+ auto newType = (IRType*)findCloneForOperand(env, oldType);
+
+ // Pointer literals need to be handled separately, as they carry other data
+ // than just the operands.
+ if (oldInst->getOp() == kIROp_PtrLit)
+ {
+ auto oldPtr = as<IRPtrLit>(oldInst);
+ return builder->getPtrValue(newType, oldPtr->value.ptrVal);
+ }
+
// This logic will not handle any instructions
// with special-case data attached, but that only
// applies to `IRConstant`s at this point, and those
@@ -62,12 +76,6 @@ IRInst* cloneInstAndOperands(IRCloneEnv* env, IRBuilder* builder, IRInst* oldIns
//
SLANG_ASSERT(!as<IRConstant>(oldInst));
- // We start by mapping the type of the orignal instruction
- // to its replacement value, if any.
- //
- auto oldType = oldInst->getFullType();
- auto newType = (IRType*)findCloneForOperand(env, oldType);
-
// Next we will iterate over the operands of `oldInst`
// to find their replacements and install them as
// the operands of `newInst`.
diff --git a/source/slang/slang-ir-insts.h b/source/slang/slang-ir-insts.h
index f46586aa2..2fa4de612 100644
--- a/source/slang/slang-ir-insts.h
+++ b/source/slang/slang-ir-insts.h
@@ -3599,7 +3599,7 @@ public:
IRInst* getFloatValue(IRType* type, IRFloatingPointValue value);
IRStringLit* getStringValue(const UnownedStringSlice& slice);
IRBlobLit* getBlobValue(ISlangBlob* blob);
- IRPtrLit* _getPtrValue(void* ptr);
+ IRPtrLit* getPtrValue(IRType* type, void* ptr);
IRPtrLit* getNullPtrValue(IRType* type);
IRPtrLit* getNullVoidPtrValue() { return getNullPtrValue(getPtrType(getVoidType())); }
IRVoidLit* getVoidValue();
diff --git a/source/slang/slang-ir-link.cpp b/source/slang/slang-ir-link.cpp
index d60903cfc..364e58c48 100644
--- a/source/slang/slang-ir-link.cpp
+++ b/source/slang/slang-ir-link.cpp
@@ -1172,6 +1172,15 @@ IRInst* cloneInst(
{
// We need to special-case any instruction that is not
// allocated like an ordinary `IRInst` with trailing args.
+ case kIROp_IntLit:
+ case kIROp_FloatLit:
+ case kIROp_BoolLit:
+ case kIROp_StringLit:
+ case kIROp_BlobLit:
+ case kIROp_PtrLit:
+ case kIROp_VoidLit:
+ return cloneValue(context, originalInst);
+
case kIROp_Func:
return cloneFuncImpl(context, builder, cast<IRFunc>(originalInst), originalValues);
diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp
index e15ec6f07..ac51ae451 100644
--- a/source/slang/slang-ir.cpp
+++ b/source/slang/slang-ir.cpp
@@ -2395,9 +2395,8 @@ IRBlobLit* IRBuilder::getBlobValue(ISlangBlob* blob)
return static_cast<IRBlobLit*>(_findOrEmitConstant(keyInst));
}
-IRPtrLit* IRBuilder::_getPtrValue(void* data)
+IRPtrLit* IRBuilder::getPtrValue(IRType* type, void* data)
{
- auto type = getPtrType(getVoidType());
IRConstant keyInst;
memset(&keyInst, 0, sizeof(keyInst));
keyInst.m_op = kIROp_PtrLit;
@@ -6324,7 +6323,7 @@ IRDecoration* IRBuilder::addDecoration(
void IRBuilder::addHighLevelDeclDecoration(IRInst* inst, Decl* decl)
{
- auto ptrConst = _getPtrValue(decl);
+ auto ptrConst = getPtrValue(getPtrType(getVoidType()), decl);
addDecoration(inst, kIROp_HighLevelDeclDecoration, ptrConst);
}