Skip to content

Commit be29612

Browse files
authored
[NewGVN] Remove returned arg simplification (#161865)
Replacing uses of the return value with the argument is already handled in other passes, additionally it causes issues with memory value numbering when the call is a memory defining intrinsic. fixes #159918
1 parent 178e2a7 commit be29612

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

llvm/lib/Transforms/Scalar/NewGVN.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,10 +1646,6 @@ NewGVN::performSymbolicPredicateInfoEvaluation(BitCastInst *I) const {
16461646
// Evaluate read only and pure calls, and create an expression result.
16471647
NewGVN::ExprResult NewGVN::performSymbolicCallEvaluation(Instruction *I) const {
16481648
auto *CI = cast<CallInst>(I);
1649-
if (auto *II = dyn_cast<IntrinsicInst>(I)) {
1650-
if (auto *ReturnedValue = II->getReturnedArgOperand())
1651-
return ExprResult::some(createVariableOrConstant(ReturnedValue));
1652-
}
16531649

16541650
// FIXME: Currently the calls which may access the thread id may
16551651
// be considered as not accessing the memory. But this is
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 6
2+
; RUN: opt -S -passes=newgvn < %s | FileCheck %s
3+
4+
; Don't use returned argument in memory defining intrinsics.
5+
define void @wombat(ptr %arg) {
6+
; CHECK-LABEL: define void @wombat(
7+
; CHECK-SAME: ptr [[ARG:%.*]]) {
8+
; CHECK-NEXT: [[LOAD:%.*]] = load ptr, ptr [[ARG]], align 8
9+
; CHECK-NEXT: [[CALL:%.*]] = call ptr @llvm.objc.retain(ptr [[LOAD]])
10+
; CHECK-NEXT: store ptr [[CALL]], ptr [[ARG]], align 8
11+
; CHECK-NEXT: ret void
12+
;
13+
%load = load ptr, ptr %arg, align 8
14+
%call = call ptr @llvm.objc.retain(ptr %load)
15+
store ptr %call, ptr %arg, align 8
16+
ret void
17+
}
18+
19+
declare ptr @llvm.objc.retain(ptr returned) #0
20+
21+
attributes #0 = { nounwind }

0 commit comments

Comments
 (0)