<div dir="ltr"><div><div><div><div>Hi, all.<br></div>I'm a graduate student working on creating llvm pass that generates resilient version of code automatically. <br></div>Basically, what it does is to duplicate instructions and compare them at the synchronization points, such as function call, branch. Plus, there is one more copy for recovery. So if two copies agree, program will proceed with original copy, or otherwise it will use the third copy as corrected one. It looks like below.<br></div><div>e.g.<br>$inst1 = add $1, $2<br></div><div>$inst2 = add $3, $4<br></div><div>$inst3 = add $5, $6<br></div><div>$cmp = icmp $inst1, $inst2<br></div><div>$corrected = sel $cmp, $inst1, $inst3<br></div><div>printf $corrected //very simplified form<br></div><div><br></div>Everything was going fine, but now I'm stuck at a weird bug that I cannot quite understand. <br></div><div>If the instructions to be copied are accessing structure elements and they are printed out by printf or fprintf(like example above except it does not access structure), it occurs segfault at runtime even though they are legit memory access. <br><br>* Here's more clarification for my situation.<br>- It compiles successfully.<br>- If I commented out 'printf' or 'fprintf' from the source code, the program works fine. So it seems like there's a problem on this part.<br></div><div>- For other printf with corrected value, they works fine if they are not accessing structure element. <br></div><div><br><br></div><div>Error msg and comparison between original code and transformed code by my pass are attached below. I tried to make it shown here but the size wasn't fit. <br><br></div><div>Is there anyone who had same problem or have any idea/guess/hint for me?<br></div><div>Thank you in advance!<br></div><div><div><div><div><div><div><div><br clear="all"><br>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr">Best, Sung<br><br></div></div></div></div>
</div></div></div></div></div></div></div></div>