<div dir="auto">Dear everyone,<div dir="auto"><br></div><div dir="auto">Is it possible in LLVM/clang to search for a specific code line and print out/extract the whole function/relevant code region where the code line was found?</div><div dir="auto"><br></div><div dir="auto">Here is an example. I would like to analyze the c file inĀ <a href="https://github.com/UoB-HPC/intro-hpc-jacobi" rel="noreferrer noreferrer noreferrer" target="_blank">https://github.com/UoB-HPC/intro-hpc-jacobi</a>.</div><div dir="auto"><br></div><div dir="auto">Let's say the specific code line is line 62:</div><div dir="auto"><span style="color:rgb(36,41,46);font-family:sfmono-regular,consolas,"liberation mono",menlo,monospace;font-size:12px;white-space:pre-wrap;background-color:rgb(255,255,255)">dot += A[row + col*N] * x[col];</span><br></div><div dir="auto"><br></div><div dir="auto">In that case I would be interested in that code region:</div><div dir="auto"><table style="border-spacing:0px;border-collapse:collapse;color:rgb(36,41,46);font-family:-apple-system,blinkmacsystemfont,"segoe ui",helvetica,arial,sans-serif,"apple color emoji","segoe ui emoji";font-size:14px;text-indent:0px;background-color:rgb(255,255,255)"><tbody><tr><td style="padding:0px 10px;line-height:20px;vertical-align:top;font-family:'sfmono-regular','consolas','liberation mono','menlo',monospace;font-size:12px;white-space:pre-wrap">    // Perfom Jacobi iteration</td></tr><tr style="background-color:transparent"><td style="padding:0px 10px;width:50px;min-width:50px;font-family:'sfmono-regular','consolas','liberation mono','menlo',monospace;font-size:12px;line-height:20px;text-align:right;white-space:nowrap;vertical-align:top"></td><td style="padding:0px 10px;line-height:20px;vertical-align:top;font-family:'sfmono-regular','consolas','liberation mono','menlo',monospace;font-size:12px;white-space:pre-wrap">    for (row = 0; row < N; row++)</td></tr><tr><td style="padding:0px 10px;width:50px;min-width:50px;font-family:'sfmono-regular','consolas','liberation mono','menlo',monospace;font-size:12px;line-height:20px;text-align:right;white-space:nowrap;vertical-align:top"></td><td style="padding:0px 10px;line-height:20px;vertical-align:top;font-family:'sfmono-regular','consolas','liberation mono','menlo',monospace;font-size:12px;white-space:pre-wrap">    {</td></tr><tr style="background-color:transparent"><td style="padding:0px 10px;width:50px;min-width:50px;font-family:'sfmono-regular','consolas','liberation mono','menlo',monospace;font-size:12px;line-height:20px;text-align:right;white-space:nowrap;vertical-align:top"></td><td style="padding:0px 10px;line-height:20px;vertical-align:top;font-family:'sfmono-regular','consolas','liberation mono','menlo',monospace;font-size:12px;white-space:pre-wrap">      dot = 0.0;</td></tr><tr><td style="padding:0px 10px;width:50px;min-width:50px;font-family:'sfmono-regular','consolas','liberation mono','menlo',monospace;font-size:12px;line-height:20px;text-align:right;white-space:nowrap;vertical-align:top"></td><td style="padding:0px 10px;line-height:20px;vertical-align:top;font-family:'sfmono-regular','consolas','liberation mono','menlo',monospace;font-size:12px;white-space:pre-wrap">      for (col = 0; col < N; col++)</td></tr><tr style="background-color:transparent"><td style="padding:0px 10px;width:50px;min-width:50px;font-family:'sfmono-regular','consolas','liberation mono','menlo',monospace;font-size:12px;line-height:20px;text-align:right;white-space:nowrap;vertical-align:top"></td><td style="padding:0px 10px;line-height:20px;vertical-align:top;font-family:'sfmono-regular','consolas','liberation mono','menlo',monospace;font-size:12px;white-space:pre-wrap">      {</td></tr><tr><td style="padding:0px 10px;width:50px;min-width:50px;font-family:'sfmono-regular','consolas','liberation mono','menlo',monospace;font-size:12px;line-height:20px;text-align:right;white-space:nowrap;vertical-align:top"></td><td style="padding:0px 10px;line-height:20px;vertical-align:top;font-family:'sfmono-regular','consolas','liberation mono','menlo',monospace;font-size:12px;white-space:pre-wrap">        if (row != col)</td></tr><tr style="background-color:transparent"><td style="padding:0px 10px;width:50px;min-width:50px;font-family:'sfmono-regular','consolas','liberation mono','menlo',monospace;font-size:12px;line-height:20px;text-align:right;white-space:nowrap;vertical-align:top"></td><td style="padding:0px 10px;line-height:20px;vertical-align:top;font-family:'sfmono-regular','consolas','liberation mono','menlo',monospace;font-size:12px;white-space:pre-wrap">          dot += A[row + col*N] * x[col];</td></tr><tr><td style="padding:0px 10px;width:50px;min-width:50px;font-family:'sfmono-regular','consolas','liberation mono','menlo',monospace;font-size:12px;line-height:20px;text-align:right;white-space:nowrap;vertical-align:top"></td><td style="padding:0px 10px;line-height:20px;vertical-align:top;font-family:'sfmono-regular','consolas','liberation mono','menlo',monospace;font-size:12px;white-space:pre-wrap">      }</td></tr><tr style="background-color:transparent"><td style="padding:0px 10px;width:50px;min-width:50px;font-family:'sfmono-regular','consolas','liberation mono','menlo',monospace;font-size:12px;line-height:20px;text-align:right;white-space:nowrap;vertical-align:top"></td><td style="padding:0px 10px;line-height:20px;vertical-align:top;font-family:'sfmono-regular','consolas','liberation mono','menlo',monospace;font-size:12px;white-space:pre-wrap">      xtmp[row] = (b[row] - dot) / A[row + row*N];</td></tr><tr><td style="padding:0px 10px;width:50px;min-width:50px;font-family:'sfmono-regular','consolas','liberation mono','menlo',monospace;font-size:12px;line-height:20px;text-align:right;white-space:nowrap;vertical-align:top"></td><td style="padding:0px 10px;line-height:20px;vertical-align:top;font-family:'sfmono-regular','consolas','liberation mono','menlo',monospace;font-size:12px;white-space:pre-wrap">    }</td></tr></tbody></table></div><div dir="auto"><br></div><div dir="auto">How can I get this result via LLVM/clang?</div><div dir="auto"><br></div><div dir="auto">Thank you very much for your ideas!</div><div dir="auto"><br></div><div dir="auto">BestĀ </div><div dir="auto">Anja</div></div>