[LLVMdev] How to disable simplifying function parameters in llvm-g++

Xiaolong Tang xiaolong.snake at gmail.com
Mon Jul 26 02:48:15 PDT 2010


Hello everybody, 

It seems to me that there is one kind of default optimization
executed by llvm-g++, simplifying function parameters in certain
cases. Consider the following example:

Given an iterator (in the context of C++ STL) (i.e. a class containing
a pointer to another class):

  %"struct.std::_List_const_iterator<int>" = type { %"struct.std::_List_node_base"* }
  (The form in the readable LLVM language)

and a function definition (declaration):

  void _M_insert(iterator __position, const value_type& __x) { ... }

By issuing this command:

  llvm-g++ -fno-exceptions -fno-inline -emit-llvm -c ...

The compilation substitutes "__position.0" for "__position", as shown below:

  define linkonce_odr void @_ZNSt4listIiSaIiEE9_M_insertESt14_List_iteratorIiERKi(%"struct.std::list<int,std::allocator<int> >"* %this, i64 %__position.0, i32* %__x) nounwind ssp { ... }

My questions are:
Could this transformation be disabled in llvm-g++? And how to achieve this?

P.S. Without any optimizations, g++ does NOT do this.

Best, 
Xiaolong



More information about the llvm-dev mailing list