Hi<div><br></div><div>I create a simple bytecode file with clang -c -emit-llvm test.c -o test.bc</div><div><br></div><div><div>#include <stdio.h></div><div>void hello(){</div><div>        printf("hello\n");</div>


<div>}</div><div>void hello2(){</div><div>        printf("hello2\n");</div><div>}</div></div><div><br></div><div>Then i want to keep only the hello function so i do : </div><div><br></div><div>llvm-extract -func=hello -o test2.bc test.bc </div>


<div><br></div><div>but the string constants are removed and "@.str" is marked as external</div><div><div>@str = external hidden unnamed_addr constant [6 x i8]</div></div><div><br></div><div>How do you keep the global constant that are used in a function ?</div>
<div><br></div><div>I tried to keep all the .str* with</div><div><div>llvm-extract -func=hello -rglob=.str* -o toto2.bc toto.bc </div>

</div><div><br></div><div>The two string are available in the module :</div><div><div>@.str = private unnamed_addr constant [7 x i8] c"hello\0A\00", align 1</div><div><div>@.str1 = private unnamed_addr constant [8 x i8] c"hello2\0A\00", align 1</div>


</div></div><div><br></div><div>Then i run opt with a global dead code elimination </div><div>opt -globaldce test2.bc -o test3.bc</div><div><br></div><div>I still have the two string. ".str1" is not used anymore and shoud have been removed?</div>


<div>Why @.str1 is not removed? Which pass can do that?</div><div><br></div><div><span style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">Thanks for your clarification.</span></div>
<div><span style="color:rgb(34,34,34);font-size:13px;font-family:arial,sans-serif">Christophe.</span></div><div><br></div><div><br></div>