remove the LinkOnceAnyLinkage since the libocl is introduced.
authorLuo Xionghu <xionghu.luo@intel.com>
Tue, 16 Sep 2014 01:40:09 +0000 (09:40 +0800)
committerZhigang Gong <zhigang.gong@intel.com>
Tue, 16 Sep 2014 06:11:54 +0000 (14:11 +0800)
no need to set the LinkOnceAnyLinkage for global variables and functions
to avoid redefinition.

v2:
also enable the VerifierPass.

Signed-off-by: Luo Xionghu <xionghu.luo@intel.com>
Signed-off-by: Zhigang Gong <zhigang.gong@intel.com>
backend/src/backend/gen_program.cpp
backend/src/llvm/llvm_to_gen.cpp

index 44c9c10..d2ad07d 100644 (file)
@@ -365,17 +365,7 @@ namespace gbe {
       ((GenProgram*)dst_program)->module = llvm::CloneModule((llvm::Module*)((GenProgram*)src_program)->module);
       errSize = 0;
     }else{
-      //set the global variables and functions to link once to fix redefine.
       llvm::Module* src = (llvm::Module*)((GenProgram*)src_program)->module;
-      for (llvm::Module::global_iterator I = src->global_begin(), E = src->global_end(); I != E; ++I) {
-        I->setLinkage(llvm::GlobalValue::LinkOnceAnyLinkage);
-      }
-
-      for (llvm::Module::iterator I = src->begin(), E = src->end(); I != E; ++I) {
-        llvm::Function *F = llvm::dyn_cast<llvm::Function>(I);
-        if (F && isKernelFunction(*F)) continue;
-        I->setLinkage(llvm::GlobalValue::LinkOnceAnyLinkage);
-      }
       llvm::Module* dst = (llvm::Module*)((GenProgram*)dst_program)->module;
       llvm::Linker::LinkModules( dst,
                                  src,
index 3690fdd..e31421f 100644 (file)
@@ -86,13 +86,10 @@ namespace gbe
     FPM.add(new DataLayout(DL));
 #endif
 
-    // XXX remove the verifier pass to workaround a non-fatal error.
-    // add this pass cause the Clang abort with the following error message:
-    // "Global is external, but doesn't have external or weak linkage"
 #if LLVM_VERSION_MAJOR == 3 && LLVM_VERSION_MINOR >=5
-    //FPM.add(createVerifierPass(true));
+    FPM.add(createVerifierPass(true));
 #else
-    //FPM.add(createVerifierPass());
+    FPM.add(createVerifierPass());
 #endif
     FPM.add(new TargetLibraryInfo(*libraryInfo));
     FPM.add(createTypeBasedAliasAnalysisPass());