1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00
llvm-mirror/test/Transforms/MergeFunc/merge-weak-crash.ll
Erik Eckstein 53b2b8eb9b Fix a crash in MergeFunctions related to ordering of weak/strong functions
The assumption, made in insert() that weak functions are always inserted after strong functions,
is only true in the first round of adding functions.
In subsequent rounds this is no longer guaranteed , because we might remove a strong function from the tree (because it's modified) and add it later,
where an equivalent weak function already exists in the tree.
This change removes the assert in insert() and explicitly enforces a weak->strong order.
This also removes the need of two separate loops in runOnModule().

llvm-svn: 271299
2016-05-31 17:20:23 +00:00

48 lines
1009 B
LLVM

; RUN: opt -S -mergefunc < %s | FileCheck %s
; CHECK-LABEL: define i32 @func1
; CHECK: call i32 @func2
; CHECK: ret
; CHECK-LABEL: define i32 @func2
; CHECK: call i32 @unknown
; CHECK: ret
; CHECK-LABEL: define i32 @func4
; CHECK: call i32 @func2
; CHECK: ret
; CHECK-LABEL: define weak i32 @func3_weak
; CHECK: call i32 @func1
; CHECK: ret
define i32 @func1(i32 %x, i32 %y) {
%sum = add i32 %x, %y
%sum2 = add i32 %sum, %y
%sum3 = call i32 @func4(i32 %sum, i32 %sum2)
ret i32 %sum3
}
define i32 @func4(i32 %x, i32 %y) {
%sum = add i32 %x, %y
%sum2 = add i32 %sum, %y
%sum3 = call i32 @unknown(i32 %sum, i32 %sum2)
ret i32 %sum3
}
define weak i32 @func3_weak(i32 %x, i32 %y) {
%sum = add i32 %x, %y
%sum2 = add i32 %sum, %y
%sum3 = call i32 @func2(i32 %sum, i32 %sum2)
ret i32 %sum3
}
define i32 @func2(i32 %x, i32 %y) {
%sum = add i32 %x, %y
%sum2 = add i32 %sum, %y
%sum3 = call i32 @unknown(i32 %sum, i32 %sum2)
ret i32 %sum3
}
declare i32 @unknown(i32 %x, i32 %y)