提交 d7fb2f6d 编写于 作者: S Shreedhar Hardikar

Fix codegen unittests on Linux and various compiler warnings while building codegen.

上级 dea16d7d
......@@ -55,6 +55,12 @@ if (COMPILER_HAS_WNO_C99_EXTENSIONS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-conversion-null")
endif()
# Suppress warnings about deprecated keyword register
CHECK_CXX_COMPILER_FLAG("-Wno-deprecated-register" COMPILER_HAS_WNO_C99_EXTENSIONS)
if (COMPILER_HAS_WNO_C99_EXTENSIONS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-register")
endif()
# Turn on the CODEGEN_DEBUG flag if this is a debug build.
if (CMAKE_MAJOR_VERSION GREATER 2)
cmake_policy(SET CMP0043 NEW)
......@@ -304,7 +310,6 @@ endif()
if(EXISTS ${TXT_OBJFILE})
add_cmockery_gtest(codegen_framework_unittest.t
tests/codegen_framework_unittest.cc
${MOCK_DIR}/backend/utils/error/elog_mock.o
)
endif()
......
......@@ -76,11 +76,7 @@ bool ExecEvalExprCodegen::GenerateExecEvalExpr(
codegen_utils, GetUniqueFuncName());
// Function arguments to ExecVariableList
llvm::Value* llvm_expression_arg =
ArgumentByPosition(exec_eval_expr_func, 0);
llvm::Value* llvm_econtext_arg = ArgumentByPosition(exec_eval_expr_func, 1);
llvm::Value* llvm_isnull_arg = ArgumentByPosition(exec_eval_expr_func, 2);
llvm::Value* llvm_isDone_arg = ArgumentByPosition(exec_eval_expr_func, 3);
// BasicBlock of function entry.
llvm::BasicBlock* llvm_entry_block = codegen_utils->CreateBasicBlock(
......
......@@ -161,9 +161,6 @@ bool ExecVariableListCodegen::GenerateExecVariableList(
llvm::Value* llvm_econtext =
irb->CreateLoad(codegen_utils->GetPointerToMember(
llvm_projInfo_arg, &ProjectionInfo::pi_exprContext));
llvm::Value* llvm_varSlotOffsets =
irb->CreateLoad(codegen_utils->GetPointerToMember(
llvm_projInfo_arg, &ProjectionInfo::pi_varSlotOffsets));
// We want to fall back when ExecVariableList is called with a slot that's
// different from the one we generated the function (eg HashJoin). We also
......@@ -325,7 +322,7 @@ bool ExecVariableListCodegen::GenerateExecVariableList(
// Create the block of (attnum+1)th attribute and jump to it after
// you finish with current attribute.
next_attribute_block = codegen_utils->CreateBasicBlock(
"attribute_block_"+(attnum+1), exec_variable_list_func);
"attribute_block_" + std::to_string(attnum+1), exec_variable_list_func);
llvm::Value* llvm_next_values_ptr =
irb->CreateInBoundsGEP(llvm_slot_PRIVATE_tts_values,
......@@ -336,9 +333,10 @@ bool ExecVariableListCodegen::GenerateExecVariableList(
if (!thisatt->attnotnull) {
// Create blocks
is_null_block = codegen_utils->CreateBasicBlock(
"is_null_block_"+attnum, exec_variable_list_func);
"is_null_block_" + std::to_string(attnum), exec_variable_list_func);
is_not_null_block = codegen_utils->CreateBasicBlock(
"is_not_null_block_"+attnum, exec_variable_list_func);
"is_not_null_block_" + std::to_string(attnum),
exec_variable_list_func);
llvm::Value* llvm_attnum = codegen_utils->GetConstant(attnum);
......
......@@ -93,11 +93,10 @@ class ExprTreeGenerator {
**/
ExprTreeGenerator(ExprState* expr_state,
ExprTreeNodeType node_type) :
expr_state_(expr_state), node_type_(node_type) {}
expr_state_(expr_state) {}
private:
ExprState* expr_state_;
ExprTreeNodeType node_type_;
DISALLOW_COPY_AND_ASSIGN(ExprTreeGenerator);
};
......
......@@ -33,7 +33,7 @@ namespace gpcodegen {
* @return A pointer to the specified argument, or NULL if the specified
* position was beyond the end of function's arguments.
**/
static llvm::Argument* ArgumentByPosition(llvm::Function* function,
static inline llvm::Argument* ArgumentByPosition(llvm::Function* function,
const unsigned position) {
llvm::Function::arg_iterator it = function->arg_begin();
if (it == function->arg_end()) {
......
......@@ -92,7 +92,8 @@ bool OpExprTreeGenerator::VerifyAndCreateExprTree(
List *arguments = reinterpret_cast<FuncExprState*>(expr_state)->args;
assert(nullptr != arguments);
// In ExecEvalFuncArgs
assert(list_length(arguments) == itr->second->GetTotalArgCount());
assert(list_length(arguments) ==
static_cast<int>(itr->second->GetTotalArgCount()));
ListCell *arg = nullptr;
bool supported_tree = true;
......
......@@ -48,7 +48,7 @@
extern "C" {
#include "utils/elog.h"
#undef elog
#define elog
#define elog(...)
}
#include "codegen/utils/codegen_utils.h"
......
......@@ -1076,7 +1076,7 @@ class CodegenUtilsTest : public ::testing::Test {
InputType* input = new InputType[input_size];
for (size_t idx = 0; idx < input_size; ++idx) {
unsigned int seed = idx;
input[idx] = rand_r(&seed) % (2 ^ (sizeof(InputType) * 8) - 1);
input[idx] = rand_r(&seed) % ((2 ^ (sizeof(InputType) * 8)) - 1);
}
return input;
}
......@@ -2754,12 +2754,12 @@ TEST_F(CodegenUtilsTest, GetOrGetOrRegisterExternalFunctionTest) {
EXPECT_EQ(expected_fabs_func, fabs_func);
// Test previously registered vararg function
llvm::Function* expected_vprintf_func = codegen_utils_->
GetOrRegisterExternalFunction(vprintf);
llvm::Function* vprintf_func = codegen_utils_->
GetOrRegisterExternalFunction(vprintf);
llvm::Function* expected_fprintf_func = codegen_utils_->
GetOrRegisterExternalFunction(fprintf);
llvm::Function* fprintf_func = codegen_utils_->
GetOrRegisterExternalFunction(fprintf);
EXPECT_EQ(expected_vprintf_func, vprintf_func);
EXPECT_EQ(expected_fprintf_func, fprintf_func);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册