<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - ARM FastIsel is renaming the memcpy to memcpy.<random-number> in getLibcallReg()."
   href="https://bugs.llvm.org/show_bug.cgi?id=43202">43202</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>ARM FastIsel  is renaming the memcpy to memcpy.<random-number> in getLibcallReg().
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>LLVM Codegen
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>umesh.kalappa0@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=22461" name="attach_22461" title="testcase">attachment 22461</a> <a href="attachment.cgi?id=22461&action=edit" title="testcase">[details]</a></span>
testcase

The attached file compiled like 

clang --target=arm-linux-eabi -mcpu=cortex-a9  -w -fno-builtin  -mlong-calls
testcase.cpp -c; nm testcase.o | grep memcpy
         U memcpy
         U memcpy.202
         U memcpy.203
         U memcpy.204

results with linker  undefined symbols error .

When we investigated why the codegen renames it ,the following code
ARMFastISel.cpp @ getLibcallReg  do so.

<span class="quote">>>GlobalValue *GV = new GlobalVariable(M, Type::getInt32Ty(*Context), false,</span >
                                        GlobalValue::ExternalLinkage, nullptr,
                                        Name);

where "Name=memcpy" in this case and GlobalVariable creates new instance with
"Name" if doesn't exist in the module table ,else its renames with appending
the random number to "Name".

But its not the semantics we required here ,hence we modified the code like 

<span class="quote">>>GlobalValue *GV = cast <GlobalVariable>(M.getOrInsertGlobal(Name.getSingleStringRef(), Type::getInt32Ty(*Context)));</span >

where we used Module.getOrInsertGlobal () instead and getOrInsertGlobal()
creates new instance with "Name" if doesn't exist ,else returns the exist one .</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>