Skip to content

Conversation

@philipc
Copy link
Contributor

@philipc philipc commented Feb 1, 2026

If a debug range started or ended on an instruction from a cold block, we omitted the entire range. Fix by skipping the instructions in the cold block to find the next valid offset.

Closes #11337

@philipc philipc requested review from a team as code owners February 1, 2026 06:02
@philipc philipc requested review from cfallin and dicej and removed request for a team February 1, 2026 06:02
If a debug range started or ended on an instruction from a cold block,
we omitted the entire range. Fix by skipping the instructions in the
cold block to find the next valid offset.
@philipc
Copy link
Contributor Author

philipc commented Feb 1, 2026

Before this change, the WASMTIME_LOG=cranelift_codegen::machinst::vcode=trace output for foo showed:

|BB|Inst    |IP         |VL0     |VL1      |VL2     |VL3      |VL4     |VL5     |VL6     |VL7     |VL8     |VL9     |VL10    |VL11    |VL12    |VL13    |VL14    |VL15    |VL16    |VL17    |VL18    |VL4294967294|
|--|--------|-----------|--------|---------|--------|---------|--------|--------|--------|--------|--------|--------|--------|--------|--------|--------|--------|--------|--------|--------|--------|------------|
|B0|Inst 0  |53         |    |   |    |    |    |   |    |    |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |       |
|  |Inst 1  |53         |v194|p2i|    |    |    |   |    |    |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |v192|p7i    |
|  |Inst 2  |60         |*   |p2i|v269|p13i|v196|   |    |    |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |*   |p7i    |
|  |Inst 3  |64         |*   |p2i|*   |p13i|*   |   |v268|p14i|    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |*   |p7i    |
|  |Inst 4  |68         |*   |p2i|*   |p13i|*   |   |*   |p14i|    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |*   |p7i    |
|  |Inst 5  |72         |*   |p2i|*   |p13i|*   |   |*   |p14i|    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |*   |p7i    |
|  |Inst 6  |76         |*   |p2i|*   |p13i|*   |   |*   |p14i|    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |*   |p7i    |
|  |Inst 7  |81         |*   |p2i|*   |p13i|*   |   |*   |p14i|    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |*   |p7i    |
|  |Inst 8  |83         |*   |   |*   |p13i|*   |   |*   |p14i|v265|p0i|    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |*   |p7i    |
|  |Inst 9  |88         |*   |   |*   |p13i|*   |   |*   |p14i|*   |   |v264|p1i|    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |*   |p7i    |
|  |Inst 10 |88         |*   |   |*   |p13i|*   |   |*   |p14i|*   |   |*   |p1i|    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |*   |p7i    |
|  |Inst 11 |91         |*   |   |*   |p13i|*   |   |*   |p14i|*   |   |*   |p1i|    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |*   |p7i    |
|  |Inst 12 |98         |*   |   |*   |p13i|*   |   |*   |p14i|*   |   |*   |p1i|    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |*   |p9i    |
|  |Inst 13 |100        |*   |   |*   |p13i|*   |   |*   |p14i|*   |   |*   |p1i|    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |*   |p9i    |
|  |Inst 14 |104        |*   |   |*   |p13i|*   |   |*   |p14i|*   |   |*   |p1i|    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |*   |p9i    |
|  |Inst 15 |107        |*   |   |*   |p13i|*   |   |*   |p14i|*   |   |*   |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |*   |p9i    |
|  |Inst 16 |111        |*   |   |*   |p13i|*   |   |*   |p14i|*   |   |*   |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |*   |p9i    |
|  |Inst 17 |117        |*   |   |*   |p13i|*   |   |*   |p14i|*   |   |*   |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |*   |p9i    |
|  |Inst 18 |121        |*   |   |*   |p13i|*   |   |*   |p14i|*   |   |*   |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |*   |p9i    |
|  |Inst 19 |124        |*   |   |*   |p13i|*   |   |*   |p14i|*   |   |*   |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |*   |p9i    |
|B1|Inst 20 |133        |*   |   |*   |p13i|*   |   |*   |p14i|*   |   |*   |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |*   |p9i    |
|B2|Inst 21 |4294967295 |*   |   |*   |p13i|*   |   |*   |p14i|*   |   |*   |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |*   |p9i    |
|  |Inst 22 |4294967295 |*   |   |*   |p13i|*   |   |*   |p14i|*   |   |*   |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |    |   |*   |p9i    |
|  |Inst 23 |4294967295 |*   |   |v255|p6i |v255|p6i|v255|p6i |v255|p6i|v255|p6i|v255|p6i|v255|p6i|v255|p6i|v255|p6i|v255|p6i|v255|p6i|v255|p6i|v255|p6i|v255|p6i|v255|p6i|v255|p6i|v255|p6i|v255|p6i|*   |p12i   |
|  |Inst 24 |4294967295 |*   |   |*   |    |*   |   |*   |    |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |p12i   |
|B3|Inst 25 |133        |*   |   |*   |    |*   |   |*   |    |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |p12i   |
|  |Inst 26 |137        |*   |   |*   |    |*   |   |*   |    |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |p12i   |
|  |Inst 27 |142        |*   |   |*   |    |*   |   |*   |    |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |p12i   |
|  |Inst 28 |145        |*   |   |*   |    |*   |   |*   |    |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |p12i   |
|  |Inst 29 |151        |*   |   |*   |    |*   |   |*   |    |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |p12i   |
|  |Inst 30 |155        |*   |   |*   |    |*   |   |*   |    |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |p12i   |
|  |Inst 31 |162        |*   |   |*   |    |*   |   |*   |    |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |p12i   |
|  |Inst 32 |164        |*   |   |*   |    |*   |   |*   |    |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |p12i   |
|  |Inst 33 |167        |*   |   |*   |    |*   |   |*   |    |*   |   |*   |   |v248|p7i|*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |p12i   |
|  |Inst 34 |171        |*   |   |*   |    |*   |   |*   |    |*   |   |*   |   |*   |   |v247|p7i|v234|   |v247|p7i|v234|   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |p12i   |
|  |Inst 35 |174        |*   |   |*   |    |*   |   |*   |    |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |p12i   |
|B4|Inst 36 |180        |*   |   |*   |    |*   |   |*   |    |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |p12i   |
|  |Inst 37 |189        |*   |   |*   |    |*   |   |*   |    |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |p12i   |
|B5|Inst 38 |194        |*   |   |*   |    |*   |   |*   |    |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |v240|   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |p12i   |
|  |Inst 39 |203        |*   |   |*   |    |*   |   |*   |    |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |p12i   |
|B6|Inst 40 |203        |*   |   |*   |    |*   |   |*   |    |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |p12i   |
|  |Inst 41 |208        |*   |   |*   |    |*   |   |*   |    |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |v246|p0i|*   |   |*   |   |*   |p12i   |
|  |Inst 42 |213        |*   |   |*   |    |*   |   |*   |    |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |p0i|*   |   |*   |   |*   |p12i   |
|  |Inst 43 |213        |*   |   |*   |    |*   |   |*   |    |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |   |*   |p0i|*   |   |*   |   |*   |       |
Recording debug range for VL0 in Reg(p2i): [Inst 1..Inst 8) [53..83)
Recording debug range for VL3 in Reg(p14i): [Inst 3..Inst 5) [64..72)
Recording debug range for VL4 in Reg(p0i): [Inst 8..Inst 9) [83..88)
Recording debug range for VL5 in Reg(p1i): [Inst 9..Inst 15) [88..107)
Recording debug range for VL6 in Reg(p7i): [Inst 33..Inst 34) [167..171)
Recording debug range for VL7 in Reg(p7i): [Inst 34..Inst 35) [171..174)
Recording debug range for VL9 in Reg(p7i): [Inst 34..Inst 35) [171..174)
Recording debug range for VL16 in Reg(p0i): [Inst 41..Inst 44) [208..264)
Recording debug range for VL4294967294 in Reg(p7i): [Inst 1..Inst 12) [53..98)

