if (llvm::all_of(F->uses(), [this](const Use &U) {
const auto *CB = dyn_cast<CallBase>(U.getUser());
return CB && CB->isCallee(&U) &&
- !A.isRunOn(const_cast<Function *>(CB->getCaller()));
+ A.isRunOn(const_cast<Function *>(CB->getCaller()));
}))
continue;
}
--- /dev/null
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt -S -passes=openmp-opt-cgscc < %s | FileCheck %s
+
+; Verify we remove the trivially dead store in a function that is not dead
+; (foo) but not in a dead function (dead) when running in cgscc mode.
+
+define internal void @dead() {
+; CHECK-LABEL: @dead(
+; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
+; CHECK-NEXT: store i32 0, ptr [[A]], align 4
+; CHECK-NEXT: ret void
+;
+ %a = alloca i32
+ store i32 0, ptr %a
+ ret void
+}
+
+define internal void @foo() {
+; CHECK-LABEL: @foo(
+; CHECK-NEXT: [[A:%.*]] = alloca i32, align 4
+; CHECK-NEXT: ret void
+;
+ %a = alloca i32
+ store i32 0, ptr %a
+ ret void
+}
+
+define internal void @bar() {
+; CHECK-LABEL: @bar(
+; CHECK-NEXT: call void @foo()
+; CHECK-NEXT: ret void
+;
+ call void @foo()
+ ret void
+}
+
+define void @baz() {
+; CHECK-LABEL: @baz(
+; CHECK-NEXT: call void @bar()
+; CHECK-NEXT: ret void
+;
+ call void @bar()
+ ret void
+}
+
+!llvm.module.flags = !{!0, !1}
+
+!0 = !{i32 7, !"openmp", i32 50}
+!1 = !{i32 7, !"openmp-device", i32 50}