[DFSan] Re-enable event_callbacks test.

Mark the dest pointers for memcpy and memmove as volatile, to avoid dead
store elimination.  Fixes https://bugs.llvm.org/show_bug.cgi?id=47488.
This commit is contained in:
Matt Morehouse 2020-09-11 09:13:34 -07:00
parent f2bb4b8855
commit 2df6efedef
1 changed files with 6 additions and 8 deletions

View File

@ -2,10 +2,6 @@
// RUN: %clang_dfsan -O2 -mllvm -dfsan-event-callbacks %s %t-callbacks.o -o %t
// RUN: %run %t FooBarBaz 2>&1 | FileCheck %s
// See PR47488, parts of this test get optimized out by a more aggressive
// dead store eliminator.
// XFAIL: *
// Tests that callbacks are inserted for store events when
// -dfsan-event-callbacks is specified.
@ -118,14 +114,16 @@ int main(int Argc, char *Argv[]) {
LabelArgv = dfsan_create_label("Argv", 0);
dfsan_set_label(LabelArgv, Argv[1], LenArgv);
char SinkBuf[64];
assert(LenArgv < sizeof(SinkBuf) - 1);
char Buf[64];
assert(LenArgv < sizeof(Buf) - 1);
// CHECK: Label 4 copied to memory
memcpy(SinkBuf, Argv[1], LenArgv);
void *volatile SinkPtr = Buf;
memcpy(SinkPtr, Argv[1], LenArgv);
// CHECK: Label 4 copied to memory
memmove(&SinkBuf[1], SinkBuf, LenArgv);
SinkPtr = &Buf[1];
memmove(SinkPtr, Buf, LenArgv);
return 0;
}