After this change we get:

Recording debug range for VL0 in Reg(p2i): [Inst 1..Inst 8) [53..83)
Recording debug range for VL1 in Reg(p13i): [Inst 2..Inst 23) [60..133)
Recording debug range for VL3 in Reg(p14i): [Inst 3..Inst 5) [64..72)
Extending debug range for VL3 in Reg(p14i) to Inst 23 (133)
Recording debug range for VL4 in Reg(p0i): [Inst 8..Inst 9) [83..88)
Recording debug range for VL5 in Reg(p1i): [Inst 9..Inst 15) [88..107)
Recording debug range for VL6 in Reg(p7i): [Inst 33..Inst 34) [167..171)
Recording debug range for VL7 in Reg(p7i): [Inst 34..Inst 35) [171..174)
Recording debug range for VL9 in Reg(p7i): [Inst 34..Inst 35) [171..174)
Recording debug range for VL16 in Reg(p0i): [Inst 41..Inst 44) [208..264)
Recording debug range for VL4294967294 in Reg(p7i): [Inst 1..Inst 12) [53..98)
Recording debug range for VL4294967294 in Reg(p9i): [Inst 12..Inst 23) [98..133)
Recording debug range for VL4294967294 in Reg(p12i): [Inst 23..Inst 43) [133..213)

@github-actions github-actions bot added cranelift Issues related to the Cranelift code generator cranelift:area:machinst Issues related to instruction selection and the new MachInst backend. labels Feb 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cranelift:area:machinst Issues related to instruction selection and the new MachInst backend. cranelift Issues related to the Cranelift code generator

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Couldn't materialize" error in debugger after indirect call

1 participant