From: Sami Tolvanen Date: Fri, 18 Nov 2022 21:23:04 +0000 (+0000) Subject: [X86][KCFI] Don't fold loads into indirect calls that need a KCFI check X-Git-Tag: upstream/17.0.6~27148 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7c96f61aaa4c8297e5cd1b96c6985f491e5f034f;p=platform%2Fupstream%2Fllvm.git [X86][KCFI] Don't fold loads into indirect calls that need a KCFI check Avoid unnecessary folding as X86KCFIPass would have to unfold these anyway when emitting the KCFI_CHECK. --- diff --git a/llvm/lib/Target/X86/X86InstrInfo.cpp b/llvm/lib/Target/X86/X86InstrInfo.cpp index 51fb860..86dc8f9 100644 --- a/llvm/lib/Target/X86/X86InstrInfo.cpp +++ b/llvm/lib/Target/X86/X86InstrInfo.cpp @@ -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.