Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tweak the type of quotes for functions in llvm code output #40869

Merged
merged 1 commit into from
May 19, 2021

Conversation

KristofferC
Copy link
Sponsor Member

It is quite common to include parts of @code_llvm in julia code blocks. For example:

julia> x = 2.0
2.0

julia> @code_llvm exp(x)
;  @ special/exp.jl:206 within `exp'
define double @julia_exp_193(double %0) {
top:
;  @ special/exp.jl:207 within `exp'
; ┌ @ float.jl:339 within `muladd'
   %1 = fmul contract double %0, 0x40771547652B82FE
   %2 = fadd contract double %1, 0x4338000000000000
; └
;  @ special/exp.jl:208 within `exp'
; ┌ @ essentials.jl:422 within `reinterpret'
   %3 = bitcast double %2 to i64
; └
; ┌ @ int.jl:472 within `rem'
   %4 = trunc i64 %3 to i32
; └
;  @ special/exp.jl:209 within `exp'
; ┌ @ float.jl:329 within `-'
   %5 = fadd double %2, 0xC338000000000000
; └
;  @ special/exp.jl:210 within `exp'

The problem here is that the way functions are quoted: `exp' means that code highlighting gets confused. This changes it to use the same delimiter:

julia> x = 2.0
2.0

julia> @code_llvm exp(x)
;  @ special/exp.jl:292 within `exp`
define double @julia_exp_128(double %0) #0 {
top:
; ┌ @ special/exp.jl:206 within `exp_impl`
; │┌ @ float.jl:402 within `muladd`
    %1 = fmul contract double %0, 0x40771547652B82FE
    %2 = fadd contract double %1, 0x4338000000000000
; └└
; ┌ @ special/exp.jl:207 within `exp_impl`
; │┌ @ essentials.jl:453 within `reinterpret`
    %3 = bitcast double %2 to i64
; │└
; │┌ @ int.jl:501 within `rem`
    %4 = trunc i64 %3 to i32
; └└
; ┌ @ special/exp.jl:208 within `exp_impl`
; │┌ @ float.jl:392 within `-`
    %5 = fadd double %2, 0xC338000000000000
; └└
; ┌ @ special/exp.jl:209 within `exp_impl`
...

@KristofferC KristofferC requested a review from vtjnash May 19, 2021 08:33
@JeffBezanson JeffBezanson merged commit 6f867eb into master May 19, 2021
@JeffBezanson JeffBezanson deleted the kc/llvm_func branch May 19, 2021 18:06
@vtjnash
Copy link
Sponsor Member

vtjnash commented May 19, 2021

This file should not be changed without making the same change in base/compiler/ssair/show.jl

Correct code highlighting should see this is inside a comment?

The old quotes matched what some old tools do when building, but perhaps now these should be unicode ‘exp_impl’?

@KristofferC
Copy link
Sponsor Member Author

Correct code highlighting should see this is inside a comment?

See the very first sentence:

It is quite common to include parts of @code_llvm in julia code blocks.

I'll update the other file as well then.

KristofferC added a commit that referenced this pull request May 20, 2021
KristofferC added a commit that referenced this pull request May 20, 2021
KristofferC added a commit that referenced this pull request May 20, 2021
shirodkara pushed a commit to shirodkara/julia that referenced this pull request Jun 9, 2021
shirodkara pushed a commit to shirodkara/julia that referenced this pull request Jun 9, 2021
johanmon pushed a commit to johanmon/julia that referenced this pull request Jul 5, 2021
johanmon pushed a commit to johanmon/julia that referenced this pull request Jul 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants