[llvm] Fix: Distinguish CFI Metadata Checks in MergeFunctions Pass (PR #65963)

Duncan P. N. Exon Smith via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 21 17:39:57 PDT 2023


================
@@ -375,9 +375,35 @@ bool MergeFunctions::doFunctionalCheck(std::vector<WeakTrackingVH> &Worklist) {
 }
 #endif
 
+// This function iterates over two functions and compares their
+// metadata to make sure we aren't merging functions which have
+// distinct metadata that is different. We don't care about
+// debug data here, it shouldn't change MIR like CFI would.
+static bool hasDistinctMetadataIntrinsic(const Function &F) {
+  for (const BasicBlock &BB : F) {
+    for (const Instruction &I : BB.instructionsWithoutDebug()) {
+      if (!isa<IntrinsicInst>(&I))
+        continue; // Only intrinsics can reference metadata.
+
+      // Iterate through operands, and return true if you find a distinct
+      // metadata operand.
+      for (unsigned i = 0, e = I.getNumOperands(); i != e;
+           ++i) { // Replaced InstLIt with I
+        MetadataAsValue *MDL = dyn_cast<MetadataAsValue>(
+            I.getOperand(i)); // Replaced InstLIt with I
----------------
dexonsmith wrote:

Should those functions be declared `internal` to be candidates for merging?

https://github.com/llvm/llvm-project/pull/65963


More information about the llvm-commits mailing list