[PATCH] D83595: [Draft][MSAN] Optimize away poisoning allocas that are always written before load

Evgenii Stepanov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 10 18:16:25 PDT 2020


eugenis added a comment.

In D83595#2145447 <https://reviews.llvm.org/D83595#2145447>, @guiand wrote:

> I figured if it's using GEP then it's likely not going to be storing to the entire shadow. Bitcast is overwhelmingly common though (especially bitcast->lifetime.start, which I realize I need to handle).


Right. From what I've seen, small aggregates on stack are quite common as well, and they are always initialized piecemeal. This can be seen as an improvement of this change, but it would be a pretty bit change to the algorithm, so consider including that from the start.

In D83595#2145347 <https://reviews.llvm.org/D83595#2145347>, @lebedev.ri wrote:

> Perhaps MemSSA-based DCE can be taught about it?


That's an option, but it could be harder to pull off when poisoning is outlined. The code will look something like this:

  %p = alloca i32
  call __msan_poison_and_set_origin(%p, 4)
  ...
  %s_p = inttoptr(xor(ptrtoint(%p), 0x50..00)))  ; shadow address for %p
  store i32 zeroinitializer, %s_p
  store i32 <value>, %p

To eliminate the dead call to __msan_poison, DCE would need to know the shadow mapping.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D83595/new/

https://reviews.llvm.org/D83595





More information about the llvm-commits mailing list