aboutsummaryrefslogtreecommitdiffhomepage
path: root/transform
diff options
context:
space:
mode:
authorAyke van Laethem <[email protected]>2022-10-12 21:46:50 +0200
committerRon Evans <[email protected]>2022-10-19 22:23:19 +0200
commitd435fc868b9caef76b7a9b30a9c33adc3a79cab4 (patch)
tree2d1d2fc77094056c4371e5929d9e98184a54bd79 /transform
parent62df1d7490ccf495dc08837ec72ee1d6042bc374 (diff)
downloadtinygo-d435fc868b9caef76b7a9b30a9c33adc3a79cab4.tar.gz
tinygo-d435fc868b9caef76b7a9b30a9c33adc3a79cab4.zip
transform: fix memory corruption issues
There was a bug in the wasm ABI lowering pass (found using AddressSanitizer on LLVM 15) that resulted in a rather subtle memory corruption. This commit fixes this issues.
Diffstat (limited to 'transform')
-rw-r--r--transform/wasm-abi.go3
1 files changed, 1 insertions, 2 deletions
diff --git a/transform/wasm-abi.go b/transform/wasm-abi.go
index 83a16d85f..08122a3e4 100644
--- a/transform/wasm-abi.go
+++ b/transform/wasm-abi.go
@@ -88,8 +88,7 @@ func ExternalInt64AsPtr(mod llvm.Module, config *compileopts.Config) error {
// Update all users to call the external function.
// The old $i64wrapper function could be removed, but it may as well
// be left in place.
- for use := fn.FirstUse(); !use.IsNil(); use = use.NextUse() {
- call := use.User()
+ for _, call := range getUses(fn) {
entryBlockBuilder.SetInsertPointBefore(call.InstructionParent().Parent().EntryBasicBlock().FirstInstruction())
builder.SetInsertPointBefore(call)
callParams := []llvm.Value{}