This is an archive of the discontinued LLVM Phabricator instance.

[AddressSanitizer] Instrument byval call arguments
AbandonedPublic

Authored by thejh on Apr 6 2020, 5:40 PM.

Details

Reviewers
None
Summary

In the LLVM IR, "call" instructions read memory for each byval operand.
For example:

$ cat blah.c
struct foo { void *a, *b, *c; };
struct bar { struct foo foo; };
void func1(const struct foo);
void func2(struct bar *bar) { func1(bar->foo); }
$ [...]/bin/clang -S -flto -c blah.c -O2 ; cat blah.s
[...]
define dso_local void @func2(%struct.bar* %bar) local_unnamed_addr #0 {
entry:

%foo = getelementptr inbounds %struct.bar, %struct.bar* %bar, i64 0, i32 0
tail call void @func1(%struct.foo* byval(%struct.foo) align 8 %foo) #2
ret void

}
[...]
$ [...]/bin/clang -S -c blah.c -O2 ; cat blah.s
[...]
func2: # @func2
[...]
subq $24, %rsp
[...]
movq 16(%rdi), %rax
movq %rax, 16(%rsp)
movups (%rdi), %xmm0
movups %xmm0, (%rsp)
callq func1
addq $24, %rsp
[...]
retq

Let ASAN instrument these hidden memory accesses.

Diff Detail

Event Timeline

thejh created this revision.Apr 6 2020, 5:40 PM
thejh abandoned this revision.Apr 6 2020, 5:42 PM