[PATCH] D111277: [SCCP] Properly report changes when changing a pointer argument

Arthur Eubanks via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 6 14:44:59 PDT 2021


aeubanks created this revision.
aeubanks added reviewers: mtrofin, asbirlea.
Herald added a subscriber: hiraditya.
aeubanks requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Fixes one of the issues in PR51946.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111277

Files:
  llvm/lib/Transforms/Scalar/SCCP.cpp
  llvm/test/Transforms/SCCP/report-changed.ll


Index: llvm/test/Transforms/SCCP/report-changed.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/SCCP/report-changed.ll
@@ -0,0 +1,34 @@
+; RUN: opt -passes='cgscc(no-op-cgscc),ipsccp,cgscc(function(sroa))' -disable-output < %s 2>&1 -debug-pass-manager | FileCheck %s
+
+; CHECK: Invalidating {{.*}} LazyCallGraph
+
+define i16 @main() {
+entry:
+  %call10 = call i16 @test_local_fp3(i16 undef)
+  ret i16 0
+}
+
+declare i16 (i16, i16)* @add_fp2()
+
+define internal i16 (i16, i16)* ()* @add_fp3() {
+entry:
+  ret i16 (i16, i16)* ()* @add_fp2
+}
+
+define internal i16 @test_local_fp3(i16 %tnr) {
+entry:
+  %tnr.addr = alloca i16, align 1
+  %call10 = call i16 @apply_fp3_local(i16 (i16, i16)* ()* ()* @add_fp3, i16 181, i16 16384)
+  %0 = load i16, i16* %tnr.addr, align 1
+  ret i16 %0
+}
+
+define internal i16 @apply_fp3_local(i16 (i16, i16)* ()* ()* %fp, i16 %p1, i16 %p2) {
+entry:
+  %fp.addr = alloca i16 (i16, i16)* ()* ()*, align 1
+  store i16 (i16, i16)* ()* ()* %fp, i16 (i16, i16)* ()* ()** %fp.addr, align 1
+  %0 = load i16 (i16, i16)* ()* ()*, i16 (i16, i16)* ()* ()** %fp.addr, align 1
+  %call = call i16 (i16, i16)* ()* %0()
+  %call2 = call i16 undef(i16 undef, i16 undef)
+  ret i16 %call2
+}
Index: llvm/lib/Transforms/Scalar/SCCP.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/SCCP.cpp
+++ llvm/lib/Transforms/Scalar/SCCP.cpp
@@ -500,6 +500,7 @@
           CB->removeFnAttrs(AttributesToRemove);
         }
       }
+      MadeChanges |= ReplacedPointerArg;
     }
 
     SmallPtrSet<Value *, 32> InsertedValues;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111277.377696.patch
Type: text/x-patch
Size: 1657 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211006/2c66aac0/attachment.bin>


More information about the llvm-commits mailing list