Skip to content
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

Make if and while conditions temporary #12134

Merged
merged 1 commit into from
Feb 10, 2014

Conversation

flaper87
Copy link
Contributor

@flaper87 flaper87 commented Feb 9, 2014

Closes #12033

IR Before:

normal-return:                                    ; preds = %while_body
  %113 = load i64* %i
  %114 = sub i64 %113, 1
  store i64 %114, i64* %i
  br label %while_cond

IR After:

normal-return:                                    ; preds = %while_cond
  store i8 %11, i8* %0
  %18 = load i8* %0, !range !0
  call void @_ZN9Temporary9glue_drop19he4ee51d3c03b9cf4ajE(%struct.Temporary* %10)
  %19 = bitcast %struct.Temporary* %10 to i8*
  call void @_ZN2rt11global_heap14exchange_free_19h4fabdf24a2250163aj4v0.0E(i8* %19)
  %20 = icmp ne i8 %18, 0
  br i1 %20, label %while_body, label %while_exit

@flaper87
Copy link
Contributor Author

flaper87 commented Feb 9, 2014

@nikomatsakis r?

@huonw
Copy link
Member

huonw commented Feb 9, 2014

Is there a particular reason that the test case doesn't look anything like #12033 at all? (And also, isn't the while part useless, since it's not actually checking that it was dropped inside the loop?)

@flaper87
Copy link
Contributor Author

flaper87 commented Feb 9, 2014

@huonw not sure what you mean with "it doesn't look like #12033 at all"

Also, it's not necessary to check at every iteration, although we could. Before the fix, just 1 Temporary was freed at the end of the loop. After the fix, all Temporarys are freed.

@huonw
Copy link
Member

huonw commented Feb 9, 2014

Ah, I see; I still think that ensuring that it's dropped inside the loop would be better: make test conservative as possible.

What I mean by being different is: the code in #12033 is demonstrating the borrow checker, while this doesn't test borrowck at all. (Calling a function borrow doesn't make it a borrow automatically. :) )

... But niko has r+'d so it's presumably ok.

@huonw
Copy link
Member

huonw commented Feb 9, 2014

Ah, wait! I think I misread the bug.

bors added a commit that referenced this pull request Feb 10, 2014
…akis

Closes #12033

IR Before:

```llvm
normal-return:                                    ; preds = %while_body
  %113 = load i64* %i
  %114 = sub i64 %113, 1
  store i64 %114, i64* %i
  br label %while_cond
```

IR After:

```llvm
normal-return:                                    ; preds = %while_cond
  store i8 %11, i8* %0
  %18 = load i8* %0, !range !0
  call void @_ZN9Temporary9glue_drop19he4ee51d3c03b9cf4ajE(%struct.Temporary* %10)
  %19 = bitcast %struct.Temporary* %10 to i8*
  call void @_ZN2rt11global_heap14exchange_free_19h4fabdf24a2250163aj4v0.0E(i8* %19)
  %20 = icmp ne i8 %18, 0
  br i1 %20, label %while_body, label %while_exit
```
@bors bors closed this Feb 10, 2014
@bors bors merged commit b0ef791 into rust-lang:master Feb 10, 2014
@flaper87 flaper87 deleted the temporary-conditions branch February 11, 2014 09:15
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 25, 2022
fix: Fix uncorrect use of double braces in HirDisplay implementations
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.

tweak temporary lifetime rules for if and while conditions
4 participants