4 echo "Path to clang required!"
5 echo "Usage: update_memprof_inputs.sh /path/to/updated/clang"
11 # Allows the script to be invoked from other directories.
12 OUTDIR
=$
(dirname $
(realpath
-s $0))
14 read -r -d '' BASIC
<< EOF
17 int main(int argc, char **argv) {
18 char *x = (char *)malloc(10);
21 x = (char *)malloc(10);
28 read -r -d '' INLINE
<< EOF
32 __attribute__((always_inline))
34 char *ptr = malloc(x);
39 __attribute__((noinline))
40 void foo(int x){ qux(x); }
42 __attribute__((noinline))
43 void bar(int x) { foo(x); }
45 int main(int argc, char **argv) {
51 read -r -d '' MULTI
<< EOF
52 #include <sanitizer/memprof_interface.h>
55 int main(int argc, char **argv) {
56 char *x = (char *)malloc(10);
59 __memprof_profile_dump();
60 x = (char *)malloc(10);
67 DEFAULT_MEMPROF_FLAGS
="-fuse-ld=lld -Wl,--no-rosegment -gmlt -fdebug-info-for-profiling -fmemory-profile -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-optimize-sibling-calls -m64 -Wl,-build-id -no-pie"
69 # Map each test to their source and any additional flags separated by ;
71 INPUTS
["basic"]="BASIC"
72 INPUTS
["inline"]="INLINE"
73 INPUTS
["multi"]="MULTI"
74 INPUTS
["pic"]="BASIC;-pie"
75 INPUTS
["buildid"]="BASIC;-Wl,-build-id=sha1"
77 for name
in "${!INPUTS[@]}"; do
78 IFS
=";" read -r src flags
<<< "${INPUTS[$name]}"
79 echo "${!src}" > ${OUTDIR}/${name}.c
80 ${CLANG} ${DEFAULT_MEMPROF_FLAGS} ${flags} ${OUTDIR}/${name}.c -o ${OUTDIR}/${name}.memprofexe
81 env MEMPROF_OPTIONS=log_path=stdout ${OUTDIR}/${name}.memprofexe > ${OUTDIR}/${name}.memprofraw
82 rm ${OUTDIR}/${name}.c