[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 18:25:21 PDT 2023


================
@@ -375,9 +375,35 @@ bool MergeFunctions::doFunctionalCheck(std::vector<WeakTrackingVH> &Worklist) {
 }
 #endif
 
+/// Check whether \p F has an intrinsic which references
+/// distinct metadata as an operand. The most common
+/// instance of this would be CFI checks for function-local types.
+static bool hasDistinctMetadataIntrinsic(const Function &F) {
+  for (const BasicBlock &BB : F) {
+    for (const Instruction &I : BB.instructionsWithoutDebug()) {
+      if (!isa<IntrinsicInst>(&I))
+        continue;
+
+      for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i) {
+        MetadataAsValue *MDL = dyn_cast<MetadataAsValue>(I.getOperand(i));
+        if (!MDL)
+          continue;
+        MDNode *node = dyn_cast<MDNode>(MDL->getMetadata());
----------------
dexonsmith wrote:

Nit: naming style should be `Node` or `N` here.

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


More information about the llvm-commits mailing list