Skip to content

Instantly share code, notes, and snippets.

@PetarKirov
Last active November 16, 2020 07:00
Show Gist options
  • Save PetarKirov/9b844d51863cb57ebc8dae214cb27bf2 to your computer and use it in GitHub Desktop.
Save PetarKirov/9b844d51863cb57ebc8dae214cb27bf2 to your computer and use it in GitHub Desktop.
LDC 1.24.0. / CT string compare / druntime symbols
extern(C) void _start() {
static if ("a" == "a") {}
}
(module
(type (;0;) (func (param i32 i32 i32) (result i32)))
(type (;1;) (func))
(type (;2;) (func (param i32 i32 i32 i32) (result i32)))
(import "env" "memcmp" (func $memcmp (type 0)))
(func $_start (type 1)) (func $_D4core8internal5array8equality__T8__equalsTyaTyaZQqFNaNbNiNfMAyaMQeZb (type 2) (param i32 i32 i32 i32) (result i32) (local i32) i32.const 0
local.set 4
block ;; label = @1
block ;; label = @2 local.get 2
local.get 0 i32.ne
br_if 0 (;@2;)
local.get 2
br_if 1 (;@1;)
i32.const 1
local.set 4
end
local.get 4
return
end
local.get 3
local.get 1
local.get 2
call $memcmp
i32.eqz)
(func $_D4core8internal5array8equality__T8__equalsTyaTyaZQqFMAyaMQeZ13trustedMemcmpFNaNbNiNeMQBgMQBkZb (type 2) (param i32 i32 i32 i32) (result i32)
local.get 3
local.get 1
local.get 2
call $memcmp
i32.eqz)
(func $_D4core8internal5array8equality__T2atTyaZQhFNaNbNcNiNeAyakZya (type 0) (param i32 i32 i32) (result i32) local.get 2
local.get 0
i32.add) (table (;0;) 1 1 funcref)
(memory (;0;) 2) (global (;0;) (mut i32) (i32.const 66592))
(global (;1;) i32 (i32.const 1024))
(export "memory" (memory 0))
(export "_start" (func $_start)) (export "_D4core8internal5array8equality__T8__equalsTyaTyaZQqFNaNbNiNfMAyaMQeZb" (func $_D4core8internal5array8equality__T8__equalsTyaTyaZQqFNaNbNiNfMAyaMQeZb))
(export "_D4core8internal5array8equality__T8__equalsTyaTyaZQqFMAyaMQeZ13trustedMemcmpFNaNbNiNeMQBgMQBkZb" (func $_D4core8internal5array8equality__T8__equalsTyaTyaZQqFMAyaMQeZ13trustedMemcmpFNaNbNiNeMQBgMQBkZb)) (export "_D4core8internal5array8equality__T2atTyaZQhFNaNbNcNiNeAyakZya" (func $_D4core8internal5array8equality__T2atTyaZQhFNaNbNcNiNeAyakZya)) (export "_D9wasm_test12__ModuleInfoZ" (global 1))
(data (;0;) (i32.const 1024) "\04\00\00\80\00\00\00\00wasm_test\00\00\00")
(data (;1;) (i32.const 1044) "\00\04\00\00"))
#!/usr/bin/env sh
ldc2 -mtriple=wasm32-unknown-unknown-wasm -ofapp.wasm app.d -L--allow-undefined -O3
wasm2wat app.wasm > app.wat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment