Clang: Add Diags for targets pre to i686 for -fcf-protection

Intel Control-flow Enforcement Technology (CET) provides new
instructions `endbr32/64` for the indirect branch control.
They are NOPs on i686 and new targets.  We need to check for that
in case it crashes on older targets.

PR:		264497
Reviewed by:	dim
MFC after:	1 week
Obtained from:	LLVM commit 52516782972730ff065a34123a9d8876da08c254
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D37268
This commit is contained in:
Ed Maste 2022-11-04 11:59:49 -04:00
parent 75217c2b47
commit 9c231325e7

View file

@ -223,12 +223,16 @@ class LLVM_LIBRARY_VISIBILITY X86TargetInfo : public TargetInfo {
virtual bool
checkCFProtectionReturnSupported(DiagnosticsEngine &Diags) const override {
return true;
if (CPU == llvm::X86::CK_None || CPU >= llvm::X86::CK_PentiumPro)
return true;
return TargetInfo::checkCFProtectionReturnSupported(Diags);
};
virtual bool
checkCFProtectionBranchSupported(DiagnosticsEngine &Diags) const override {
return true;
if (CPU == llvm::X86::CK_None || CPU >= llvm::X86::CK_PentiumPro)
return true;
return TargetInfo::checkCFProtectionBranchSupported(Diags);
};
virtual bool validateOperandSize(const llvm::StringMap<bool> &FeatureMap,