[PATCH] D111108: [X86] Fix fentry handling in X86IndirectBranchTracking.cpp
Phoebe Wang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 6 20:10:12 PST 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdfcf69770bc5: [X86] Fix fentry handling in X86IndirectBranchTracking.cpp (authored by joaomoreira, committed by pengfei).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D111108/new/
https://reviews.llvm.org/D111108
Files:
llvm/lib/Target/X86/X86IndirectBranchTracking.cpp
llvm/test/CodeGen/X86/fentry-ibt.ll
Index: llvm/test/CodeGen/X86/fentry-ibt.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/X86/fentry-ibt.ll
@@ -0,0 +1,17 @@
+; RUN: llc %s -o - -verify-machineinstrs | FileCheck %s
+
+define void @test1() #0 {
+entry:
+ ret void
+
+; CHECK-LABEL: @test1
+; CHECK: endbr64
+; CHECK: callq __fentry__
+; CHECK-NOT: mcount
+; CHECK: retq
+}
+
+!llvm.module.flags = !{!0}
+
+attributes #0 = { "fentry-call"="true" }
+!0 = !{i32 4, !"cf-protection-branch", i32 1}
Index: llvm/lib/Target/X86/X86IndirectBranchTracking.cpp
===================================================================
--- llvm/lib/Target/X86/X86IndirectBranchTracking.cpp
+++ llvm/lib/Target/X86/X86IndirectBranchTracking.cpp
@@ -137,8 +137,10 @@
Changed |= addENDBR(MBB, MBB.begin());
for (MachineBasicBlock::iterator I = MBB.begin(); I != MBB.end(); ++I) {
- if (I->isCall() && IsCallReturnTwice(I->getOperand(0)))
+ if (I->isCall() && I->getNumOperands() > 0 &&
+ IsCallReturnTwice(I->getOperand(0))) {
Changed |= addENDBR(MBB, std::next(I));
+ }
}
// Exception handle may indirectly jump to catch pad, So we should add
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111108.392270.patch
Type: text/x-patch
Size: 1207 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211207/6219b736/attachment-0001.bin>
More information about the llvm-commits
mailing list