[PATCH] D143129: [GVN] Restrict equality propagation for pointers

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 4 07:17:45 PDT 2023


nikic requested changes to this revision.
nikic added inline comments.
This revision now requires changes to proceed.


================
Comment at: llvm/lib/Analysis/Loads.cpp:729
+bool llvm::canReplacePointersInAllUsesIfEqual(const Value *From,
+                                              const Value *To) {
+  // Not a pointer, just return true.
----------------
This API should not contain any Use-based reasoning, it should be just the isPointerAlwaysReplacable() part. The leader table replacement isn't valid even if all uses of this particular pointer are fine, as we may end up performing an indirect replacement on additional users.


================
Comment at: llvm/test/Transforms/GVN/assume-equal.ll:24
   
-  ; CHECK: call i32 @_ZN1A3fooEv(
+  ; CHECK: call i32 %0(
   %call2 = tail call i32 %0(ptr %call) #1
----------------
Hm, these regressions look problematic. These assumptions are emitted by clang in EmitVTableAssumptionLoad() specifically to allow these replacements. This is going to lose devirtualization support for these cases.

We probably need to carve out another exception for this case. Possibly we should just keep the existing exception for constants (i.e. allow if they are deferencable) to make this work.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143129/new/

https://reviews.llvm.org/D143129



More information about the llvm-commits mailing list