[PATCH] DataFlowSanitizer; LLVM changes.
Peter Collingbourne
peter at pcc.me.uk
Tue Jul 2 19:00:12 PDT 2013
================
Comment at: lib/Transforms/Instrumentation/DataFlowSanitizer.cpp:656
@@ +655,3 @@
+ Ofs += 64 / DFS.ShadowWidth) {
+ BasicBlock *NextBB = BasicBlock::Create(*DFS.Ctx, "", F);
+ IRBuilder<> NextIRB(NextBB);
----------------
Evgeniy Stepanov wrote:
> You creating are a lot of basic blocks here. Would it be better to make a loop here an leave it to the loop unroller to make the decision?
> On the other hand, in practice Size must be very limited.
Exactly. I expect generally about 1 iteration max through this loop. It was easier to code this without a loop and I don't think it's worth trying to optimise for the uncommon case where the load is large.
================
Comment at: lib/Transforms/Instrumentation/DataFlowSanitizer.cpp:723
@@ +722,3 @@
+ uint64_t Offset = 0;
+ if (Size >= ShadowVecSize) {
+ VectorType *ShadowVecTy = VectorType::get(DFS.ShadowTy, ShadowVecSize);
----------------
Evgeniy Stepanov wrote:
> This looks like an optimization that belongs elsewhere. I wonder if there is a pass in LLVM that will do it for you?
> Also, why 128 bit code here, and only 64 bit in LoadShadow?
> This looks like an optimization that belongs elsewhere. I wonder if there is a pass in LLVM that will do it for you?
I don't think there is one. I tried optimising the following code with -O3; no improvement:
void f(short *p, short s) {
for (unsigned i = 8; i != 0; --i, ++p) {
*p = s;
}
}
> Also, why 128 bit code here, and only 64 bit in LoadShadow?
Because LoadShadow needs to be able to do equality comparisons and collapse the result into a single bit. It also needs to be able to compare every 16-bit element of the 128-bit vector against one another. There are some short instruction sequences for the former (on x86), but LLVM doesn't seem to be able to generate them, and I haven't thought too much about the latter yet.
http://llvm-reviews.chandlerc.com/D965
More information about the llvm-commits
mailing list