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 | ||
---|---|---|
72 | Hi! Fang rui, Nice to see you here! bool X86IndirectBranchTrackingPass::addENDBR(MachineBasicBlock &MBB, MachineBasicBlock::iterator I) const { | |
78 | It seems same with ++I ? More performance ? | |
139 | I used iterator I, because I want to pass I into BuildMI in addENDBR() |
lib/Target/X86/X86IndirectBranchTracking.cpp | ||
---|---|---|
72 | 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 { | |
78 |
lib/Target/X86/X86IndirectBranchTracking.cpp | ||
---|---|---|
76–84 | 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 | 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 | ||
10 | funtion->function | |
70 | Please reduce this to only the attributes necessary. target-cpu, no-trapping-math, etc. are all unnecessary. |
lib/Target/X86/X86IndirectBranchTracking.cpp | ||
---|---|---|
76–84 | Here we just want to use a special "value" to let the addENDBR() ignore the argument "I". | |
141 | Yes! make sense! | |
test/CodeGen/X86/indirect-branch-tracking-r2.ll | ||
10 | Yes! | |
70 | OK! I'll simply them. Thank you! |
lib/Target/X86/X86IndirectBranchTracking.cpp | ||
---|---|---|
144 | 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 | 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 | Hi Craig, we can not avoid. one case is insert endbr after I |
lib/Target/X86/X86IndirectBranchTracking.cpp | ||
---|---|---|
144 | Sorry, I miss understand before. Your suggestion is right! |
indent with clang-format.