[PATCH] D41879: [X86] Added support for nocf_check attribute for indirect Branch Tracking

Oren Ben Simhon via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 29 07:39:37 PST 2018


oren_ben_simhon marked 3 inline comments as done.
oren_ben_simhon added a comment.

I will add "notrack" to X86 ASM Parser (and also add symbolic test)



================
Comment at: lib/Target/X86/X86IndirectBranchTracking.cpp:146
-  // Adds ENDBR instructions to MBB destinations of the jump table.
-  // TODO: In case of more than 50 destinations, do not add ENDBR and
-  // instead add DS_PREFIX.
----------------
craig.topper wrote:
> Is this TODO implemented by this patch? I didn't see anywhere that checks for the number of destination.
I decided to follow a better approach. I don't add ENDBR to guarded switch-case. Instead adds NOTRACK prefix when the switch-case is safe.

A safe/guarded switch-case is a an indirect branch that uses a jump table and does a range check before the branch. It usually happens in large switch-case statement.

So now, I change ISD::BRIND to ISD::NT_BRIND every time the branch originates from a jump table (ISD::BR_JT).
ISD::NT_BRIND will have no track prefix before it.

In case of jump tables, the target addresses of an indirect branch are not flagged as "address taken". So no ENDBR will be instrumented.



Repository:
  rL LLVM

https://reviews.llvm.org/D41879





More information about the llvm-commits mailing list