From 24ab8362f2099ed42f2e05f09fb9323ad0c5ab27 Mon Sep 17 00:00:00 2001 From: Alex Zinenko Date: Wed, 18 Dec 2019 09:04:42 -0800 Subject: [PATCH] Move function template definition to the header file. NFC The definition of the function template LLVM::ModuleTranslation::lookupValues has been located in a source file. As long as it has been the only file that actually called into the function, this did not cause any problem. However, it creates linking issues if the function is used from other translation units. PiperOrigin-RevId: 286203078 --- mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h | 10 +++++++++- mlir/lib/Target/LLVMIR/ModuleTranslation.cpp | 11 ----------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h index 2889012..0b65218 100644 --- a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h +++ b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h @@ -87,8 +87,16 @@ protected: llvm::IRBuilder<> &builder); static std::unique_ptr prepareLLVMModule(Operation *m); + // A helper to look up remapped operands in the value remapping table. template - SmallVector lookupValues(Range &&values); + SmallVector lookupValues(Range &&values) { + SmallVector remapped; + remapped.reserve(llvm::size(values)); + for (Value *v : values) { + remapped.push_back(valueMapping.lookup(v)); + } + return remapped; + } private: /// Check whether the module contains only supported ops directly in its body. diff --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp index f5f9cca..7a7964d 100644 --- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp @@ -159,17 +159,6 @@ static llvm::CmpInst::Predicate getLLVMCmpPredicate(FCmpPredicate p) { llvm_unreachable("incorrect comparison predicate"); } -// A helper to look up remapped operands in the value remapping table. -template -SmallVector ModuleTranslation::lookupValues(Range &&values) { - SmallVector remapped; - remapped.reserve(llvm::size(values)); - for (Value *v : values) { - remapped.push_back(valueMapping.lookup(v)); - } - return remapped; -} - // Given a single MLIR operation, create the corresponding LLVM IR operation // using the `builder`. LLVM IR Builder does not have a generic interface so // this has to be a long chain of `if`s calling different functions with a -- 2.7.4