[PATCH] D24670: Fix unresolved linker symbols from misplaced extern definitions

Chuck Atkins via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 21 08:21:59 PDT 2016


chuckatkins updated this revision to Diff 72047.
chuckatkins added a comment.

Fix unresolved linker symbols from un-namespaced extern definitions

When LCSSAID and LoopSimplifyID are declared extern inside a function body,
some linkers will fail to resolve the actual symbols defined in the llvm
namespace.  By removing the function local extern declarations and moving
them to outside the function body, the symbols can be properly resolved.
This is specifically an issue when building with the Intel compiler.


https://reviews.llvm.org/D24670

Files:
  lib/Transforms/Utils/LoopUtils.cpp

Index: lib/Transforms/Utils/LoopUtils.cpp
===================================================================
--- lib/Transforms/Utils/LoopUtils.cpp
+++ lib/Transforms/Utils/LoopUtils.cpp
@@ -929,6 +929,14 @@
   return UsedOutside;
 }
 
+// We locally access their IDs for LoopSimplify and LCSSA here because
+// users shouldn't directly get them from this header.
+namespace llvm
+{
+  extern char &LoopSimplifyID;
+  extern char &LCSSAID;
+}
+
 void llvm::getLoopAnalysisUsage(AnalysisUsage &AU) {
   // By definition, all loop passes need the LoopInfo analysis and the
   // Dominator tree it depends on. Because they all participate in the loop
@@ -938,10 +946,7 @@
   AU.addRequired<LoopInfoWrapperPass>();
   AU.addPreserved<LoopInfoWrapperPass>();
 
-  // We must also preserve LoopSimplify and LCSSA. We locally access their IDs
-  // here because users shouldn't directly get them from this header.
-  extern char &LoopSimplifyID;
-  extern char &LCSSAID;
+  // We must also preserve LoopSimplify and LCSSA.
   AU.addRequiredID(LoopSimplifyID);
   AU.addPreservedID(LoopSimplifyID);
   AU.addRequiredID(LCSSAID);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24670.72047.patch
Type: text/x-patch
Size: 1122 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160921/9776ff17/attachment.bin>


More information about the llvm-commits mailing list