<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<tt>Hi everyone,<br>
<br>
We are using the llvm2cpp feature of LLVM in the VMKit project and
there are some issues that I would like to point out.<br>
<br>
I made a tiny reproducible example here, to be clear:<br>
<br>
echo "int main() { return 0; };" > test.c && clang
test.c -emit-llvm -c -o - | llc -march=cpp -cppgen=function
-cppfor=main -o -<br>
<br>
This command is supposed to generate the C++ code to construct the
main function in LLVM (see main_llvm2cpp.cc joined file).<br>
But an error occurs while generating the code (see stack trace
below).<br>
<br>
It appears that an assertion is broken while treating attributes
in </tt><tt><tt>the file CPPBackend.cpp</tt>.<br>
So I dumped the main function's attributes before treating them,
here is the result:<br>
<br>
PAL[<br>
{ ~0U => <b>nounwind uwtable</b>
"less-precise-fpmad"="false" "no-frame-pointer-elim"="false"
"no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false"
"no-nans-fp-math"="false" "unsafe-fp-math"="false"
"use-soft-float"="false" }<br>
]<br>
<br>
The problem </tt><tt><tt>is that </tt>llvm2cpp code generation
supports only the attributes present in the AttrKind enum of the
Attribute class.<br>
It means that the following attributes are not supported:<br>
- "</tt><tt><tt>less-precise-fpmad"<br>
- </tt></tt><tt>"no-frame-pointer-elim"<br>
- </tt><tt>"no-frame-pointer-elim-non-leaf"<br>
- </tt><tt>"no-infs-fp-math"<br>
- </tt><tt>"no-nans-fp-math"<br>
- </tt><tt>"unsafe-fp-math"<br>
- </tt><tt>"use-soft-float"<br>
<br>
What is extremely strange, is that those attributes are set by
clang with no particular option. <br>
<br>
So, is the assert in CPPBackend.cpp deprecated or should those
attributes be handled somehow in C++ code generation (which means
that the previous attribute list should be added to the AttrKind
enum of the Attribute class)?<br>
<br>
Cheers,<br>
</tt>
<pre class="moz-signature" cols="72">--
Harris Bakiras
</pre>
<tt> llc: CPPBackend.cpp:521: void
{anonymous}::CppWriter::printAttributes(const
llvm::AttributeSet&, const string&): Assertion
`!attrs.hasAttributes() && "Unhandled attribute!"' failed.<br>
0 llc 0x00000000010edc22
llvm::sys::PrintStackTrace(_IO_FILE*) + 34<br>
1 llc 0x00000000010ed049<br>
2 libpthread.so.0 0x00007f9701addcb0<br>
3 libc.so.6 0x00007f9700d2f425 gsignal + 53<br>
4 libc.so.6 0x00007f9700d32b8b abort + 379<br>
5 libc.so.6 0x00007f9700d280ee<br>
6 libc.so.6 0x00007f9700d28192<br>
7 llc 0x000000000064fed3<br>
8 llc 0x000000000065335b<br>
9 llc 0x0000000000659fed<br>
10 llc 0x000000000065b0dc<br>
11 llc 0x0000000001081230
llvm::MPPassManager::runOnModule(llvm::Module&) + 688<br>
12 llc 0x0000000001081405
llvm::PassManagerImpl::run(llvm::Module&) + 245<br>
13 llc 0x0000000000565d27<br>
14 llc 0x0000000000551281 main + 353<br>
15 libc.so.6 0x00007f9700d1a76d __libc_start_main + 237<br>
16 llc 0x0000000000561fd5<br>
Stack dump:<br>
0. Program arguments: llc -march=cpp -cppgen=function
-cppfor=main -o - <br>
1. Running pass 'C++ backend' on module '<stdin>'.<br>
Aborted (core dumped)<br>
<br>
</tt>
</body>
</html>