Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 63bcfe3

Browse files
committed
Merging r331990:
------------------------------------------------------------------------ r331990 | whitequark | 2018-05-10 08:05:47 -0700 (Thu, 10 May 2018) | 15 lines [PR37339] Fix assertion in FunctionComparator::cmpInlineAsm Fixes bug https://bugs.llvm.org/show_bug.cgi?id=37339. InlineAsm is only uniqued if the FunctionTypes are exactly the same, while cmpTypes() for example considers all pointer types in the default address space to be the same. For this reason the end of cmpInlineAsm() can be reached. This patch replaces the unreachable assertion with a check that the function types are not identical. Differential Revision: https://reviews.llvm.org/D46495 Reviewers: jfb ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_60@332678 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent be07815 commit 63bcfe3

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

lib/Transforms/Utils/FunctionComparator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ int FunctionComparator::cmpInlineAsm(const InlineAsm *L,
710710
return Res;
711711
if (int Res = cmpNumbers(L->getDialect(), R->getDialect()))
712712
return Res;
713-
llvm_unreachable("InlineAsm blocks were not uniqued.");
713+
assert(L->getFunctionType() != R->getFunctionType());
714714
return 0;
715715
}
716716

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
; RUN: opt -mergefunc -S < %s | FileCheck %s
2+
3+
; CHECK-LABEL: @int_ptr_arg_different
4+
; CHECK-NEXT: call void asm
5+
6+
; CHECK-LABEL: @int_ptr_arg_same
7+
; CHECK-NEXT: %2 = bitcast i32* %0 to float*
8+
; CHECK-NEXT: tail call void @float_ptr_arg_same(float* %2)
9+
10+
; CHECK-LABEL: @int_ptr_null
11+
; CHECK-NEXT: tail call void @float_ptr_null()
12+
13+
; Used to satisfy minimum size limit
14+
declare void @stuff()
15+
16+
; Can be merged
17+
define void @float_ptr_null() {
18+
call void asm "nop", "r"(float* null)
19+
call void @stuff()
20+
ret void
21+
}
22+
23+
define void @int_ptr_null() {
24+
call void asm "nop", "r"(i32* null)
25+
call void @stuff()
26+
ret void
27+
}
28+
29+
; Can be merged (uses same argument differing by pointer type)
30+
define void @float_ptr_arg_same(float*) {
31+
call void asm "nop", "r"(float* %0)
32+
call void @stuff()
33+
ret void
34+
}
35+
36+
define void @int_ptr_arg_same(i32*) {
37+
call void asm "nop", "r"(i32* %0)
38+
call void @stuff()
39+
ret void
40+
}
41+
42+
; Can not be merged (uses different arguments)
43+
define void @float_ptr_arg_different(float*, float*) {
44+
call void asm "nop", "r"(float* %0)
45+
call void @stuff()
46+
ret void
47+
}
48+
49+
define void @int_ptr_arg_different(i32*, i32*) {
50+
call void asm "nop", "r"(i32* %1)
51+
call void @stuff()
52+
ret void
53+
}

0 commit comments

Comments
 (0)