diff options
| author | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2013-08-23 12:11:00 +0000 |
|---|---|---|
| committer | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2013-08-23 12:11:00 +0000 |
| commit | d42863cc1fd8702aa635859a56411bd5f3a59142 (patch) | |
| tree | cf03484706f557117f8e320babffe3255cc077e7 /llvm/test | |
| parent | e3dd684aadcaba6993e0d91734cc4cc62ff4de87 (diff) | |
| download | bcm5719-llvm-d42863cc1fd8702aa635859a56411bd5f3a59142.tar.gz bcm5719-llvm-d42863cc1fd8702aa635859a56411bd5f3a59142.zip | |
[msan] Fix handling of va_arg overflow area on x86_64.
The code was erroneously reading overflow area shadow from the TLS slot,
bypassing the local copy. Reading shadow directly from TLS is wrong, because
it can be overwritten by a nested vararg call, if that happens before va_start.
llvm-svn: 189104
Diffstat (limited to 'llvm/test')
| -rw-r--r-- | llvm/test/Instrumentation/MemorySanitizer/msan_basic.ll | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/llvm/test/Instrumentation/MemorySanitizer/msan_basic.ll b/llvm/test/Instrumentation/MemorySanitizer/msan_basic.ll index 4fa031924f5..345b070b538 100644 --- a/llvm/test/Instrumentation/MemorySanitizer/msan_basic.ll +++ b/llvm/test/Instrumentation/MemorySanitizer/msan_basic.ll @@ -597,6 +597,31 @@ define void @VACopy(i8* %p1, i8* %p2) nounwind uwtable sanitize_memory { ; CHECK: ret void +; Test that va_start instrumentation does not use va_arg_tls*. +; It should work with a local stack copy instead. + +%struct.__va_list_tag = type { i32, i32, i8*, i8* } +declare void @llvm.va_start(i8*) nounwind + +; Function Attrs: nounwind uwtable +define void @VAStart(i32 %x, ...) { +entry: + %x.addr = alloca i32, align 4 + %va = alloca [1 x %struct.__va_list_tag], align 16 + store i32 %x, i32* %x.addr, align 4 + %arraydecay = getelementptr inbounds [1 x %struct.__va_list_tag]* %va, i32 0, i32 0 + %arraydecay1 = bitcast %struct.__va_list_tag* %arraydecay to i8* + call void @llvm.va_start(i8* %arraydecay1) + ret void +} + +; CHECK: @VAStart +; CHECK: call void @llvm.va_start +; CHECK-NOT: @__msan_va_arg_tls +; CHECK-NOT: @__msan_va_arg_overflow_size_tls +; CHECK: ret void + + ; Test handling of volatile stores. ; Check that MemorySanitizer does not add a check of the value being stored. |

