[PATCH] D83595: [Draft][MSAN] Optimize away poisoning allocas that are always written before load
Gui Andrade via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 31 17:42:54 PDT 2020
guiand added a comment.
It seems like `collectInitializers` leans heavily on the `isPointerOffset` function, which returns an offset if two pointers have a constant difference, `nullopt` if they don't. The problem here is that we can't distinguish `isPointerOffset == nullopt` happening because the offset is determined at runtime, or because the two pointers are completely unrelated.
It's a pretty big difference, because we don't want to poison a sequence like this:
%x = alloca [ i32, i32 }
%y = alloca i32
%z = load i32, i32* %y ; isPointerOffset == false
%x0 = getelementptr { i32, i32 }, { i32, i32 }* %x, i32 0, i32 0
%x1 = getelementptr { i32, i32 }, { i32, i32 }* %x, i32 0, i32 1
store i32 0, i32* %x0
store i32 0, i32* %x1
But we want to poison a sequence like this:
%x = alloca [ i32, i32 }
%y = getelementptr { i32, i32 }, { i32, i32 }* %x, i32 0, i32 %dynamic_offs
%z = load i32, i32* %y ; isPointerOffset == false
%x0 = getelementptr { i32, i32 }, { i32, i32 }* %x, i32 0, i32 0
%x1 = getelementptr { i32, i32 }, { i32, i32 }* %x, i32 0, i32 1
store i32 0, i32* %x0
store i32 0, i32* %x1
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