Closed djg closed 6 years ago
Ah, I need to update the example. Cretonne's ExternalName
changed from holding actual byte sequences to holding opaque indices; this is what necessitated llvm2cretonne's string_table.rs. So this means that the Cretonne IR dump won't contain the actual symbol name anymore.
That said, it would be nice to print the name somewhere. Perhaps we could have the llvm2cretonne code that prints the function print a comment before the function.
@sunfishcode I started adding an option to cretonne to pass through a closure that is called to resolve ExternalName
into a proper name. It works, but from reading the code I'm not sure what the requirements governing cretonne names are?
The docs appear to suggest they're of the %string
format but the code calls these testcase strings and limits them to 16 characters.
Surely we need to keep the name if it's an external symbol, such as function bar, that the linker needs to lookup?
The design principle behind this is that the Cretonne codegen crate is meant to be just about codegen, and not linking, so it doesn't need to know anything about symbol names. As such, it's llvm2cretonne's job to keep track of the actual name strings, and pass them to faerie at the appropriate time.
Thanks for the clarification.
With https://github.com/sunfishcode/llvm2cretonne/commit/3ca2d2f810d5982b49493afee9f4959f44f84379, llvm2cretonne -p now prints the function names again, and the README is updated.
The following LLVM IR:
Is translated into CTON IR:
foo
andbar
are changed tou0:0
andu0:1
. Given the example in the Cretonne docs, the following should be generated:This appears to be an issue with Cretonne. ExternalName doesn't provide anyway to look up user-defined names.