[LLVMdev] How to disable simplifying function parameters in llvm-g++
xiaolong.snake at gmail.com
Mon Jul 26 09:40:54 PDT 2010
> > Note that the original parameter (of the function in concern) is of
> > type "struct.std::_List_const_iterator<int>", whereas the parameter
> > (after the compilation) is of type
> > "struct.std::_List_node_base"*. Evidently, llvm-g++ replaces the
> > original parameter with its sole field. This is understandable and the
> > LLVM output indicates this by using "__position.0" rather than
> > "__position". Further, llvm-g++ represents (bitcasts) the parameter
> > type "struct.std::_List_node_base"* as (into) i64. Though this may
> > be decoded by analyzing the meta data with the function, I believe
> > that llvm-g++ has conducted some transformations somehow. To me, the
> > transformation looks likes scalar replacement.
> I think on the contrary this is llvm-g++ trying to obtain ABI conformance.
> The rules on how parameters should be passed to functions (in registers, on
> the stack, partly in registers, partly on the stack) can be quite complicated.
> Rather than pushing this complexity into LLVM, front-ends are required to take
> care of ensuring ABI conformance when they generate the LLVM IR. The kind of
> transform you see looks typical of llvm-g++ trying to handle an ABI rule which
> says that initial fields of a struct should be passed in registers. In short,
> I don't think this is LLVM doing an optimization, it is LLVM trying to produce
> correct ABI conformant code.
As far as you know, is there any way to figure out the original type
of the function parameter? As to the example in concern, is it
possible to find out that the function parameter has the original type
"struct.std::_List_node_base"*, maybe from i64. The debug information
(arising from -g) seems to contain no such information.
More information about the llvm-dev