Skip to content

Commit 64c2312

Browse files
committed
Revert 43f031d "Enable IBT(Indirect Branch Tracking) in JIT with CET(Control-flow Enforcement Technology)"
ExecutionEngine/MCJIT/cet-code-model-lager.ll is failing on 32-bit windows, see llvm-commits thread for fef2dab. This reverts commit 43f031d and the follow-ups fef2dab and 6a800f6.
1 parent da5fe23 commit 64c2312

File tree

5 files changed

+8
-91
lines changed

5 files changed

+8
-91
lines changed

llvm/lib/Target/X86/X86IndirectBranchTracking.cpp

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include "X86.h"
1919
#include "X86InstrInfo.h"
2020
#include "X86Subtarget.h"
21-
#include "X86TargetMachine.h"
2221
#include "llvm/ADT/Statistic.h"
2322
#include "llvm/CodeGen/MachineFunctionPass.h"
2423
#include "llvm/CodeGen/MachineInstrBuilder.h"
@@ -103,16 +102,7 @@ bool X86IndirectBranchTrackingPass::runOnMachineFunction(MachineFunction &MF) {
103102
// Check that the cf-protection-branch is enabled.
104103
Metadata *isCFProtectionSupported =
105104
MF.getMMI().getModule()->getModuleFlag("cf-protection-branch");
106-
// NB: We need to enable IBT in jitted code if JIT compiler is CET
107-
// enabled.
108-
const X86TargetMachine *TM =
109-
static_cast<const X86TargetMachine *>(&MF.getTarget());
110-
#ifdef __CET__
111-
bool isJITwithCET = TM->isJIT();
112-
#else
113-
bool isJITwithCET = false;
114-
#endif
115-
if (!isCFProtectionSupported && !IndirectBranchTracking && !isJITwithCET)
105+
if (!isCFProtectionSupported && !IndirectBranchTracking)
116106
return false;
117107

118108
// True if the current MF was changed and false otherwise.
@@ -121,11 +111,10 @@ bool X86IndirectBranchTrackingPass::runOnMachineFunction(MachineFunction &MF) {
121111
TII = SubTarget.getInstrInfo();
122112
EndbrOpcode = SubTarget.is64Bit() ? X86::ENDBR64 : X86::ENDBR32;
123113

124-
// Large code model, non-internal function or function whose address
125-
// was taken, can be accessed through indirect calls. Mark the first
126-
// BB with ENDBR instruction unless nocf_check attribute is used.
127-
if ((TM->getCodeModel() == CodeModel::Large ||
128-
MF.getFunction().hasAddressTaken() ||
114+
// Non-internal function or function whose address was taken, can be
115+
// accessed through indirect calls. Mark the first BB with ENDBR instruction
116+
// unless nocf_check attribute is used.
117+
if ((MF.getFunction().hasAddressTaken() ||
129118
!MF.getFunction().hasLocalLinkage()) &&
130119
!MF.getFunction().doesNoCfCheck()) {
131120
auto MBB = MF.begin();
@@ -147,8 +136,8 @@ bool X86IndirectBranchTrackingPass::runOnMachineFunction(MachineFunction &MF) {
147136
Changed |= addENDBR(MBB, std::next(I));
148137

149138
if (EHPadIBTNeeded && I->isEHLabel()) {
150-
Changed |= addENDBR(MBB, std::next(I));
151-
EHPadIBTNeeded = false;
139+
Changed |= addENDBR(MBB, std::next(I));
140+
EHPadIBTNeeded = false;
152141
}
153142
}
154143
}

llvm/lib/Target/X86/X86TargetMachine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ X86TargetMachine::X86TargetMachine(const Target &T, const Triple &TT,
215215
getEffectiveRelocModel(TT, JIT, RM),
216216
getEffectiveX86CodeModel(CM, JIT, TT.getArch() == Triple::x86_64),
217217
OL),
218-
TLOF(createTLOF(getTargetTriple())), IsJIT(JIT) {
218+
TLOF(createTLOF(getTargetTriple())) {
219219
// On PS4, the "return address" of a 'noreturn' call must still be within
220220
// the calling function, and TrapUnreachable is an easy way to get that.
221221
if (TT.isPS4() || TT.isOSBinFormatMachO()) {

llvm/lib/Target/X86/X86TargetMachine.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ class TargetTransformInfo;
3030
class X86TargetMachine final : public LLVMTargetMachine {
3131
std::unique_ptr<TargetLoweringObjectFile> TLOF;
3232
mutable StringMap<std::unique_ptr<X86Subtarget>> SubtargetMap;
33-
// True if this is used in JIT.
34-
bool IsJIT;
3533

3634
public:
3735
X86TargetMachine(const Target &T, const Triple &TT, StringRef CPU,
@@ -54,8 +52,6 @@ class X86TargetMachine final : public LLVMTargetMachine {
5452
TargetLoweringObjectFile *getObjFileLowering() const override {
5553
return TLOF.get();
5654
}
57-
58-
bool isJIT() const { return IsJIT; }
5955
};
6056

6157
} // end namespace llvm

llvm/test/CodeGen/X86/indirect-branch-tracking-cm-lager.ll

Lines changed: 0 additions & 36 deletions
This file was deleted.

llvm/test/ExecutionEngine/MCJIT/cet-code-model-lager.ll

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)