Skip to content

Move null check from Printer to halide_string_to_string() #6467

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
Dec 8, 2021

Conversation

steven-johnson
Copy link
Contributor

The Printer is (currently) usually inlined into every module, so this check is repeated in multiple chunks of code. Since the goal is to avoid crashing when debugging, let's move it to halide_string_to_string() (which will catch all these, and possibly more) and save some code size.

(Further improvements in Printer code size on the way; this change seems worthy of considering separately.)

The Printer is (currently) usually inlined into every module, so this check is repeated in multiple chunks of code. Since the goal is to avoid crashing when debugging, let's move it to halide_string_to_string() (which will catch all these, and possibly more) and save some code size.

(Further improvements in Printer code size on the way; this change seems worthy of considering separately.)
@steven-johnson
Copy link
Contributor Author

Windows failure appears to be a flake.

@steven-johnson
Copy link
Contributor Author

Gentle review ping

@abadams
Copy link
Member

abadams commented Dec 8, 2021

string_to_string is used in a lot of places where the arg is known to be non-null (e.g. when you use a print expression in the IR). If this is just about moving the check out of the inlined Printer, can that be handled in #6473 ?

@steven-johnson
Copy link
Contributor Author

If this is just about moving the check out of the inlined Printer, can that be handled in #6473 ?

It was originally about that, yes, and yes it can be handled elsewhere, but (again) I'd argue that if we want to put in a guard against crashing due to rogue null string ptrs, this is the better place to do it.

@steven-johnson
Copy link
Contributor Author

If this is just about moving the check out of the inlined Printer, can that be handled in #6473 ?

It was originally about that, yes, and yes it can be handled elsewhere, but (again) I'd argue that if we want to put in a guard against crashing due to rogue null string ptrs, this is the better place to do it.

(I'm not 100% married to this change, just think it's worthy of consideration in the name of defensive coding.)

@abadams
Copy link
Member

abadams commented Dec 8, 2021

I don't think anything performance-critical calls this, so sure why not in the name of defensive programming.

@steven-johnson steven-johnson merged commit d089588 into master Dec 8, 2021
@steven-johnson steven-johnson deleted the srj/to-string branch December 8, 2021 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants