Skip to content

Compiler switch to list bound checks #37397

@leonardo-m

Description

@leonardo-m

This is my first Rust enhancement request.

With the Go language compiler version 1.7, you can build the code using -gcflags="-d=ssa/check_bce/debug=1" to show which code lines still need checking bounds:

http://www.tapirgames.com/blog/golang-1.7-bce

Finding where the compiler is not able to optimize away run-time bound checks is important for some kinds of code where performance matters:

#30917

Currently to do that in Rust I have to generate the asm with --emit asm, search the function(s) (this sometimes is not so easy because of inlining) and then read the asm to understand if and where it performs bound checks. This is a bit laborious and not handy. So is it possible to add to Rustc a compilation switch similar to Go that outputs all the lines and column where LLVM isn't able to remove array bound tests?

In-bound test(s):
16 | foo[i] -= 1;
         ^

32 | foo[i] += bar[j];
         ^         ^

(Having this compiler switch is only about one third of this performance battle).

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: An issue proposing an enhancement or a PR with one.C-feature-requestCategory: A feature request, i.e: not implemented / a PR.I-slowIssue: Problems and improvements with respect to performance of generated code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions