<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span lang=BG style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'>Hi,<o:p></o:p></span></p><p class=MsoNormal><span lang=BG style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=BG style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'>I think I missed the root cause of the problem the previous time. Consider your sample code with a small tweak:<o:p></o:p></span></p><p class=MsoNormal><span lang=BG style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=BG style='font-size:11.0pt;font-family:"Courier New";color:#1F497D'>    extern "C" {<o:p></o:p></span></p><p class=MsoNormal><span lang=BG style='font-size:11.0pt;font-family:"Courier New";color:#1F497D'>    void LLVMInitializeInstCombine(int);<o:p></o:p></span></p><p class=MsoNormal><span lang=BG style='font-size:11.0pt;font-family:"Courier New";color:#1F497D'>    }<o:p></o:p></span></p><p class=MsoNormal><span lang=BG style='font-size:11.0pt;font-family:"Courier New";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=BG style='font-size:11.0pt;font-family:"Courier New";color:#1F497D'>    </span><span lang=BG style='font-size:11.0pt;font-family:"Courier New";color:red'>char *</span><span lang=BG style='font-size:11.0pt;font-family:"Courier New";color:#1F497D'>LLVMInitializeInstCombine(int) {</span><span lang=BG>  </span><span lang=BG style='font-size:11.0pt;font-family:"Courier New";color:#1F497D'>return 0; }<o:p></o:p></span></p><p class=MsoNormal><span lang=BG style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=BG style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'>This will bomb out with <i>error C2556: 'char *LLVMInitializeInstCombine(int)': overloaded function differs only by return type from 'void LLVMInitializeInstCombine(int)'</i> in MSVC<o:p></o:p></span></p><p class=MsoNormal><span lang=BG style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=BG style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'>But when you "tweak" the same way LLVMInitializeInstCombine in InstructionCombining.cpp the LLVMInstCombine project compiles w/ no error.<o:p></o:p></span></p><p class=MsoNormal><span lang=BG style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=BG style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'>So the root cause here seems to be that the .h file with the extern "C" declaration of LLVMInitializeInstCombine is not included in InstructionCombining.cpp source, so a mismatch between declaration vs definition is possible and is actually happening.<o:p></o:p></span></p><p class=MsoNormal><span lang=BG style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=BG style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'>My previous fix works but probably including Initialization.h would be better altogether.<o:p></o:p></span></p><p class=MsoNormal><span lang=BG style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=BG style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'>cheers,<o:p></o:p></span></p><p class=MsoNormal><span lang=BG style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'></wqw><o:p></o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><b><span style='font-size:11.0pt;font-family:"Calibri",sans-serif'>From:</span></b><span style='font-size:11.0pt;font-family:"Calibri",sans-serif'> George Burgess IV [mailto:george.burgess.iv@gmail.com] <br><b>Sent:</b> Wednesday, July 11, 2018 1:56 AM<br><b>To:</b> wqweto@gmail.com<br><b>Cc:</b> llvm-dev <llvm-dev@lists.llvm.org><br><b>Subject:</b> Re: [llvm-dev] A bug-report too difficult to make<o:p></o:p></span></p><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>Hi,<o:p></o:p></p><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>It looks like there's an `extern "C"` declaration in <a href="https://github.com/llvm-mirror/llvm/blob/master/include/llvm-c/Initialization.h#L39" target="_blank">the corresponding header file</a>, which <a href="https://godbolt.org/g/UCZ3qo" target="_blank">appears to be sufficient</a>. All of my attempts to grep for `LLVMInitializeInstCombine` in my build directory are leaving me with unmangled symbols, though I can't say the same for `LLVMInitializeAggressiveInstCombiner`.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>r336736 is an attempt to fix `LLVMInitializeAggressiveInstCombiner`. If I missed something, please let me know. (and if you're still seeing a problem with `LLVMInitializeInstCombine`, more details about your setup/etc. would be appreciated.) :)<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Thanks,<o:p></o:p></p></div><div><p class=MsoNormal>George<o:p></o:p></p></div></div><p class=MsoNormal><o:p> </o:p></p><div><div><p class=MsoNormal>On Tue, Jul 10, 2018 at 7:23 AM Vladimir Vissoultchev via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<o:p></o:p></p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm'><div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=BG>Hi all,</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=BG> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=BG>I just found out that there is an <b>extern "C"</b> missing on the <b>LLVMInitializeInstCombine</b> function definition somewhere around this line:</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><a href="https://github.com/llvm-mirror/llvm/blob/master/lib/Transforms/InstCombine/InstructionCombining.cpp#L3365" target="_blank">https://github.com/llvm-mirror/llvm/blob/master/lib/Transforms/InstCombine/InstructionCombining.cpp#L3365</a><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=BG>As a result the function name gets mangled in the .lib file and is not accessible from LLVM C API.</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=BG> </span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=BG>cheers,</span><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span lang=BG></wqw></span><o:p></o:p></p></div></div><p class=MsoNormal>_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><o:p></o:p></p></blockquote></div></div></body></html>