I'm writing an open source library for Rust, and would like to serve an API that writes
&'static str wrapped with double quotation mark (") into memory. Here is a simplified code:
Assembly output says it writes double quotation mark first, write contents, and then double quotation mark again.
I implemented the exactly same operation in C, but clang optimize this as I expected.
What surprised me more is, if I removed the
test2 function from above Rust code, LLVM properly optimize the operations.
Could you tell me why things happen, and how can I make things work?