From d17f7739c5d5db38498297103c0b8bf32ce469a3 Mon Sep 17 00:00:00 2001 From: Luo Xionghu Date: Tue, 16 Sep 2014 09:40:09 +0800 Subject: remove the LinkOnceAnyLinkage since the libocl is introduced. no need to set the LinkOnceAnyLinkage for global variables and functions to avoid redefinition. v2: also enable the VerifierPass. Signed-off-by: Luo Xionghu Signed-off-by: Zhigang Gong --- backend/src/backend/gen_program.cpp | 10 ---------- backend/src/llvm/llvm_to_gen.cpp | 7 ++----- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/backend/src/backend/gen_program.cpp b/backend/src/backend/gen_program.cpp index 44c9c102..d2ad07d5 100644 --- a/backend/src/backend/gen_program.cpp +++ b/backend/src/backend/gen_program.cpp @@ -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(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, diff --git a/backend/src/llvm/llvm_to_gen.cpp b/backend/src/llvm/llvm_to_gen.cpp index 3690fdd9..e31421f0 100644 --- a/backend/src/llvm/llvm_to_gen.cpp +++ b/backend/src/llvm/llvm_to_gen.cpp @@ -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()); -- cgit v1.2.3