From 1d4b5b6fd2433a10cc7ab87626cb560f54b0acbb Mon Sep 17 00:00:00 2001 From: Yong He Date: Sun, 3 Sep 2023 12:56:31 -0700 Subject: Proper lowering of functiosn that returns NonCopyable values. (#3179) * Proper lowering of functiosn that returns NonCopyable values. * Fix tests. * Fix clang errors. * Fix. * Fix clang error. --------- Co-authored-by: Yong He --- source/slang/slang-emit-c-like.cpp | 29 ----------------------------- 1 file changed, 29 deletions(-) (limited to 'source/slang/slang-emit-c-like.cpp') diff --git a/source/slang/slang-emit-c-like.cpp b/source/slang/slang-emit-c-like.cpp index fe25c3f19..a8080851f 100644 --- a/source/slang/slang-emit-c-like.cpp +++ b/source/slang/slang-emit-c-like.cpp @@ -1535,25 +1535,6 @@ bool CLikeSourceEmitter::shouldFoldInstIntoUseSites(IRInst* inst) if(as(user)) return false; - // HACK: As a special case, an `allocateOpaqueHandle` operation should - // only be folded in if its only use is as the operand of a `store` - // that will *itself* get peephole merged in as the initial-value expression - // of a `var`: - // - if (inst->getOp() == kIROp_AllocateOpaqueHandle) - { - auto store = as(user); - if (!store) return false; - if (store->getVal() != inst) return false; - - auto var = as(store->getPtr()); - if (!var) return false; - - if(var->getNextInst() != store) return false; - - return true; - } - // Okay, if we reach this point then the user comes later in // the same block, and there are no instructions with side // effects in between, so it seems safe to fold things in. @@ -2003,7 +1984,6 @@ void CLikeSourceEmitter::defaultEmitInstExpr(IRInst* inst, const EmitOpInfo& inO case kIROp_undefined: case kIROp_DefaultConstruct: - case kIROp_AllocateOpaqueHandle: m_writer->emit(getName(inst)); break; @@ -2676,11 +2656,7 @@ void CLikeSourceEmitter::_emitInst(IRInst* inst) break; case kIROp_AllocateOpaqueHandle: - { - _emitAllocateOpaqueHandleImpl(inst); - } break; - case kIROp_Var: { auto var = cast(inst); @@ -2875,11 +2851,6 @@ void CLikeSourceEmitter::_emitInstAsDefaultInitializedVar(IRInst* inst, IRType* m_writer->emit(";\n"); } -void CLikeSourceEmitter::_emitAllocateOpaqueHandleImpl(IRInst* allocateInst) -{ - _emitInstAsDefaultInitializedVar(allocateInst, allocateInst->getDataType()); -} - void CLikeSourceEmitter::emitSemanticsUsingVarLayout(IRVarLayout* varLayout) { if(auto semanticAttr = varLayout->findAttr()) -- cgit v1.2.3