<div dir="ltr"><div><br></div>The DataFlowSanitizer pass on LLVM 3.8.0, 64 bit (Ubuntu 16.04.2) generates the following IR from source:<div><br></div><div>======================================<br></div><div>test.c</div><div>======================================</div><div><div>#include <sanitizer/dfsan_interface.h></div><div><br></div><div>int main(void) {</div><div> int i = 1;</div><div> </div><div> dfsan_label i_label = dfsan_create_label("i", 0);</div><div> dfsan_set_label(i_label, &i, sizeof(i));</div><div><br></div><div> return 0;</div><div>}</div><div><br></div><div>======================================</div><div>clang -c -emit-llvm -fsanitize=dataflow test.c -o test.bc</div><div>llvm-dis test.bc</div><div>======================================<br></div><div><br></div><div>test.ll</div><div>======================================</div><div><br></div><div><div>; Function Attrs: nounwind uwtable</div><div>define i32 @main() #0 {</div><div>entry:</div><div> %0 = alloca i16</div><div> %retval = alloca i32, align 4</div><div> %i = alloca i32, align 4</div><div> %1 = alloca i16</div><div> %i_label = alloca i16, align 2</div><div> store i16 0, i16* %0</div><div> store i32 0, i32* %retval, align 4</div><div> </div><div> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</div><div> %2 = ptrtoint i32* %i to i64<br></div><div> %3 = and i64 %2, -123145302310913</div><div> %4 = mul i64 %3, 2</div><div> %5 = inttoptr i64 %4 to i16*</div><div> %6 = bitcast i16* %5 to i64*</div><div> store i64 0, i64* %6, align 2</div><div> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br></div><div><br></div><div> store i32 1, i32* %i, align 4</div><div> %call = call zeroext i16 @dfsan_create_label(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0), i8* null)</div><div> store i16 0, i16* %1</div><div> store i16 %call, i16* %i_label, align 2</div><div> %7 = load i16, i16* %1</div><div> %8 = load i16, i16* %i_label, align 2</div><div> %9 = bitcast i32* %i to i8*</div><div> call void @dfsan_set_label(i16 zeroext %8, i8* %9, i64 4)</div><div> ret i32 0</div><div>}</div></div><div><br></div><div>======================================<br></div><div><br></div><div>I don't understand why the block of instruction I separated out is being generated. Looking at the Transform/Instrumentation/DataFlowsanitizer.cpp, I can't find the code that inserts the instrumentation above. Can anyone explain this behavior?</div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><span><div><div dir="ltr"><p>Thanks & Regards,</p>
<div>Dipanjan</div></div></div></span></div></div>
</div></div>