From dcfa59b8c32e44bcd16fbd58ce91e7d3f332be36 Mon Sep 17 00:00:00 2001 From: Sanjoy Das Date: Tue, 13 Feb 2018 14:55:24 -0800 Subject: [PATCH] Change linkage type of modules to external after dropping initializers It isn't legal to have private global variables without initializers. In the current state the -noconst.ll LLVM IR cannot be passed to opt. PiperOrigin-RevId: 185593073 --- tensorflow/compiler/xla/service/llvm_ir/llvm_util.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tensorflow/compiler/xla/service/llvm_ir/llvm_util.cc b/tensorflow/compiler/xla/service/llvm_ir/llvm_util.cc index 15a4cf8..22141e7 100644 --- a/tensorflow/compiler/xla/service/llvm_ir/llvm_util.cc +++ b/tensorflow/compiler/xla/service/llvm_ir/llvm_util.cc @@ -20,6 +20,7 @@ limitations under the License. #include #include "llvm/IR/DerivedTypes.h" +#include "llvm/IR/GlobalValue.h" #include "llvm/IR/MDBuilder.h" #include "llvm/IR/Operator.h" #include "llvm/Target/TargetOptions.h" @@ -67,6 +68,7 @@ std::unique_ptr DropConstantInitializers( std::unique_ptr cloned_module = CloneModule(&module); for (llvm::GlobalVariable& global_var : cloned_module->globals()) { global_var.setInitializer(nullptr); + global_var.setLinkage(llvm::GlobalValue::LinkageTypes::ExternalLinkage); } return cloned_module; } -- 2.7.4