[PATCH] D44802: Add the ShadowCallStack pass

Vlad Tsyrklevich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 28 16:45:21 PDT 2018


vlad.tsyrklevich added inline comments.


================
Comment at: lib/Target/X86/ShadowCallStack.cpp:95
+  if (MBB->empty())
+    Noop = BuildMI(MBB, DL, TII->get(X86::NOOP));
+
----------------
pcc wrote:
> vlad.tsyrklevich wrote:
> > eugenis wrote:
> > > AFAIK you can do it without a dummy instruction by using the iterator form of BuildMI and passing MBB->end() or MBB->begin() in case of the empty basic block.
> > You could use the MBB->begin() form and insert them backwards, but for the sake of readability I insert them forwards.
> I would imagine that you could save the result of `MBB->begin()` and use that to insert instructions forwards, as it should always refer to what used to be the first instruction. Does that not work?
Sorry, let me be more clear. BuildMI() has two forms: one to add to the end of an MBB and one to add before a given instruction in the MBB. That means that for an empty MBB we can't insert instructions in forwards order without inserting a fake instruction to insert behind or using two different forms to insert the same instructions (one inserting behind the first instruction and the other always using the add-to-the-end form.)


Repository:
  rL LLVM

https://reviews.llvm.org/D44802





More information about the llvm-commits mailing list