<feed xmlns='http://www.w3.org/2005/Atom'>
<title>rust/compiler/rustc_codegen_llvm/src/debuginfo, branch 1.74.0</title>
<subtitle>https://github.com/rust-lang/rust
</subtitle>
<id>http://git.dreamy.place/mirrors/rust/atom?h=1.74.0</id>
<link rel='self' href='http://git.dreamy.place/mirrors/rust/atom?h=1.74.0'/>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/'/>
<updated>2023-09-26T07:37:55+00:00</updated>
<entry>
<title>subst -&gt; instantiate</title>
<updated>2023-09-26T07:37:55+00:00</updated>
<author>
<name>lcnr</name>
<email>rust@lcnr.de</email>
</author>
<published>2023-09-25T13:46:38+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=3c52a3e280a5fd1e8e4b48a5ec349aa00dcd859c'/>
<id>urn:sha1:3c52a3e280a5fd1e8e4b48a5ec349aa00dcd859c</id>
<content type='text'>
</content>
</entry>
<entry>
<title>treat host effect params as erased generics in codegen</title>
<updated>2023-09-14T07:34:35+00:00</updated>
<author>
<name>Deadbeef</name>
<email>ent3rm4n@gmail.com</email>
</author>
<published>2023-09-13T13:55:23+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=a0a801cd3807498bdf6b0d7fd4148fdff9ede4b1'/>
<id>urn:sha1:a0a801cd3807498bdf6b0d7fd4148fdff9ede4b1</id>
<content type='text'>
This fixes the changes brought to codegen tests when effect params are
added to libcore, by not attempting to monomorphize functions that get
the host param by being `const fn`.
</content>
</entry>
<entry>
<title>Auto merge of #115417 - dpaoliello:fixdi, r=wesleywiser</title>
<updated>2023-09-08T20:56:01+00:00</updated>
<author>
<name>bors</name>
<email>bors@rust-lang.org</email>
</author>
<published>2023-09-08T20:56:01+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=62ebe3a2b177d50ec664798d731b8a8d1a9120d1'/>
<id>urn:sha1:62ebe3a2b177d50ec664798d731b8a8d1a9120d1</id>
<content type='text'>
Use the same DISubprogram for each instance of the same inlined function within a caller

# Issue Details:
The call to `panic` within a function like `Option::unwrap` is translated to LLVM as a `tail call` (as it will never return), when multiple calls to the same function like this are inlined LLVM will notice the common `tail call` block (i.e., loading the same panic string + location info and then calling `panic`) and merge them together.

When merging these instructions together, LLVM will also attempt to merge the debug locations as well, but this fails (i.e., debug info is dropped) as Rust emits a new `DISubprogram` at each inline site thus LLVM doesn't recognize that these are actually the same function and so thinks that there isn't a common debug location.

As an example of this, consider the following program:
```rust
#[no_mangle]
fn add_numbers(x: &amp;Option&lt;i32&gt;, y: &amp;Option&lt;i32&gt;) -&gt; i32 {
    let x1 = x.unwrap();
    let y1 = y.unwrap();

    x1 + y1
}
```

 When building for x86_64 Windows using 1.72 it generates (note the lack of `.cv_loc` before the call to `panic`, thus it will be attributed to the same line at the `addq` instruction):

```llvm
	.cv_loc	0 1 3 0                        # src\lib.rs:3:0
	addq	$40, %rsp
	retq
	leaq	.Lalloc_f570dea0a53168780ce9a91e67646421(%rip), %rcx
	leaq	.Lalloc_629ace53b7e5b76aaa810d549cc84ea3(%rip), %r8
	movl	$43, %edx
	callq	_ZN4core9panicking5panic17h12e60b9063f6dee8E
	int3
```

# Fix Details:
Cache the `DISubprogram` emitted for each inlined function instance within a caller so that this can be reused if that instance is encountered again.

Ideally, we would also deduplicate child scopes and variables, however my attempt to do that with #114643 resulted in asserts when building for Linux (#115156) which would require some deep changes to Rust to fix (#115455).

