mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
[MergeFunctions] fix function attribute comparison in FunctionComparator
The comparison of AttributeSets stopped after seeing a matching type attribute. Subsequent mismatching attributes were not detected causing a crash.
This commit is contained in:
parent
56b649d72d
commit
5d0b348cd7
@ -124,12 +124,17 @@ int FunctionComparator::cmpAttrs(const AttributeList L,
|
|||||||
|
|
||||||
Type *TyL = LA.getValueAsType();
|
Type *TyL = LA.getValueAsType();
|
||||||
Type *TyR = RA.getValueAsType();
|
Type *TyR = RA.getValueAsType();
|
||||||
if (TyL && TyR)
|
if (TyL && TyR) {
|
||||||
return cmpTypes(TyL, TyR);
|
if (int Res = cmpTypes(TyL, TyR))
|
||||||
|
return Res;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Two pointers, at least one null, so the comparison result is
|
// Two pointers, at least one null, so the comparison result is
|
||||||
// independent of the value of a real pointer.
|
// independent of the value of a real pointer.
|
||||||
return cmpNumbers((uint64_t)TyL, (uint64_t)TyR);
|
if (int Res = cmpNumbers((uint64_t)TyL, (uint64_t)TyR))
|
||||||
|
return Res;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
if (LA < RA)
|
if (LA < RA)
|
||||||
return -1;
|
return -1;
|
||||||
|
21
test/Transforms/MergeFunc/mismatching-attr-crash.ll
Normal file
21
test/Transforms/MergeFunc/mismatching-attr-crash.ll
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
; RUN: opt -S -mergefunc %s | FileCheck %s
|
||||||
|
|
||||||
|
; CHECK-LABEL: define void @foo
|
||||||
|
; CHECK: call void %bc
|
||||||
|
define void @foo(i8* byval %a0, i8* swiftself %a4) {
|
||||||
|
entry:
|
||||||
|
%bc = bitcast i8* %a0 to void (i8*, i8*)*
|
||||||
|
call void %bc(i8* byval %a0, i8* swiftself %a4)
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
; CHECK-LABEL: define void @bar
|
||||||
|
; CHECK: call void %bc
|
||||||
|
define void @bar(i8* byval(i8) %a0, i8** swifterror %a4) {
|
||||||
|
entry:
|
||||||
|
%bc = bitcast i8* %a0 to void (i8*, i8**)*
|
||||||
|
call void %bc(i8* byval(i8) %a0, i8** swifterror %a4)
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user