-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Never create allocas for indirect function arguments #27687
Conversation
r? @arielb1 (rust_highfive has picked a reviewer for you, use r? to override) |
let arg_datum = if !has_tupled_arg || i < arg_tys.len() - 1 { | ||
if type_of::arg_is_indirect(bcx.ccx(), arg_ty) | ||
&& bcx.sess().opts.debuginfo != FullDebugInfo { | ||
if indirect_arg { | ||
// Don't copy an indirect argument to an alloca, the caller | ||
// already put it in a temporary alloca and gave it up, unless | ||
// we emit extra-debug-info, which requires local allocas :(. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The last part of this comment is outdated now, isn't it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right!
The assertion that argument debuginfo always has to be assigned to allocas only exists in rustc, not in LLVM. The reason for that assertion might have been that we used to created bad debuginfo for closures which did indeed lead to errors when we skipped the alloca, but this was fixed in commit 218eccf "Fix de-deduplication for closure debuginfo". So now we can always skip the alloca for indirect arguments, even when generating debuginfo.
Interesting. I remember running into lots of problems when not having allocas and LLVM didn't really have any documentation on it's requirement in this respect. But that was quite some time and LLVM updates ago and before unboxed closures were a thing in Rust. Maybe things have changed. |
Yes, it did pass make check for me. Had to wait for the new snapshot that
|
OK, let's give it a try |
@bors: r+ |
📌 Commit 98258e3 has been approved by |
⌛ Testing commit 98258e3 with merge 3c7f021... |
💔 Test failed - auto-mac-32-opt |
@michaelwoerister Any idea what might be wrong here? gdb has no problem with those changes, and AFAICT, this PR makes rustc behave the same as clang, so I don't really know where to look. |
I'll see if I can find out something over the weekend. |
OK, so I can reproduce this error locally for 32bit builds and it seems that the DWARF information does not contain the entries for some parameters. E.g. in associated-types.rs for
In other cases, it is there as expected:
In the 64bit version, the entry does show up:
Is it possible that the 32bit code generator will just remove the variable altogether while the 64bit one doesn't? |
Weird, I can reproduce this on Linux i686 now, too. Not sure why it didn't happen before. And, I can also reproduce the problem with clang. |
@michaelwoerister I figured this out now. It's a limitation of FastISel. On X86_64, the pointer is in a register, but on x86 it's on the stack. And apparently handling the value on the stack is something FastISel can't do yet. https://github.com/llvm-mirror/llvm/blob/master/lib/CodeGen/SelectionDAG/FastISel.cpp#L1173 That is triggered for x86 but not for x86_64. I'm not sure how we want to proceed here. Drop the patch or only skip the alloca when optimizations are turned on? |
☔ The latest upstream changes (presumably #28138) made this pull request unmergeable. Please resolve the merge conflicts. |
@dotdash Cool that you found out what the problem is in LLVM! |
@michaelwoerister Well, the information is only "guaranteed" to be lost when optimizations are turned off, and thus FastISel is turned on. With optimizations turned on, the debug info is possibly preserved. Anyway, I agree on this slightly complicating the code. So until I find a less complicated way and the problem in LLVM gets fixed, I'll close this. |
The assertion that argument debuginfo always has to be assigned to
allocas only exists in rustc, not in LLVM. The reason for that assertion
might have been that we used to created bad debuginfo for closures which
did indeed lead to errors when we skipped the alloca, but this was fixed
in commit 218eccf "Fix de-deduplication for closure debuginfo".
So now we can always skip the alloca for indirect arguments, even when
generating debuginfo.