[X86][KCFI] Don't fold loads into indirect calls that need a KCFI check
authorSami Tolvanen <samitolvanen@google.com>
Fri, 18 Nov 2022 21:23:04 +0000 (21:23 +0000)
committerSami Tolvanen <samitolvanen@google.com>
Fri, 18 Nov 2022 21:55:41 +0000 (21:55 +0000)
Avoid unnecessary folding as X86KCFIPass would have to unfold these
anyway when emitting the KCFI_CHECK.

llvm/lib/Target/X86/X86InstrInfo.cpp

index 51fb860..86dc8f9 100644 (file)
@@ -6135,6 +6135,11 @@ MachineInstr *X86InstrInfo::foldMemoryOperandImpl(
       MI.getOpcode() != X86::ADD64rr)
     return nullptr;
 
+  // Don't fold loads into indirect calls that need a KCFI check as we'll
+  // have to unfold these in X86KCFIPass anyway.
+  if (MI.isCall() && MI.getCFIType())
+    return nullptr;
+
   MachineInstr *NewMI = nullptr;
 
   // Attempt to fold any custom cases we have.