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

Update __rust_{alloc,realloc} builtins #89

Closed
wants to merge 2 commits into from
Closed

Update __rust_{alloc,realloc} builtins #89

wants to merge 2 commits into from

Conversation

jacob-hughes
Copy link

The prototypes for these alloc functions changed in library/alloc and need updating here.

Uncovered as part of zulip discussion here.

The prototypes for these alloc functions changed in library/alloc and
need updating here.
@nikic
Copy link

nikic commented Feb 3, 2021

The zulip thread mentions that after this change one test no longer optimizes. Is that still the case, or was that with an earlier version?

@jacob-hughes
Copy link
Author

jacob-hughes commented Feb 3, 2021

Hi @nikic the suite passes fine with these changes. That was user error! When I was working on these changes, I'd inadvertently reordered the builtins, and there is an invariant that these must be defined in alphabetical order -- something I missed as I'd compiled LLVM without assertions 🤦

@nikic
Copy link

nikic commented Feb 3, 2021

I've looked into why this works despite the incorrect checks, and it turns out that getAllocationDataForFunction is using the getLibFunc API that only checks the function name, and then performs it's own signature checks. And the parameter counts specified in MemoryBuiltins were correct. As such, the libcall detection logic ultimately didn't matter.

Possibly it makes sense to just drop these checks entirely, if they're going to be ignored anyway? Though we could also add some additional FuncAttrs inference, in particular adding noalias, inaccessible_mem_only and willreturn attributes may be beneficial (and that part would require passing signature checks).

@jacob-hughes
Copy link
Author

jacob-hughes commented Feb 4, 2021

That's interesting, and explains a lot. I'm happy to remove these checks entirely if you'd prefer.

Though we could also add some additional FuncAttrs inference, in particular adding noalias, inaccessible_mem_only and willreturn attributes may be beneficial (and that part would require passing signature checks).

IIUC noalias is already passed to the callsite with the #[rustc_allocator] attribute on __rustc_alloc. What benefit is gained by adding it here also?

@nikic
Copy link

nikic commented Feb 5, 2021

Though we could also add some additional FuncAttrs inference, in particular adding noalias, inaccessible_mem_only and willreturn attributes may be beneficial (and that part would require passing signature checks).

IIUC noalias is already passed to the callsite with the #[rustc_allocator] attribute on __rustc_alloc. What benefit is gained by adding it here also?

Right. For reference, this happens here:

https://github.com/rust-lang/rust/blob/38030ffb4e735b26260848b744c0910a5641e1db/compiler/rustc_codegen_llvm/src/attributes.rs#L302-L304

I guess if we wanted to add more attributes, it would make sense to do so there as well, no point in doing it on the LLVM side really.

I think in that case it would be best to just drop this code.

@jacob-hughes
Copy link
Author

Do you mean close the PR? Or remove the rust alloc functions from the TargetLibraryInfo parts of LLVM?

@nikic
Copy link

nikic commented Feb 6, 2021

Do you mean close the PR? Or remove the rust alloc functions from the TargetLibraryInfo parts of LLVM?

I mean remove the signature checks in TargetLibraryInfo.cpp handling, as they are effectively unused.

@jacob-hughes
Copy link
Author

Something like this 40d6804?

@nikic
Copy link

nikic commented Aug 15, 2021

Due to changes in LLVM 13 these checks actually matter now, so I've included the original version of this PR as part of the rebase (b1f55f7 is the new commit).

@nikic nikic closed this Aug 15, 2021
vext01 added a commit to vext01/llvm-project that referenced this pull request Oct 6, 2023
89: Serialise alloca properly. r=ltratt a=vext01



Co-authored-by: Edd Barrett <[email protected]>
nikic pushed a commit to nikic/llvm-project that referenced this pull request Dec 21, 2023
This PR adds support for thread names in lldb on Windows.

```
(lldb) thr list
Process 2960 stopped
  thread rust-lang#53: tid = 0x03a0, 0x00007ff84582db34 ntdll.dll`NtWaitForMultipleObjects + 20
  thread rust-lang#29: tid = 0x04ec, 0x00007ff845830a14 ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'SPUW.6'
  thread rust-lang#89: tid = 0x057c, 0x00007ff845830a14 ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'PPU[0x1000019] physics[main]'
  thread rust-lang#3: tid = 0x0648, 0x00007ff843c2cafe combase.dll`InternalDoATClassCreate + 39518
  thread rust-lang#93: tid = 0x0688, 0x00007ff845830a14 ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'PPU[0x100501d] uMovie::StreamingThread'
  thread #1: tid = 0x087c, 0x00007ff842e7a104 win32u.dll`NtUserMsgWaitForMultipleObjectsEx + 20
  thread rust-lang#96: tid = 0x0890, 0x00007ff845830a14 ntdll.dll`NtWaitForAlertByThreadId + 20, name = 'PPU[0x1002020] HLE Video Decoder'
<...>
```
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.

3 participants