[LLVMdev] Why function pointer is different from other data type?

Hao Shen william.shen at gmail.com
Mon Apr 12 08:02:44 PDT 2010

Dear all,

I compiled c program with llvm and found something strange with
function pointer as following small example .

------------- In C Code --------------
float a (int value) {
    return value + 1;

typedef float (*funcptr_t) (int);

funcptr_t get_ptr(funcptr_t p) {
    return p;

float result = get_ptr(a)(4);

------------- In LLVM Code --------------

%4 = call float (i32)* (float (i32)*)* @get_ptr(float (i32)* @a1)
nounwind ; <float (i32)*> [#uses=1]
              ~~~~~~~~~~~~~~~~~~~~  VERY STRANGE RETURN TYPE !!!
%5 = call float %4(i32 4) nounwind              ; <float> [#uses=1]

Why we need duplicated return type?

Best regards,
Hao Shen

More information about the llvm-dev mailing list