Skip to content

Instantly share code, notes, and snippets.

@tkf
Last active Dec 6, 2021
Embed
What would you like to do?
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# This file is machine-generated - editing it directly is not advised
[[ArgCheck]]
git-tree-sha1 = "dedbbb2ddb876f899585c4ec4433265e3017215a"
uuid = "dce04be8-c92d-5529-be00-80e4d2c0e197"
version = "2.1.0"
[[Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
[[Dates]]
deps = ["Printf"]
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"
[[GitDataManager]]
deps = ["Sockets"]
git-tree-sha1 = "e8f03ade9a3a427803ae01303d48553c49ba1fa8"
repo-rev = "master"
repo-url = "https://github.com/tkf/GitDataManager.jl.git"
uuid = "e46aa908-4c54-40d5-94de-678bb20abb10"
version = "0.1.0-DEV"
[[IOCapture]]
deps = ["Logging", "Random"]
git-tree-sha1 = "f7be53659ab06ddc986428d3a9dcc95f6fa6705a"
uuid = "b5f81e59-6552-4d32-b1f0-c071b021bf89"
version = "0.2.2"
[[IRDumps]]
deps = ["ArgCheck", "InteractiveUtils"]
git-tree-sha1 = "7247ecb24e1679361f5115600a4ee5b6029d86e4"
repo-rev = "main"
repo-url = "https://github.com/tkf/IRDumps.jl.git"
uuid = "c8e92293-cae1-4b79-88ed-f0aaeba70b74"
version = "0.1.0-DEV"
[[InteractiveUtils]]
deps = ["Markdown"]
uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
[[JSON]]
deps = ["Dates", "Mmap", "Parsers", "Unicode"]
git-tree-sha1 = "8076680b162ada2a031f707ac7b4953e30667a37"
uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
version = "0.21.2"
[[Literate]]
deps = ["Base64", "IOCapture", "JSON", "REPL"]
git-tree-sha1 = "d3493acfb9e6aa0cff46b09773fc2342327b0feb"
uuid = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
version = "2.9.4"
[[Logging]]
uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
[[Markdown]]
deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
[[Mmap]]
uuid = "a63ad114-7e13-5084-954f-fe012c677804"
[[Parsers]]
deps = ["Dates"]
git-tree-sha1 = "ae4bbcadb2906ccc085cf52ac286dc1377dceccc"
uuid = "69de0a69-1ddd-5017-9359-2bf0b02dc9f0"
version = "2.1.2"
[[Printf]]
deps = ["Unicode"]
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"
[[REPL]]
deps = ["InteractiveUtils", "Markdown", "Sockets", "Unicode"]
uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
[[Random]]
deps = ["Serialization"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
[[Serialization]]
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
[[Sockets]]
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
[[Unicode]]
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
[deps]
GitDataManager = "e46aa908-4c54-40d5-94de-678bb20abb10"
IRDumps = "c8e92293-cae1-4b79-88ed-f0aaeba70b74"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
using IRDumps
using InteractiveUtils
begin
# Julia code to be executed in an external process
code = """
function ref_alloca_demo()
ref = Ref(0)
ptr = Ptr{Int}(pointer_from_objref(ref))
GC.@preserve ref begin
yield()
unsafe_store!(ptr, 123)
end
ref[]
end
ref_alloca_demo()
"""
# Dump LLVM IR with JULIA_LLVM_ARGS=-print-after-all
irs = IRDumps.dump(code)
passes = only(values(irs[r"julia_ref_alloca_demo"]))
irs
end
#-
# ### Unoptimized LLVM IR
first(passes)
#-
# ### Just after the first llvm-alloc-opt
allocopt = first(ir for ir in passes if ir.pass == "Promote heap allocation to stack")
#-
# ### Fully optimized LLVM IR
last(passes)
#-
# ## Appendix
versioninfo()
#-
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment