[llvm] [InferAddressSpaces] Fix constant replace to avoid modifying other functions (PR #70611)
Wenju He via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 30 00:41:48 PDT 2023
================
@@ -0,0 +1,40 @@
+; RUN: opt -assume-default-is-flat-addrspace -print-module-scope -print-after-all -S -disable-output -passes=infer-address-spaces <%s 2>&1 | FileCheck %s
+
+; CHECK: IR Dump After InferAddressSpacesPass on f2
+
+; Check that after running infer-address-spaces on f2, the redundant addrspace cast %x1 in f2 is gone.
+; CHECK-LABEL: define spir_func void @f2()
+; CHECK: [[X:%.*]] = addrspacecast ptr addrspace(1) @x to ptr
+; CHECK-NEXT: call spir_func void @f1(ptr noundef [[X]])
+
+; But it should not affect f3.
+; CHECK-LABEL: define spir_func void @f3()
+; CHECK: %x1 = addrspacecast ptr addrspacecast (ptr addrspace(1) @x to ptr) to ptr addrspace(1)
+; CHECK-NEXT: %x2 = addrspacecast ptr addrspace(1) %x1 to ptr
+; CHECK-NEXT: call spir_func void @f1(ptr noundef %x2)
+
+; Ensure that the pass hasn't run on f3 yet.
+; CHECK: IR Dump After InferAddressSpacesPass on f3
----------------
wenju-he wrote:
yes, adding optnone to f3 works. Thank you for the suggestion.
https://github.com/llvm/llvm-project/pull/70611
More information about the llvm-commits
mailing list