Skip to content

Update assembly filter to handle LLVM comments #407

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 1 commit into from
Sep 20, 2018

Conversation

wfchandler
Copy link
Contributor

Fixes #406

The LLVM comments recently added to assembly are not handled by the existing filtering scripts, causing some labels to be removed incorrectly.

This commit makes the following updates:

  • Fixes the assembly filtering to recognize labels with a comment on the same line
  • Retain comments that are on their own line
    • For now I've retained the # %bb comments as seen in the example below. I'm not sure how much utility they provide, but they also don't create too much noise.
  • Directive types that were previously removed will continue to be removed even if they have a comment
    • This removes the "Begin function..." comments added to .p2align directives, but still retains the standalone "End function" comments. I don't think this will be confusing as the filtering makes it easy to tell which function we're in. Below is an example for reference:

Raw

	.p2align	4, 0x90         # -- Begin function <T as core::any::Any>::get_type_id
	.type	<T as core::any::Any>::get_type_id,@function
<T as core::any::Any>::get_type_id: # @"<T as core::any::Any>::get_type_id"
	.cfi_startproc
# %bb.0:
	movabsq	$7549865886324542212, %rax # imm = 0x68C68305D036CB04
	retq
.Lfunc_end0:
	.size	<T as core::any::Any>::get_type_id, .Lfunc_end0-<T as core::any::Any>::get_type_id
	.cfi_endproc
                                        # -- End function

Filtered

<T as core::any::Any>::get_type_id: # @"<T as core::any::Any>::get_type_id"
# %bb.0:
	movabsq	$7549865886324542212, %rax # imm = 0x68C68305D036CB04
	retq
                                        # -- End function

The addition of LLVM comments to the generated
asm has prevented the filtering script from
recognizing some labels. This commit fixes
the missing labels and should keep comments
in the filtered asm.
@shepmaster
Copy link
Member

@scottmcm do you have any opinions on the improved output?

@wfchandler
Copy link
Contributor Author

Interesting paper re reordering basic blocks (bb):

https://arxiv.org/abs/1809.04676

@shepmaster shepmaster merged commit 3ff605f into rust-lang:master Sep 20, 2018
@shepmaster shepmaster added the bug The playground isn't doing what it was intended to label Sep 20, 2018
@wfchandler wfchandler deleted the fix_asm_comments branch September 26, 2018 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The playground isn't doing what it was intended to
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants