[PATCH] D105616: [llvm-diff] Check for recursive initialiers

Bill Wendling via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 8 02:11:10 PDT 2021


void created this revision.
void added reviewers: rjmccall, dexonsmith, arsenm.
void requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

We need to check for recursive initializers in the "ConstantStruct"
case.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D105616

Files:
  llvm/test/tools/llvm-diff/initializers.ll
  llvm/tools/llvm-diff/DifferenceEngine.cpp


Index: llvm/tools/llvm-diff/DifferenceEngine.cpp
===================================================================
--- llvm/tools/llvm-diff/DifferenceEngine.cpp
+++ llvm/tools/llvm-diff/DifferenceEngine.cpp
@@ -490,6 +490,16 @@
         const Value *LAgg = CSL->getAggregateElement(I);
         const Value *RAgg = CSR->getAggregateElement(I);
 
+        if (LAgg == SavedLHS || RAgg == SavedRHS) {
+          if (LAgg != SavedLHS || RAgg != SavedRHS)
+            // If the left and right operands aren't both re-analyzing the
+            // variable, then the initialiers don't match, so report "false".
+            // Otherwise, we skip these operands..
+            return false;
+
+          continue;
+        }
+
         if (!equivalentAsOperands(LAgg, RAgg)) {
           return false;
         }
Index: llvm/test/tools/llvm-diff/initializers.ll
===================================================================
--- llvm/test/tools/llvm-diff/initializers.ll
+++ llvm/test/tools/llvm-diff/initializers.ll
@@ -36,3 +36,12 @@
   call void undef(%struct.mutex* @vmx_l1d_flush_mutex)
   ret i32 undef
 }
+
+; An initializer could use itself as part of the initialization.
+
+ at kvm_debugfs_entries = internal global %struct.list_head { %struct.list_head* @kvm_debugfs_entries, %struct.list_head* @kvm_debugfs_entries }, align 8
+
+define i64 @mux() {
+  %1 = load i8*, i8** bitcast (%struct.list_head* @kvm_debugfs_entries to i8**), align 8
+  ret i64 undef
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D105616.357168.patch
Type: text/x-patch
Size: 1469 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210708/8f0efda5/attachment.bin>


More information about the llvm-commits mailing list