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

[REGRESSION] UNREACHABLE executed at lib/CodeGen/RegAllocFast.cpp:361! #26859

Closed
compnerd opened this issue Feb 5, 2016 · 3 comments
Closed
Labels
bugzilla Issues migrated from bugzilla llvm:regalloc

Comments

@compnerd
Copy link
Member

compnerd commented Feb 5, 2016

Bugzilla Link 26485
Resolution FIXED
Resolved on Feb 19, 2016 18:32
Version 3.8
OS All
Blocks #26433
Attachments reduced.c
CC @zmodem,@qcolombet

Extended Description

This is a regression lowering TLS access in C on Darwin, currently on 3.8 and 3.9 (master). The attached lit-style test case reproduces the fast reg alloc failure. Note that this only occurs at -O0 as the problem is only exhibited for the fast register allocator.

@qcolombet
Copy link
Collaborator

I’ll have a look.
Thanks for the report!

@qcolombet
Copy link
Collaborator

The bug is actually pretty obvious.
I am surprised this did not crash before!

Basically, we were not tracking properly the definitions of the physical register on calls and because of that, we may reuse one of this physical register for a virtual register before reaching the use of that physical register.
In that case:

CALL32m %EAX, 1, %noreg, 0, %noreg, <regmask %BH %BL %BP %BPL %BX %DI %DIL %EBP %EBX %EDI %ESI %SI %SIL>, %ESP<imp-use>, %EAX<imp-def> ; <— We were not recording that EAX was defined here (and not dead).
%vreg0<def> = MOV32rm %noreg, 1, %noreg, <ga:@c>[TF=18], %noreg; mem:LD4[GOT] GR32:%vreg0 ; <— As a result, we were using EAX here.
ADJCALLSTACKUP32 0, 0, %ESP<imp-def,dead>, %EFLAGS<imp-def,dead>, %ESP<imp-use>
%vreg1<def> = COPY %EAX; GR32:%vreg1 ; <— Regalloc was complaining that EAX is not defined and was reused.

I have a fix. I am polishing the test case and I’ll commit shortly.

Note: The reason why this did not bit us earlier is because the copy that used the return value is usually right after the call. In that case, this is one instruction farther.

@qcolombet
Copy link
Collaborator

Committed revision 261384.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla llvm:regalloc
Projects
None yet
Development

No branches or pull requests

2 participants