<div dir="ltr">Is there a way to distinguish between GlobalValues that are user-defined and those that are compiler-defined? I am looking for a function that I can use to tell if a GlobalValue is user-defined , something like "GlobalValue::isUserDefined", which returns true for user-defined GlobalValue.<div>
<div><br></div><div>I'm trying to make changes to prevent llvm from placing user-defined constant arrays in the merge able constant sections. Currently, clang places 16-byte constant arrays that are marked "unnamed_addr" into __literal16 for macho (see following example).</div>
<div><br></div><div><p style="margin:0px;font-size:11px;font-family:Menlo">$ cat test1.c</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">static const int s_dashArraysSize1[4] = {2, 2, 4, 6};</p>
<p style="margin:0px;font-size:11px;font-family:Menlo;min-height:13px"><br></p>
<p style="margin:0px;font-size:11px;font-family:Menlo">int foo1(int a) {</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"> return s_dashArraysSize1[a]; </p>
<p style="margin:0px;font-size:11px;font-family:Menlo">}</p></div><div><br></div><div><p style="margin:0px;font-size:11px;font-family:Menlo">$ clang test1.c -S -O3 -o - | tail -n 10</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><span class="" style="white-space:pre"> </span>.section<span class="" style="white-space:pre"> </span>__TEXT,__literal16,16byte_literals</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><span class="" style="white-space:pre"> </span>.align<span class="" style="white-space:pre"> </span>4 ## @s_dashArraysSize1</p>
<p style="margin:0px;font-size:11px;font-family:Menlo">_s_dashArraysSize1:</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><span class="" style="white-space:pre"> </span>.long<span class="" style="white-space:pre"> </span>2 ## 0x2</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><span class="" style="white-space:pre"> </span>.long<span class="" style="white-space:pre"> </span>2 ## 0x2</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><span class="" style="white-space:pre"> </span>.long<span class="" style="white-space:pre"> </span>4 ## 0x4</p>
<p style="margin:0px;font-size:11px;font-family:Menlo"><span class="" style="white-space:pre"> </span>.long<span class="" style="white-space:pre"> </span>6 ## 0x6</p><p style="margin:0px;font-size:11px;font-family:Menlo">
<br></p><p style="margin:0px;font-size:11px;font-family:Menlo"><br></p><div>This is not desirable because macho linker wasn't originally designed to handle user-defined symbols in those sections and having to handle them complicates the linker. Also, there is no benefit in doing so, since the linker currently doesn't try to merge user-defined variables anyway.</div>
</div><div><br></div></div></div>