From 4bd3e6e02324f913e8927fe69d32c0aafe9fc831 Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 22 Aug 2022 14:17:56 -0700 Subject: Make Optional lower to PointerType instead of a struct. (#2373) --- source/slang/slang-emit.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'source/slang/slang-emit.cpp') diff --git a/source/slang/slang-emit.cpp b/source/slang/slang-emit.cpp index 3ec03d0e7..11e0812d9 100644 --- a/source/slang/slang-emit.cpp +++ b/source/slang/slang-emit.cpp @@ -212,22 +212,6 @@ Result linkAndOptimizeIR( // un-specialized IR. dumpIRIfEnabled(codeGenContext, irModule); - switch (target) - { - case CodeGenTarget::CPPSource: - case CodeGenTarget::HostCPPSource: - { - lowerComInterfaces(irModule, artifactDesc.style, sink); - generateDllImportFuncs(codeGenContext->getTargetReq(), irModule, sink); - generateDllExportFuncs(irModule, sink); - break; - } - default: break; - } - - // Lower `Result` types into ordinary struct types. - lowerResultType(irModule, sink); - // Replace any global constants with their values. // replaceGlobalConstants(irModule); @@ -323,6 +307,24 @@ Result linkAndOptimizeIR( break; } + lowerOptionalType(irModule, sink); + simplifyIR(irModule); + + switch (target) + { + case CodeGenTarget::CPPSource: + case CodeGenTarget::HostCPPSource: + { + lowerComInterfaces(irModule, artifactDesc.style, sink); + generateDllImportFuncs(codeGenContext->getTargetReq(), irModule, sink); + generateDllExportFuncs(irModule, sink); + break; + } + default: break; + } + + // Lower `Result` types into ordinary struct types. + lowerResultType(irModule, sink); // Desguar any union types, since these will be illegal on // various targets. @@ -393,8 +395,6 @@ Result linkAndOptimizeIR( // simplifyIR(irModule); - lowerOptionalType(irModule, sink); - #if 0 dumpIRIfEnabled(codeGenContext, irModule, "AFTER DCE"); #endif -- cgit v1.2.3