mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-05 13:26:55 +00:00
Fix a long standing tail call optimization bug. When a libcall is emitted
legalizer always use the DAG entry node. This is wrong when the libcall is emitted as a tail call since it effectively folds the return node. If the return node's input chain is not the entry (i.e. call, load, or store) use that as the tail call input chain. PR12419 rdar://9770785 rdar://11195178 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154370 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -138,3 +138,24 @@ declare i32 @a(i32)
|
||||
declare i32 @b(i32)
|
||||
|
||||
declare i32 @c(i32)
|
||||
|
||||
; PR12419
|
||||
; rdar://11195178
|
||||
; Use the correct input chain for the tailcall node or else the call to
|
||||
; _ZN9MutexLockD1Ev would be lost.
|
||||
%class.MutexLock = type { i8 }
|
||||
|
||||
@x = external global i32, align 4
|
||||
|
||||
define i32 @_Z5test1v() nounwind {
|
||||
%lock = alloca %class.MutexLock, align 1
|
||||
%1 = call %class.MutexLock* @_ZN9MutexLockC1Ev(%class.MutexLock* %lock)
|
||||
%2 = load i32* @x, align 4
|
||||
%3 = sdiv i32 1000, %2
|
||||
%4 = call %class.MutexLock* @_ZN9MutexLockD1Ev(%class.MutexLock* %lock)
|
||||
ret i32 %3
|
||||
}
|
||||
|
||||
declare %class.MutexLock* @_ZN9MutexLockC1Ev(%class.MutexLock*) unnamed_addr nounwind align 2
|
||||
|
||||
declare %class.MutexLock* @_ZN9MutexLockD1Ev(%class.MutexLock*) unnamed_addr nounwind align 2
|
||||
|
Reference in New Issue
Block a user