diff options
Diffstat (limited to 'source/slang/slang-ir-specialize-function-call.cpp')
| -rw-r--r-- | source/slang/slang-ir-specialize-function-call.cpp | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/source/slang/slang-ir-specialize-function-call.cpp b/source/slang/slang-ir-specialize-function-call.cpp index 0341438c5..ab77ec88e 100644 --- a/source/slang/slang-ir-specialize-function-call.cpp +++ b/source/slang/slang-ir-specialize-function-call.cpp @@ -104,9 +104,8 @@ struct FunctionParameterSpecializationContext { // We will start by initializing our IR building state. // - sharedBuilderStorage.module = module; - sharedBuilderStorage.session = module->getSession(); - builderStorage.sharedBuilder = &sharedBuilderStorage; + sharedBuilderStorage.init(module); + builderStorage.init(sharedBuilderStorage); // Next we will populate our initial work list by // recursively finding every single call site in the module. @@ -675,7 +674,19 @@ struct FunctionParameterSpecializationContext // instructions if an insertion location // is set. // - builder->setInsertInto(nullptr); + // TODO(tfoley): We should really question any cases where + // we are creating IR instructions but not inserting them into the + // hierarchy of the IR module anywhere. Ideally we would have an + // invariant that all IR instructions are always parented somewhere + // under their IR module, except during very brief interludes. + // + // A good fix here would be for a pass like this to create a transient + // IR block to serve as a "nursery" for the newly-created instructions, + // instead of using `newBodyInsts` to hold them. The new IR block could + // be placed directly under the IR module during the construction phase + // of things, and then inserted to a more permanent location later. + // + builder->setInsertLoc(IRInsertLoc()); auto newVal = builder->emitElementExtract( oldArg->getFullType(), newBase, @@ -697,7 +708,7 @@ struct FunctionParameterSpecializationContext auto newPtr = getSpecializedValueForArg(ioInfo, oldPtr); auto builder = getBuilder(); - builder->setInsertInto(nullptr); + builder->setInsertLoc(IRInsertLoc()); auto newVal = builder->emitLoad( oldArg->getFullType(), newPtr); @@ -782,7 +793,7 @@ struct FunctionParameterSpecializationContext // cloneInstDecorationsAndChildren( &cloneEnv, - builder->sharedBuilder, + builder->getSharedBuilder(), oldFunc, newFunc); |
