Skip to content

Commit 565d70e

Browse files
committed
[GVN] Handle empty attrs in Expression ==
1 parent a2f9d1d commit 565d70e

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

llvm/lib/Transforms/Scalar/GVN.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ struct llvm::GVNPass::Expression {
156156
return false;
157157
if (varargs != other.varargs)
158158
return false;
159-
if (!attrs.isEmpty() && !other.attrs.isEmpty() &&
159+
if ((!attrs.isEmpty() || !other.attrs.isEmpty()) &&
160160
!attrs.intersectWith(type->getContext(), other.attrs).has_value())
161161
return false;
162162
return true;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
; RUN: opt -S -passes=gvn < %s | FileCheck %s
2+
3+
declare i32 @bar() #0
4+
5+
define i32 @foo() {
6+
entry:
7+
%0 = tail call i32 @bar() #1
8+
%1 = tail call i32 @bar()
9+
ret i32 1
10+
}
11+
12+
; CHECK-LABEL: define i32 @foo(
13+
; CHECK: %0 = tail call i32 @bar() #1
14+
; CHECK-NEXT: %1 = tail call i32 @bar()
15+
; CHECK-NEXT: ret i32 1
16+
; CHECK-NEXT: }
17+
18+
attributes #0 = { memory(none) }
19+
attributes #1 = { "llvm.assume"="ompx_no_call_asm" }

0 commit comments

Comments
 (0)