Skip to content

Instantly share code, notes, and snippets.

@Seelengrab
Last active April 2, 2022 12:17
Show Gist options
  • Save Seelengrab/2806847e54c2a5b5a7949a309c32eaac to your computer and use it in GitHub Desktop.
Save Seelengrab/2806847e54c2a5b5a7949a309c32eaac to your computer and use it in GitHub Desktop.
Weird `extractvalue`s
using InteractiveUtils
struct Foo
a::UInt
b::NTuple{32, UInt8}
c::NTuple{4096, UInt8}
d::NTuple{4096, UInt8}
end
ident(_) = 0x0
Foo() = Foo(0, ntuple(ident, 0x20), ntuple(ident, 0x1000), ntuple(ident, 0x1000))
function access_tuple(array, vars...)
@inbounds vars[1]
end
function set_array(array, vars...)
@inbounds array[1] = vars[1]
array
end
function read_array(array, vars...)
@inbounds array[1]
end
function main()
for func in (access_tuple, set_array, read_array)
println("Doing function ", func, " llvm")
open("code_llvm_$func.ll", "w") do io
code_llvm(io, func, (Vector{Foo}, Tuple{Foo}); raw=true)
end
println("Doing function ", func, " native")
open("code_native_$func.asm", "w") do io
code_native(io, func, (Vector{Foo}, Tuple{Foo}))
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment