<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<p>Hi,</p>
<p>Did you think about using something like Debugger API to
translate addresses to the var names?<br>
</p>
<p> <br>
</p>
<pre class="moz-signature" cols="72">-------------
Best regards,
Alexey Bataev</pre>
<div class="moz-cite-prefix">08.10.2020 11:38 AM, Huber, Joseph via
llvm-dev пишет:<br>
</div>
<blockquote type="cite" cite="mid:%3CBLAPR09MB7329220C91E3460880466CADD90B0@BLAPR09MB7329.namprd09.prod.outlook.com%3E">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;}</style>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
Hello, </div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
A commonly requested feature in the OpenMP Target Runtime is to
be able to associate offloaded pointers with their original
variable names. We figured the most straightforward way to
accomplish this is to make an additional argument to the mapper
functions that contains an array of structs containing source
information about the variables similar to how we pass in the
size and offset already. This will only happen if debugging
symbols are enabled, otherwise we'll probably just pass a null
pointer. So, basically we're planning on turning this<br>
<br>
void __tgt_target_data_begin_mapper(int64_t device_id, int32_t
arg_num,
<div> void **args_base, void
**args,</div>
<div> int64_t *arg_sizes,
int64_t *arg_types,</div>
<div> void **arg_mappers);</div>
<br>
Into something like this for better debugging.<br>
<br>
void __tgt_target_data_begin_mapper(ident_t *loc, int64_t
device_id, int32_t arg_num,
<div> void **args_base, void
**args,</div>
<div> int64_t *arg_sizes,
arg_info_struct **arg_info, int64_t *arg_types,</div>
<div> void **arg_mappers);</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
I figured we could trace back the original VarDecls used to
create the mapper arguments and just build a struct using the
names (if availible). There's a ValueDecl listed in the
BasePointerInfo class at CGOpenMPRuntime.cpp:7048 but when I
tried to access its fields it was just a nullptr when I was
passing in a single variable. The method 'setDevicePtrDecl` is
used to set it, but it's only called in a single location at
CGOpenMPRuntime.cpp:8240 so I'm assuming this is not available
in the general case.<br>
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
What do you think would be the best way to approach this?
Basically just getting the name and line number of the variable
declaration that was used to build the argument to the offload
function.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
Thanks,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);">
Joseph Huber</div>
</blockquote>
</body>
</html>