[LLVMdev] Removing unused global constant
Rafael EspĂndola
rafael.espindola at gmail.com
Tue Nov 20 13:50:17 PST 2012
When I run llvm-extract I get:
@.str = hidden unnamed_addr constant [7 x i8] c"hello\0A\00", align 1
@.str1 = hidden unnamed_addr constant [8 x i8] c"hello2\0A\00", align 1
The problem is that llvm-extract changes the linkage (removes the
'private') so that any users left behind can see it. It could get an
option for not doing that I guess.
On 20 November 2012 16:08, Christophe Duvernois
<christophe.duvernois at gmail.com> wrote:
> Hi
>
> I create a simple bytecode file with clang -c -emit-llvm test.c -o test.bc
>
> #include <stdio.h>
> void hello(){
> printf("hello\n");
> }
> void hello2(){
> printf("hello2\n");
> }
>
> Then i want to keep only the hello function so i do :
>
> llvm-extract -func=hello -o test2.bc test.bc
>
> but the string constants are removed and "@.str" is marked as external
> @str = external hidden unnamed_addr constant [6 x i8]
>
> How do you keep the global constant that are used in a function ?
>
> I tried to keep all the .str* with
> llvm-extract -func=hello -rglob=.str* -o toto2.bc toto.bc
>
> The two string are available in the module :
> @.str = private unnamed_addr constant [7 x i8] c"hello\0A\00", align 1
> @.str1 = private unnamed_addr constant [8 x i8] c"hello2\0A\00", align 1
>
> Then i run opt with a global dead code elimination
> opt -globaldce test2.bc -o test3.bc
>
> I still have the two string. ".str1" is not used anymore and shoud have been
> removed?
> Why @.str1 is not removed? Which pass can do that?
>
> Thanks for your clarification.
> Christophe.
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
More information about the llvm-dev
mailing list