aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2024-07-11 12:50:51 +0100
committerGitHub <noreply@github.com>2024-07-11 12:50:51 +0100
commite05e99253b16c4ffd1c51d50072292dd99ff5e5b (patch)
tree1dd3b2eb3a12a61bd7923b93a5566a26ddd95837 /src
parenta8ce5bd005840cf0998f91869320e9dbf7d34e70 (diff)
parent65ca03a93054864e75ca3ba879a9a16465989a9f (diff)
Merge pull request #3904 from laytan/make-instrumentation-work-on-wasm
make instrumentation "work" on wasm
Diffstat (limited to 'src')
-rw-r--r--src/llvm_backend_opt.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/llvm_backend_opt.cpp b/src/llvm_backend_opt.cpp
index 6a6d2f802..e6ccc9a57 100644
--- a/src/llvm_backend_opt.cpp
+++ b/src/llvm_backend_opt.cpp
@@ -398,16 +398,20 @@ gb_internal LLVMValueRef lb_run_instrumentation_pass_insert_call(lbProcedure *p,
LLVMValueRef args[3] = {};
args[0] = p->value;
- LLVMValueRef returnaddress_args[1] = {};
+ if (is_arch_wasm()) {
+ args[1] = LLVMConstPointerNull(lb_type(m, t_rawptr));
+ } else {
+ LLVMValueRef returnaddress_args[1] = {};
- returnaddress_args[0] = LLVMConstInt(LLVMInt32TypeInContext(m->ctx), 0, false);
+ returnaddress_args[0] = LLVMConstInt(LLVMInt32TypeInContext(m->ctx), 0, false);
- char const *instrinsic_name = "llvm.returnaddress";
- unsigned id = LLVMLookupIntrinsicID(instrinsic_name, gb_strlen(instrinsic_name));
- GB_ASSERT_MSG(id != 0, "Unable to find %s", instrinsic_name);
- LLVMValueRef ip = LLVMGetIntrinsicDeclaration(m->mod, id, nullptr, 0);
- LLVMTypeRef call_type = LLVMIntrinsicGetType(m->ctx, id, nullptr, 0);
- args[1] = LLVMBuildCall2(dummy_builder, call_type, ip, returnaddress_args, gb_count_of(returnaddress_args), "");
+ char const *instrinsic_name = "llvm.returnaddress";
+ unsigned id = LLVMLookupIntrinsicID(instrinsic_name, gb_strlen(instrinsic_name));
+ GB_ASSERT_MSG(id != 0, "Unable to find %s", instrinsic_name);
+ LLVMValueRef ip = LLVMGetIntrinsicDeclaration(m->mod, id, nullptr, 0);
+ LLVMTypeRef call_type = LLVMIntrinsicGetType(m->ctx, id, nullptr, 0);
+ args[1] = LLVMBuildCall2(dummy_builder, call_type, ip, returnaddress_args, gb_count_of(returnaddress_args), "");
+ }
Token name = {};
if (p->entity) {