[PATCH] Fix unresolved linker symbols from misplaced extern definitions

Chuck Atkins via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 13 08:38:13 PDT 2016


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 relying
on the header definitions in Scalar.h, the symbols can be properly reolved.
This is specifically an issue when building with the Intel compiler.
---
 lib/Transforms/Utils/LoopUtils.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/Transforms/Utils/LoopUtils.cpp b/lib/Transforms/Utils/LoopUtils.cpp
index 3902c67..9a1cd0b 100644
--- a/lib/Transforms/Utils/LoopUtils.cpp
+++ b/lib/Transforms/Utils/LoopUtils.cpp
@@ -26,6 +26,7 @@
 #include "llvm/IR/ValueHandle.h"
 #include "llvm/Pass.h"
 #include "llvm/Support/Debug.h"
+#include "llvm/Transforms/Scalar.h"
 #include "llvm/Transforms/Utils/LoopUtils.h"
 
 using namespace llvm;
@@ -845,8 +846,6 @@ void llvm::getLoopAnalysisUsage(AnalysisUsage &AU) {
 
   // 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;
   AU.addRequiredID(LoopSimplifyID);
   AU.addPreservedID(LoopSimplifyID);
   AU.addRequiredID(LCSSAID);
-- 
2.7.4



More information about the llvm-commits mailing list