Sachin.Punyani at microchip.com
2008-May-12 15:28 UTC
[LLVMdev] FW: Integer promotion of return node operand
Hi I am sorry. In my previous mail I mistyped the test case and disassembly. Test case -- -------------------------------------- char a; char fun () { return a; } -------------------------------------- Disassembly -------------------------------------- ; ModuleID = 'first.bc' @a = global i8 0 ; <i8*> [#uses=1] define i8 @fun(...) { entry: %tmp = load i8* @a ; <i8> [#uses=1] ret i8 %tmp } -------------------------------------- -----Original Message----- From: Sachin Punyani - I00202 Sent: Monday, May 12, 2008 8:51 PM To: LLVM Developer Mailing List (llvmdev at cs.uiuc.edu) Subject: Integer promotion of return node operand Hi All, Please consider the following case Test case -- -------------------------------------- char a; void fun () { return a; } -------------------------------------- Following disassembly (using llvm-dis) is generated for the above test case -------------------------------------- ; ModuleID = 'first.bc' @a = internal global i8 0 ; <i8*> [#uses=1] define i8 @fun(...) { entry: %tmp = load i8* @a ; <i8> [#uses=1] ret i8 %tmp } -------------------------------------- When LLVM constructs the DAG for above case - it tries to promote (during DAG construction phase - before any combine or legalize phase) the return node operand to i32. I have few doubts here: 1) If C language requires integer promotion of return value argument then should it not be done by the C language frontend. (I think LLVM is langauge independent). This is what happens when we use char in calculations. Clang promotes char in calculations to int and this promotion is visible in the disassembly. However return node operand promotion is not visible in disassembly but LLVM is doing that. 2) Also should the char not be promoted to target integer (Target integer may be 16 bits). LLVM tries to promote to i32 (promotion to i32 is hardcoded in file SelectionDAGISel.cpp - function visitRet). The comment in LLVM code says "C calling convention requires the return type to be promoted to atleast 32 bits. But this is not necessary for non-C calling conventions." What about targets where integer size is not 32 bits ?? 3) And How should this promotion be handled when the target does not have register to handle int size. e.g. if a target has int size of 16 bits but the register size of 8 bits. Regards -:SP:-
Possibly Parallel Threads
- [LLVMdev] Integer promotion of return node operand
- [LLVMdev] Integer promotion of return node operand
- [LLVMdev] Troubling promotion of return value to Integer ...
- [LLVMdev] Troubling promotion of return value to Integer ...
- [LLVMdev] Troubling promotion of return value to Integer ...