Instead, when using an inlined function as a debug scope, we will also create a new child scope such that subsequent child scopes and variables do not collide (from LLVM's perspective).

After this change the above assembly now (with &lt;https://reviews.llvm.org/D159226&gt; as well) shows the `panic!` was inlined from `unwrap` in `option.rs` at line 935 into the current function in `lib.rs` at line 0 (line 0 is emitted since it is ambiguous which line to use as there were two inline sites that lead to this same code):

```llvm
	.cv_loc	0 1 3 0                        # src\lib.rs:3:0
	addq	$40, %rsp
	retq
	.cv_inline_site_id 6 within 0 inlined_at 1 0 0
	.cv_loc	6 2 935 0                       # library\core\src\option.rs:935:0
	leaq	.Lalloc_5f55955de67e57c79064b537689facea(%rip), %rcx
	leaq	.Lalloc_e741d4de8cb5801e1fd7a6c6795c1559(%rip), %r8
	movl	$43, %edx
	callq	_ZN4core9panicking5panic17hde1558f32d5b1c04E
	int3
```
</content>
</entry>
<entry>
<title>Use `Freeze` for `SourceFile.lines`</title>
<updated>2023-09-07T11:05:05+00:00</updated>
<author>
<name>John Kåre Alsaker</name>
<email>john.kare.alsaker@gmail.com</email>
</author>
<published>2023-08-31T20:12:47+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=f49382c0508db608aa9c33d6a8c77d2955d8f62c'/>
<id>urn:sha1:f49382c0508db608aa9c33d6a8c77d2955d8f62c</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Use relative positions inside a SourceFile.</title>
<updated>2023-09-03T12:56:10+00:00</updated>
<author>
<name>Camille GILLOT</name>
<email>gillot.camille@gmail.com</email>
</author>
<published>2023-09-03T10:15:35+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=258ace613da6b8c90ba4995738cb13791388c4bb'/>
<id>urn:sha1:258ace613da6b8c90ba4995738cb13791388c4bb</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Deduplicate inlined function debug info, but create a new lexical scope to child subsequent scopes and variables from colliding</title>
<updated>2023-09-01T21:27:21+00:00</updated>
<author>
<name>Daniel Paoliello</name>
<email>danpao@microsoft.com</email>
</author>
<published>2023-09-01T21:27:21+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=06890774ab4f4f494be55fd6fe1097636fbea7c1'/>
<id>urn:sha1:06890774ab4f4f494be55fd6fe1097636fbea7c1</id>
<content type='text'>
</content>
</entry>
<entry>
<title>const_eval and codegen: audit uses of is_zst</title>
<updated>2023-08-29T07:03:46+00:00</updated>
<author>
<name>Ralf Jung</name>
<email>post@ralfj.de</email>
</author>
<published>2023-08-27T16:12:34+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=b2ebf1c23f93886ba7d3738878f04e275add4ead'/>
<id>urn:sha1:b2ebf1c23f93886ba7d3738878f04e275add4ead</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Revert "Use the same DISubprogram for each instance of the same inlined function within the caller"</title>
<updated>2023-08-25T23:49:10+00:00</updated>
<author>
<name>Wesley Wiser</name>
<email>wesleywiser@microsoft.com</email>
</author>
<published>2023-08-25T23:49:10+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=d0b2c4f72760915b2503ca14ce3cad305ce7dc52'/>
<id>urn:sha1:d0b2c4f72760915b2503ca14ce3cad305ce7dc52</id>
<content type='text'>
This reverts commit 687bffa49375aa00bacc51f5d9adfb84a9453e17.

Reverting to resolve ICEs reported on nightly.
</content>
</entry>
<entry>
<title>Auto merge of #114643 - dpaoliello:inlinedebuginfo, r=wesleywiser</title>
<updated>2023-08-22T20:15:29+00:00</updated>
<author>
<name>bors</name>
<email>bors@rust-lang.org</email>
</author>
<published>2023-08-22T20:15:29+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=154ae32a554a457a8e712ac85ba2199755646e79'/>
<id>urn:sha1:154ae32a554a457a8e712ac85ba2199755646e79</id>
<content type='text'>
Use the same DISubprogram for each instance of the same inlined function within a caller

# Issue Details:
The call to `panic` within a function like `Option::unwrap` is translated to LLVM as a `tail call` (as it will never return), when multiple calls to the same function like this is inlined LLVM will notice the common `tail call` block (i.e., loading the same panic string + location info and then calling `panic`) and merge them together.

When merging these instructions together, LLVM will also attempt to merge the debug locations as well, but this fails (i.e., debug info is dropped) as Rust emits a new `DISubprogram` at each inline site thus LLVM doesn't recognize that these are actually the same function and so thinks that there isn't a common debug location.

As an example of this when building for x86_64 Windows (note the lack of `.cv_loc` before the call to `panic`, thus it will be attributed to the same line at the `addq` instruction):

```
	.cv_loc	0 1 23 0                        # src\lib.rs:23:0
	addq	$40, %rsp
	retq
	leaq	.Lalloc_f570dea0a53168780ce9a91e67646421(%rip), %rcx
	leaq	.Lalloc_629ace53b7e5b76aaa810d549cc84ea3(%rip), %r8
	movl	$43, %edx
	callq	_ZN4core9panicking5panic17h12e60b9063f6dee8E
	int3
```

# Fix Details:
Cache the `DISubprogram` emitted for each inlined function instance within a caller so that this can be reused if that instance is encountered again, this also requires caching the `DILexicalBlock` and `DIVariable` objects to avoid creating duplicates.

After this change the above assembly now looks like:

```
	.cv_loc	0 1 23 0                        # src\lib.rs:23:0
	addq	$40, %rsp
	retq
	.cv_inline_site_id 5 within 0 inlined_at 1 0 0
	.cv_inline_site_id 6 within 5 inlined_at 1 12 0
	.cv_loc	6 2 935 0                       # library\core\src\option.rs:935:0
	leaq	.Lalloc_5f55955de67e57c79064b537689facea(%rip), %rcx
	leaq	.Lalloc_e741d4de8cb5801e1fd7a6c6795c1559(%rip), %r8
	movl	$43, %edx
	callq	_ZN4core9panicking5panic17hde1558f32d5b1c04E
	int3
```
</content>
</entry>
<entry>
<title>Fix spelling mistake</title>
<updated>2023-08-22T19:30:26+00:00</updated>
<author>
<name>Wesley Wiser</name>
<email>wwiser@gmail.com</email>
</author>
<published>2023-08-22T19:30:26+00:00</published>
<link rel='alternate' type='text/html' href='http://git.dreamy.place/mirrors/rust/commit/?id=1097e0957e299613fac4ea58c85aaf8204075a62'/>
<id>urn:sha1:1097e0957e299613fac4ea58c85aaf8204075a62</id>
<content type='text'>
</content>
</entry>
</feed>
