[llvm-dev] Risc-v Assembly printer function order

Friedman, Eli via llvm-dev llvm-dev at lists.llvm.org
Tue Aug 7 10:58:25 PDT 2018


On 8/7/2018 12:54 AM, 'Irenee GROZ IG255340' via llvm-dev wrote:
> Hello,
>
> I am working on the assembly printer for RISC-V, more specifically on 
> the AsmPrinter class.
> I altered the RISCV Backend to print C code instead of Assembly, 
> interpreted by libraries... (but that's not important)
> My problem is that, for my application to work, I need to treat my 
> functions in the order they are in the original C file.
> I discovered that these functions are not treated in this order.
>
> My question is : Is there a way to force llvm to treat the functions 
> in the order given in the original C file ? and how?

The LLVM backend should generally print functions in the same order they 
appear in the IR.  This is an implementation detail, not a guarantee, 
but there currently aren't any backend passes that rearrange functions.

That said, clang doesn't really try to emit functions in source order: 
it will delay emitting functions for various reasons.  If that's truly 
necessary for your use-case, you'll probably have to modify clang 
somehow.  Or maybe -femit-all-decls is close enough if your input is pure C?

-Eli

-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project



More information about the llvm-dev mailing list