<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
On 4/29/2013 9:13 AM, Jovi Zhang wrote:<br>
<span style="white-space: pre;">> We arrived the key part:
offsetof and sizeof are resolved to a <br>
> constant by Clang before they are lowered to LLVM IR, so
that's the<br>
> main reason why there have a high-level IR file except LLVM
IR file,<br>
> that high-level IR file contain unresolved structure field
reference<br>
> info and unresolved sizeof, that high-level IR file "link"
with<br>
> kernel header ABI file which contain structure offset and
sizeof<br>
> info, then generate to LLVM IR file, this is the design
picture.<br>
> <br>
> I don't want to change LLVM IR format, I'm just thinking on
hack<br>
> Clang to output that high-level IR file without resolved<br>
> offset/sizeof info, how about this sounds?</span><br>
<br>
I think that is much less feasible then it sounds. Since
offsetof/sizeof are both compiled to a constant, they are both
compile-time constants. In particular, you can do things in C like:<br>
<br>
#if sizeof(T) == 10<br>
...<br>
#endif<br>
<br>
This means that the only truly portable way to late-resolve
offsetof/sizeof is to save the source code of the program and
compile it as late as possible. I'm skeptical that you could
convince all the stakeholders you would need to support this
approach, especially since you are probably neither willing to
implement any optimizations on your "high-level IR" nor able to make
it close enough to LLVM IR to reuse LLVM's optimization passes--as a
result, you would pretty much be distributing the source code to
your driver module, just without the comments and less resilient to
kernel changes than the original source.<br>
<br>
-- <br>
Joshua Cranmer<br>
News submodule owner<br>
DXR coauthor<br>
<br>
</body>
</html>