Return-twice functions will indirectly jump after the caller's position.
So when CET-IBT is enable, we should make sure these is endbr* instructions follow these Return-twice function caller. Like GCC does.
Details
- Reviewers
LuoYuanke craig.topper annita.zhang pengfei - Commits
- rZORGeffbbba6384f: [X86] [CET] Deal with return-twice function such as vfork, setjmp when CET-IBT…
rGeffbbba6384f: [X86] [CET] Deal with return-twice function such as vfork, setjmp when CET-IBT…
rG6a0d432e9e0f: [X86] [CET] Deal with return-twice function such as vfork, setjmp when CET-IBT…
rL361342: [X86] [CET] Deal with return-twice function such as vfork, setjmp when
Diff Detail
- Repository
- rL LLVM
Event Timeline
| lib/Target/X86/X86IndirectBranchTracking.cpp | ||
|---|---|---|
| 73 ↗ | (On Diff #199373) | Hi! Fang rui, Nice to see you here! bool
X86IndirectBranchTrackingPass::addENDBR(MachineBasicBlock &MBB,
MachineBasicBlock::iterator I) const { |
| 79 ↗ | (On Diff #199373) | It seems same with ++I ? More performance ? |
| 140 ↗ | (On Diff #199373) | I used iterator I, because I want to pass I into BuildMI in addENDBR() |
| lib/Target/X86/X86IndirectBranchTracking.cpp | ||
|---|---|---|
| 73 ↗ | (On Diff #199373) | You may use clang-format (git diff -U0 --no-color 'HEAD^' | ~/llvm/tools/clang/tools/clang-format/clang-format-diff.py -i -p1). It reformats this block as: bool X86IndirectBranchTrackingPass::addENDBR(
MachineBasicBlock &MBB, MachineBasicBlock::iterator I) const { |
| 79 ↗ | (On Diff #199373) | |
| lib/Target/X86/X86IndirectBranchTracking.cpp | ||
|---|---|---|
| 76 ↗ | (On Diff #199547) | Is this really "I != MBB.end()"? MachineBasicBlock::iterator is an iterator into a linked list and I'm not sure what it means for that to be nullptr. |
| 141 ↗ | (On Diff #199547) | Variable names should be capitalized and use camel case. But I think this variable is unnecessary and you could just call I->isCall from the if. |
| test/CodeGen/X86/indirect-branch-tracking-r2.ll | ||
| 9 ↗ | (On Diff #199547) | funtion->function |
| 69 ↗ | (On Diff #199547) | Please reduce this to only the attributes necessary. target-cpu, no-trapping-math, etc. are all unnecessary. |
| lib/Target/X86/X86IndirectBranchTracking.cpp | ||
|---|---|---|
| 76 ↗ | (On Diff #199547) | Here we just want to use a special "value" to let the addENDBR() ignore the argument "I". |
| 141 ↗ | (On Diff #199547) | Yes! make sense! |
| test/CodeGen/X86/indirect-branch-tracking-r2.ll | ||
| 9 ↗ | (On Diff #199547) | Yes! |
| 69 ↗ | (On Diff #199547) | OK! I'll simply them. Thank you! |
| lib/Target/X86/X86IndirectBranchTracking.cpp | ||
|---|---|---|
| 144 ↗ | (On Diff #199718) | What if we passed I++ here and passed MBB.begin() on the other callsites. Could we then avoid two different cases in addENDBR? |
| lib/Target/X86/X86IndirectBranchTracking.cpp | ||
|---|---|---|
| 139 ↗ | (On Diff #199718) | I find here line 139 maybe problem: for (MachineBasicBlock::iterator I = MBB.begin(); I != MBB.end(); //because the MBB may update by insert endbr. |
| 144 ↗ | (On Diff #199718) | Hi Craig, we can not avoid. one case is insert endbr after I |
| lib/Target/X86/X86IndirectBranchTracking.cpp | ||
|---|---|---|
| 144 ↗ | (On Diff #199718) | Sorry, I miss understand before. Your suggestion is right! |