clang and static functions

Hi,

I am trying to compile a single module (dgemm.c) using clang and
generate dgemm.ll.
Command: clang -emit-llvm dgemm.c -S -o dgemm.ll
Some of the functions are declared as static and clang ignores these functions:

One of the functions is:
static void innerloop(double a, const double* b, double* c, double beta)
{
  *b = a*beta;
   return;
}

Is there any way to make clang generate llvm code for the static functions?

Thanks
Sincerely
Arvind

Hi Arvind,

you need to use it effectively :

static int add(int a, int b) {
return a+b;
}
int use() {
return add(4,5);
}

==>

; ModuleID = ‘’
target datalayout = “e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32”
target triple = “i386-pc-linux-gnu”

define i32 @use() nounwind {
[…]
}

define internal i32 @add(i32 %a, i32 %b) nounwind {
[…]
}

Olivier.

Hi,

Sorry for not being specific. I just wanted to know if there is any
way at all to force clang to generate intermediate code for static
functions when they are not being called anywhere inside the current
module. Other compilers seem to generate intermediate code (lcc, for
instance).

Thanks for your reply..Olivier.

Sincerely
Arvind

You can mark it with 'attribute used'. Other than that, no, clang tries hard not to generate dead code. Also, in C++, it's not even valid to instantiate unused templates.

-Chris

Ah ok. Sorry. :slight_smile:

I think that argument “-femit-all-decls” will help you.

Olivier.

Hi Olivier,

That worked....Thanks....

Arvind