Skip to content

Commit 0f08b59

Browse files
committed
[GVN] Handle empty attrs in Expression ==
Change-Id: I75e876452af701191d36331703654581c6eb46f2
1 parent 5dd9867 commit 0f08b59

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-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: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2+
; RUN: opt -S -passes=gvn < %s | FileCheck %s
3+
4+
declare i32 @bar() #0
5+
6+
define i32 @foo() {
7+
; CHECK-LABEL: define i32 @foo() {
8+
; CHECK-NEXT: [[ENTRY:.*:]]
9+
; CHECK-NEXT: [[TMP0:%.*]] = tail call i32 @bar() #[[ATTR1:[0-9]+]]
10+
; CHECK-NEXT: [[TMP1:%.*]] = tail call i32 @bar()
11+
; CHECK-NEXT: ret i32 1
12+
;
13+
entry:
14+
%0 = tail call i32 @bar() #1
15+
%1 = tail call i32 @bar()
16+
ret i32 1
17+
}
18+
19+
20+
attributes #0 = { memory(none) }
21+
attributes #1 = { "llvm.assume"="ompx_no_call_asm" }

0 commit comments

Comments
 (0)