<br><br>On Wednesday, September 21, 2016, Chuck Atkins <<a href="mailto:chuck.atkins@kitware.com">chuck.atkins@kitware.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi David,<br>
Thanks for taking a look.  Yes, explicitly namespacing the externs<br>
fixes the issue in the same way. The failure is a link error with<br>
undefined references for LoopSimplifyID and LCSSAID in that object<br>
file.<br>
<br>
../../lib/<wbr>libLLVMTransformUtils.a(<wbr>LoopUtils.cpp.o): In function<br>
`llvm::getLoopAnalysisUsage(<wbr>llvm::AnalysisUsage&)':<br>
LoopUtils.cpp:(.text+0x33dd): undefined reference to `LoopSimplifyID'<br>
LoopUtils.cpp:(.text+0x3410): undefined reference to `LCSSAID'<br>
<br>
 Is there a reason to use a locally defined extern definition instead<br>
of pulling it in from the header it already resides in?</blockquote><div><br></div><div>The comment block above the declaration explicitly says that it shouldn't bring in the header.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
- Chuck<br>
<br>
On Tue, Sep 20, 2016 at 7:16 PM, David Majnemer<br>
<<a href="javascript:;" onclick="_e(event, 'cvml', 'david.majnemer@gmail.com')">david.majnemer@gmail.com</a>> wrote:<br>
><br>
><br>
> On Tue, Sep 20, 2016 at 3:55 PM, David Majnemer <<a href="javascript:;" onclick="_e(event, 'cvml', 'david.majnemer@gmail.com')">david.majnemer@gmail.com</a>><br>
> wrote:<br>
>><br>
>><br>
>><br>
>> On Fri, Sep 16, 2016 at 8:15 AM, Chuck Atkins via llvm-commits<br>
>> <<a href="javascript:;" onclick="_e(event, 'cvml', 'llvm-commits@lists.llvm.org')">llvm-commits@lists.llvm.org</a>> wrote:<br>
>>><br>
>>> ping?<br>
>>><br>
>>> Anybody mind taking a look at this patch?  It's fairly trivial; but<br>
>>> without it, builds with the Intel compiler fail.<br>
>><br>
>><br>
>> What is the failure mode?<br>
><br>
><br>
><br>
> Out of curiosity, does the following make ICC any happier:<br>
><br>
> diff --git a/lib/Transforms/Utils/<wbr>LoopUtils.cpp<br>
> b/lib/Transforms/Utils/<wbr>LoopUtils.cpp<br>
> index 8878689..1b2a2d6 100644<br>
> --- a/lib/Transforms/Utils/<wbr>LoopUtils.cpp<br>
> +++ b/lib/Transforms/Utils/<wbr>LoopUtils.cpp<br>
> @@ -929,6 +929,13 @@ SmallVector<Instruction *, 8><br>
> llvm::<wbr>findDefsUsedOutsideOfLoop(Loop *L) {<br>
>    return UsedOutside;<br>
>  }<br>
><br>
> +// We locally access their IDs here because users shouldn't directly get<br>
> them<br>
> +// from this header.<br>
> +namespace llvm {<br>
> +extern char &LoopSimplifyID;<br>
> +extern char &LCSSAID;<br>
> +}<br>
> +<br>
>  void llvm::getLoopAnalysisUsage(<wbr>AnalysisUsage &AU) {<br>
>    // By definition, all loop passes need the LoopInfo analysis and the<br>
>    // Dominator tree it depends on. Because they all participate in the loop<br>
> @@ -938,10 +945,7 @@ void llvm::getLoopAnalysisUsage(<wbr>AnalysisUsage &AU) {<br>
>    AU.addRequired<<wbr>LoopInfoWrapperPass>();<br>
>    AU.addPreserved<<wbr>LoopInfoWrapperPass>();<br>
><br>
> -  // We must also preserve LoopSimplify and LCSSA. We locally access their<br>
> IDs<br>
> -  // here because users shouldn't directly get them from this header.<br>
> -  extern char &LoopSimplifyID;<br>
> -  extern char &LCSSAID;<br>
> +  // We must also preserve LoopSimplify and LCSSA.<br>
>    AU.addRequiredID(<wbr>LoopSimplifyID);<br>
>    AU.addPreservedID(<wbr>LoopSimplifyID);<br>
>    AU.addRequiredID(LCSSAID);<br>
><br>
><br>
>><br>
>><br>
>>><br>
>>><br>
>>> On Tue, Sep 13, 2016 at 11:38 AM, Chuck Atkins <<a href="javascript:;" onclick="_e(event, 'cvml', 'chuck.atkins@kitware.com')">chuck.atkins@kitware.com</a>><br>
>>> wrote:<br>
>>>><br>
>>>> When LCSSAID and LoopSimplifyID are declared extern inside a function<br>
>>>> body,<br>
>>>> some linkers will fail to resolve the actual symbols defined in the llvm<br>
>>>> namespace.  By removing the function local extern declarations and<br>
>>>> relying<br>
>>>> on the header definitions in Scalar.h, the symbols can be properly<br>
>>>> reolved.<br>
>>>> This is specifically an issue when building with the Intel compiler.<br>
>>>> ---<br>
>>>>  lib/Transforms/Utils/<wbr>LoopUtils.cpp | 3 +--<br>
>>>>  1 file changed, 1 insertion(+), 2 deletions(-)<br>
>>>><br>
>>>> diff --git a/lib/Transforms/Utils/<wbr>LoopUtils.cpp<br>
>>>> b/lib/Transforms/Utils/<wbr>LoopUtils.cpp<br>
>>>> index 3902c67..9a1cd0b 100644<br>
>>>> --- a/lib/Transforms/Utils/<wbr>LoopUtils.cpp<br>
>>>> +++ b/lib/Transforms/Utils/<wbr>LoopUtils.cpp<br>
>>>> @@ -26,6 +26,7 @@<br>
>>>>  #include "llvm/IR/ValueHandle.h"<br>
>>>>  #include "llvm/Pass.h"<br>
>>>>  #include "llvm/Support/Debug.h"<br>
>>>> +#include "llvm/Transforms/Scalar.h"<br>
>>>>  #include "llvm/Transforms/Utils/<wbr>LoopUtils.h"<br>
>>>><br>
>>>>  using namespace llvm;<br>
>>>> @@ -845,8 +846,6 @@ void llvm::getLoopAnalysisUsage(<wbr>AnalysisUsage &AU) {<br>
>>>><br>
>>>>    // We must also preserve LoopSimplify and LCSSA. We locally access<br>
>>>> their IDs<br>
>>>>    // here because users shouldn't directly get them from this header.<br>
>>>> -  extern char &LoopSimplifyID;<br>
>>>> -  extern char &LCSSAID;<br>
>>>>    AU.addRequiredID(<wbr>LoopSimplifyID);<br>
>>>>    AU.addPreservedID(<wbr>LoopSimplifyID);<br>
>>>>    AU.addRequiredID(LCSSAID);<br>
>>>> --<br>
>>>> 2.7.4<br>
>>>><br>
>>><br>
>>><br>
>>> ______________________________<wbr>_________________<br>
>>> llvm-commits mailing list<br>
>>> <a href="javascript:;" onclick="_e(event, 'cvml', 'llvm-commits@lists.llvm.org')">llvm-commits@lists.llvm.org</a><br>
>>> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
>>><br>
>><br>
><br>
</blockquote>