summaryrefslogtreecommitdiffstats
path: root/source/slang/ir.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/ir.cpp')
-rw-r--r--source/slang/ir.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/source/slang/ir.cpp b/source/slang/ir.cpp
index c2d900fdd..408f4257d 100644
--- a/source/slang/ir.cpp
+++ b/source/slang/ir.cpp
@@ -4515,9 +4515,17 @@ namespace Slang
break;
}
- builder.setInsertBefore(terminatorInst);
+ // We dont' re-use `builder` here because we don't want to
+ // disrupt the source location it is using for inserting
+ // temporary variables at the top of the function.
+ //
+ IRBuilder terminatorBuilder;
+ terminatorBuilder.sharedBuilder = builder.sharedBuilder;
+ terminatorBuilder.setInsertBefore(terminatorInst);
- assign(&builder, globalOutputVal, localVal);
+ // Assign from the local variabel to the global output
+ // variable before the actual `return` takes place.
+ assign(&terminatorBuilder, globalOutputVal, localVal);
}
}
else