-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Add discriminators to DILocations when multiple functions are inlined into a single point. #132613
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
//@ force-host | ||
//@ no-prefer-dynamic | ||
#![crate_type = "proc-macro"] | ||
|
||
extern crate proc_macro; | ||
use proc_macro::*; | ||
|
||
#[proc_macro] | ||
pub fn square_twice(_item: TokenStream) -> TokenStream { | ||
"(square(env::vars().count() as i32), square(env::vars().count() as i32))".parse().unwrap() | ||
} |
53 changes: 53 additions & 0 deletions
53
tests/codegen/debuginfo-proc-macro/mir_inlined_twice_var_locs.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
//@ min-llvm-version: 19 | ||
//@ compile-flags: -Cdebuginfo=2 -Copt-level=0 -Zmir-enable-passes=+Inline | ||
// MSVC is different because of the individual allocas. | ||
//@ ignore-msvc | ||
|
||
//@ aux-build:macro_def.rs | ||
|
||
// Find the variable. | ||
// CHECK-DAG: ![[#var_dbg:]] = !DILocalVariable(name: "n",{{( arg: 1,)?}} scope: ![[#var_scope:]] | ||
|
||
// Find both dbg_declares. These will proceed the variable metadata, of course, so we're looking | ||
// backwards. | ||
// CHECK-DAG: dbg_declare(ptr %n.dbg.spill{{[0-9]}}, ![[#var_dbg]], !DIExpression(), ![[#var_loc2:]]) | ||
// CHECK-DAG: dbg_declare(ptr %n.dbg.spill, ![[#var_dbg]], !DIExpression(), ![[#var_loc1:]]) | ||
|
||
// Find the first location definition, looking forwards again. | ||
// CHECK: ![[#var_loc1]] = !DILocation | ||
// CHECK-SAME: scope: ![[#var_scope:]], inlinedAt: ![[#var_inlinedAt1:]] | ||
|
||
// Find the first location's inlinedAt | ||
// NB: If we fail here it's *probably* because we failed to produce two | ||
// different locations and ended up reusing an earlier one. | ||
// CHECK: ![[#var_inlinedAt1]] = !DILocation | ||
// CHECK-SAME: scope: ![[var_inlinedAt1_scope:]] | ||
|
||
// Find the second location definition, still looking forwards. | ||
// NB: If we failed to produce two different locations, the test will | ||
// definitely fail by this point (if it hasn't already) because we won't | ||
// be able to find the same line again. | ||
// CHECK: ![[#var_loc2]] = !DILocation | ||
// CHECK-SAME: scope: ![[#var_scope]], inlinedAt: ![[#var_inlinedAt2:]] | ||
|
||
// Find the second location's inlinedAt. | ||
// CHECK: ![[#var_inlinedAt2]] = !DILocation | ||
// CHECK-SAME: scope: ![[#var_inlinedAt2_scope:]] | ||
|
||
// Finally, check that a discriminator was emitted for the second scope. | ||
// FIXMEkhuey ideally we would check that *either* scope has a discriminator | ||
// but I don't know that it's possible to check that with FileCheck. | ||
// CHECK: ![[#var_inlinedAt2_scope]] = !DILexicalBlockFile | ||
// CHECK-SAME: discriminator: [[#]] | ||
extern crate macro_def; | ||
|
||
use std::env; | ||
|
||
fn square(n: i32) -> i32 { | ||
n * n | ||
} | ||
|
||
fn main() { | ||
let (z1, z2) = macro_def::square_twice!(); | ||
println!("{z1} == {z2}"); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.