[PATCH] D90929: [MergeFunctions] fix function attribute comparison in FunctionComparator
Erik Eckstein via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 6 05:11:53 PST 2020
eeckstein created this revision.
eeckstein added a reviewer: t.p.northover.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
eeckstein requested review of this revision.
The comparison of AttributeSets stopped after seeing a matching type attribute.
Subsequent mismatching attributes were not detected.
This caused a crash in the swift compiler in case one of the AttributeSet contained a swifterror attribute (after the matching type attribute).
rdar://problem/70573980
https://reviews.llvm.org/D90929
Files:
llvm/lib/Transforms/Utils/FunctionComparator.cpp
llvm/test/Transforms/MergeFunc/mismatching-attr-crash.ll
Index: llvm/test/Transforms/MergeFunc/mismatching-attr-crash.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/MergeFunc/mismatching-attr-crash.ll
@@ -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
+}
+
+
Index: llvm/lib/Transforms/Utils/FunctionComparator.cpp
===================================================================
--- llvm/lib/Transforms/Utils/FunctionComparator.cpp
+++ llvm/lib/Transforms/Utils/FunctionComparator.cpp
@@ -124,12 +124,17 @@
Type *TyL = LA.getValueAsType();
Type *TyR = RA.getValueAsType();
- if (TyL && TyR)
- return cmpTypes(TyL, TyR);
+ if (TyL && TyR) {
+ if (int Res = cmpTypes(TyL, TyR))
+ return Res;
+ continue;
+ }
// Two pointers, at least one null, so the comparison result is
// 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)
return -1;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90929.303408.patch
Type: text/x-patch
Size: 1624 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201106/8960ab04/attachment.bin>
More information about the llvm-commits
mailing list