Comments (6)
Can you reproduce with a supported Julia version?
from julia.
I can reproduce it with 1.10.3:
julia> function test_maximum()
a = [0.5 1 3]
d = -1
c = maximum(a)
if c < d
c = maximum[a]
else
c = maximum[a]
end
end
test_maximum (generic function with 1 method)
julia> test_maximum()
ERROR: MethodError: no method matching getindex(::typeof(maximum), ::Matrix{Float64})
Stacktrace:
[1] test_maximum()
@ Main ./REPL[1]:0
[2] top-level scope
@ REPL[2]:1
julia> versioninfo()
Julia Version 1.10.3
Commit 0b4590a5507 (2024-04-30 10:59 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 8 × Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-15.0.7 (ORCJIT, skylake)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)
Also, as OP said, changing one branch leads to the correct line number being reported:
julia> function test_maximum()
a = [0.5 1 3]
d = -1
c = maximum(a)
if c < d
c = 1. # changed here
else
c = maximum[a]
end
end
test_maximum (generic function with 1 method)
julia> test_maximum()
ERROR: MethodError: no method matching getindex(::typeof(maximum), ::Matrix{Float64})
Stacktrace:
[1] test_maximum()
@ Main ./REPL[6]:8
[2] top-level scope
@ REPL[7]:1
from julia.
I think what's happening here is that the two branches are recognized as equal and therefore the whole if ... end
is effectively replaced with a single c = maximum[a]
. But that no longer has a unique line number (could be 6 or 8), and that is apparently signaled by setting the line number to zero.
BTW, a smaller reproducer is
function test_maximum(b)
if b
maximum[1]
else
maximum[1]
end
end
for which @code_llvm
easily confirms that the branch has been eliminated.
from julia.
Running with -O0
gives the correct line number.
from julia.
This might be an interesting test-case for JuliaLowering @c42f
from julia.
Lowering is doing fine here. For the reduced test_maximum
from #54541 (comment), we have
julia> @code_typed debuginfo=:source test_maximum(true)
CodeInfo(
@ REPL[1]:2 within `test_maximum`
1 ─ goto #3 if not b
@ REPL[1]:3 within `test_maximum`
2 ─ Base.getindex(Main.maximum, 1)::Union{}
└── unreachable
@ REPL[1]:5 within `test_maximum`
3 ─ Base.getindex(Main.maximum, 1)::Union{}
└── unreachable
) => Union{}
We can see that the line info is there even after inference/Julia level optimization. But than LLVM elides the unnecessary branch and doesn't know which line info to keep:
julia> @code_llvm debuginfo=:source test_maximum(true)
; Function Signature: test_maximum(Bool)
; @ REPL[1]:1 within `test_maximum`
; Function Attrs: noreturn
define void @julia_test_maximum_3590(i8 zeroext %"b::Bool") #0 {
top:
%jlcallframe1 = alloca [2 x ptr], align 8
; @ REPL[1] within `test_maximum`
store ptr @"jl_global#3595.jit", ptr %jlcallframe1, align 8
%0 = getelementptr inbounds ptr, ptr %jlcallframe1, i64 1
store ptr @"jl_global#3596.jit", ptr %0, align 8
%1 = call nonnull ptr @ijl_apply_generic(ptr nonnull @"jl_global#3594.jit", ptr nonnull %jlcallframe1, i32 2)
call void @llvm.trap()
unreachable
}
from julia.
Related Issues (20)
- ^C inside pkg-add prompt causes assertion abort
- Argument destructuring returned from macro accidentally assigns global
- Potentially erring paths in matrix logarithms HOT 1
- `nm -D --with-symbol-versions` unreliable
- julia1.10.4 using CUDA ERROR: failed to parse TOML output from running "~/.julia/packages/CUDA_Runtime_jll/VNnmC/.pkg/select_artifacts.jl", got: TOML Parser error: none:1:7 error: expected equal sign after key
- Stack overflow during gc_read_stack on win32 HOT 2
- Make an `isdense` trait HOT 8
- `factorize(<:AbstractMatrix)` prefers `Cholesky` but `factorize(<:Hermitian)` prefers `BunchKaufman` HOT 2
- Concurrent program crashes 1.12 nightly build (1.10 is fine) HOT 1
- Intermittent segmentation fault while running CFITSIO tests on nightly HOT 2
- Conversion to pointer not defined for `Base.ReinterpretArray` on v1.11 and above HOT 2
- Julia Rejecting this target due to use of runtime-disabled feature HOT 3
- Base.PersistentDict/HAMT: rehashing is ineffective HOT 4
- suboptimal subtyping: tuple types vs unions of tuple types
- segmentation fault on julia nightly - macos 14 - aarch64 HOT 4
- Clean up syntactic multi-assignment? HOT 1
- JuliaSyntax's documentation is overflowing into the main Julia documentation
- Methods may be added to a function from a different module without it being explicitly imported HOT 2
- REPL errors "randomly" after fake Pkg prompt PR HOT 7
- Mistaken "invalid redefinition" for self-referential types
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from julia.