aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormacurtis-amd <macurtis@amd.com>2024-11-12 09:08:06 -0600
committerGitHub <noreply@github.com>2024-11-12 09:08:06 -0600
commiteea8b44aaa3464f52dea1d56ca47e0519b08fd36 (patch)
tree3c19aa6ebbb048affb315375bf6f307f2e668899
parent71d4f343f52756ca086d02151662e68633a0db52 (diff)
downloadllvm-eea8b44aaa3464f52dea1d56ca47e0519b08fd36.zip
llvm-eea8b44aaa3464f52dea1d56ca47e0519b08fd36.tar.gz
llvm-eea8b44aaa3464f52dea1d56ca47e0519b08fd36.tar.bz2
[GVN] Handle empty attrs in Expression == (#115761)
-rw-r--r--llvm/lib/Transforms/Scalar/GVN.cpp2
-rw-r--r--llvm/test/Transforms/GVN/intersect-empty-attr.ll21
2 files changed, 22 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp
index e27f5a0..a3df7a0 100644
--- a/llvm/lib/Transforms/Scalar/GVN.cpp
+++ b/llvm/lib/Transforms/Scalar/GVN.cpp
@@ -156,7 +156,7 @@ struct llvm::GVNPass::Expression {
return false;
if (varargs != other.varargs)
return false;
- if (!attrs.isEmpty() && !other.attrs.isEmpty() &&
+ if ((!attrs.isEmpty() || !other.attrs.isEmpty()) &&
!attrs.intersectWith(type->getContext(), other.attrs).has_value())
return false;
return true;
diff --git a/llvm/test/Transforms/GVN/intersect-empty-attr.ll b/llvm/test/Transforms/GVN/intersect-empty-attr.ll
new file mode 100644
index 0000000..a2d719e
--- /dev/null
+++ b/llvm/test/Transforms/GVN/intersect-empty-attr.ll
@@ -0,0 +1,21 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
+; RUN: opt -S -passes=gvn < %s | FileCheck %s
+
+declare i32 @bar() #0
+
+define i32 @foo() {
+; CHECK-LABEL: define i32 @foo() {
+; CHECK-NEXT: [[ENTRY:.*:]]
+; CHECK-NEXT: [[TMP0:%.*]] = tail call i32 @bar() #[[ATTR1:[0-9]+]]
+; CHECK-NEXT: [[TMP1:%.*]] = tail call i32 @bar()
+; CHECK-NEXT: ret i32 1
+;
+entry:
+ %0 = tail call i32 @bar() #1
+ %1 = tail call i32 @bar()
+ ret i32 1
+}
+
+
+attributes #0 = { memory(none) }
+attributes #1 = { "llvm.assume"="ompx_no_call_asm" }