LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 26485 - [REGRESSION] UNREACHABLE executed at lib/CodeGen/RegAllocFast.cpp:361!
Summary: [REGRESSION] UNREACHABLE executed at lib/CodeGen/RegAllocFast.cpp:361!
Status: RESOLVED FIXED
Alias: None
Product: libraries
Classification: Unclassified
Component: Register Allocator (show other bugs)
Version: 3.8
Hardware: PC All
: P normal
Assignee: Unassigned LLVM Bugs
URL:
Keywords:
Depends on:
Blocks: 26059
  Show dependency tree
 
Reported: 2016-02-04 22:38 PST by Saleem Abdulrasool
Modified: 2016-02-19 18:32 PST (History)
3 users (show)

See Also:
Fixed By Commit(s):


Attachments
reduced.c (122 bytes, application/octet-stream)
2016-02-04 22:38 PST, Saleem Abdulrasool
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Saleem Abdulrasool 2016-02-04 22:38:58 PST
Created attachment 15829 [details]
reduced.c

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.
Comment 1 Quentin Colombet 2016-02-19 13:41:54 PST
I’ll have a look.
Thanks for the report!
Comment 2 Quentin Colombet 2016-02-19 17:42:42 PST
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.
Comment 3 Quentin Colombet 2016-02-19 18:32:45 PST
Committed revision 261384.