forced module name & ptx string to be generaetd nly once
This commit is contained in:
21
ctx.cpp
21
ctx.cpp
@@ -3682,12 +3682,12 @@ FunctionEmitContext::LaunchInst(llvm::Value *callee,
|
|||||||
|
|
||||||
args.push_back(launchGroupHandlePtr); /* void **handler */
|
args.push_back(launchGroupHandlePtr); /* void **handler */
|
||||||
|
|
||||||
/* module name string to distinguish between different modules */
|
/* module name string to distinguish between different modules , generated ones */
|
||||||
{
|
{
|
||||||
const std::string moduleNameStr = m->module->getModuleIdentifier();
|
const std::string moduleNameStr = m->module->getModuleIdentifier();
|
||||||
llvm::ArrayType* ArrayTyModuleName = llvm::ArrayType::get(llvm::IntegerType::get(*g->ctx, 8), moduleNameStr.size()+1);
|
static llvm::ArrayType* ArrayTyModuleName = llvm::ArrayType::get(llvm::IntegerType::get(*g->ctx, 8), moduleNameStr.size()+1);
|
||||||
|
|
||||||
llvm::GlobalVariable* gvarModuleNameStr = new llvm::GlobalVariable(
|
static llvm::GlobalVariable* gvarModuleNameStr = new llvm::GlobalVariable(
|
||||||
/*Module=*/ *m->module,
|
/*Module=*/ *m->module,
|
||||||
/*Type=*/ ArrayTyModuleName,
|
/*Type=*/ ArrayTyModuleName,
|
||||||
/*isConstant=*/ true,
|
/*isConstant=*/ true,
|
||||||
@@ -3696,23 +3696,22 @@ FunctionEmitContext::LaunchInst(llvm::Value *callee,
|
|||||||
/*Name=*/ ".module_str");
|
/*Name=*/ ".module_str");
|
||||||
//gvarModuleNameStr->setAlignment(1);
|
//gvarModuleNameStr->setAlignment(1);
|
||||||
|
|
||||||
llvm::Constant *constModuleName= llvm::ConstantDataArray::getString(*g->ctx, moduleNameStr.c_str(), true);
|
static llvm::Constant *constModuleName= llvm::ConstantDataArray::getString(*g->ctx, moduleNameStr.c_str(), true);
|
||||||
gvarModuleNameStr->setInitializer(constModuleName);
|
gvarModuleNameStr->setInitializer(constModuleName);
|
||||||
|
|
||||||
std::vector<llvm::Constant*> const_ptr_12_indices;
|
std::vector<llvm::Constant*> const_ptr_12_indices;
|
||||||
const_ptr_12_indices.push_back(llvm::Constant::getNullValue(llvm::Type::getInt32Ty(*g->ctx)));
|
const_ptr_12_indices.push_back(llvm::Constant::getNullValue(llvm::Type::getInt32Ty(*g->ctx)));
|
||||||
const_ptr_12_indices.push_back(llvm::ConstantInt::get(llvm::Type::getInt32Ty(*g->ctx),0));
|
const_ptr_12_indices.push_back(llvm::ConstantInt::get(llvm::Type::getInt32Ty(*g->ctx),0));
|
||||||
llvm::Constant* const_ptr_12 = llvm::ConstantExpr::getGetElementPtr(gvarModuleNameStr, const_ptr_12_indices);
|
static llvm::Constant* const_ptr_12 = llvm::ConstantExpr::getGetElementPtr(gvarModuleNameStr, const_ptr_12_indices);
|
||||||
args.push_back(const_ptr_12); /* const char * module_name */
|
args.push_back(const_ptr_12); /* const char * module_name */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ptx string, must be created ones */
|
/* ptx string, quick hack with "static" to create only single string.. the must be a better way */
|
||||||
{
|
{
|
||||||
const std::string moduleNameStr = g->PtxString;
|
const std::string moduleNameStr = g->PtxString;
|
||||||
g->PtxString.clear();
|
static llvm::ArrayType* ArrayTyModuleName = llvm::ArrayType::get(llvm::IntegerType::get(*g->ctx, 8), moduleNameStr.size()+1);
|
||||||
llvm::ArrayType* ArrayTyModuleName = llvm::ArrayType::get(llvm::IntegerType::get(*g->ctx, 8), moduleNameStr.size()+1);
|
|
||||||
|
|
||||||
llvm::GlobalVariable* gvarModuleNameStr = new llvm::GlobalVariable(
|
static llvm::GlobalVariable* gvarModuleNameStr = new llvm::GlobalVariable(
|
||||||
/*Module=*/ *m->module,
|
/*Module=*/ *m->module,
|
||||||
/*Type=*/ ArrayTyModuleName,
|
/*Type=*/ ArrayTyModuleName,
|
||||||
/*isConstant=*/ true,
|
/*isConstant=*/ true,
|
||||||
@@ -3720,13 +3719,13 @@ FunctionEmitContext::LaunchInst(llvm::Value *callee,
|
|||||||
/*Initializer=*/ 0, // has initializer, specified below
|
/*Initializer=*/ 0, // has initializer, specified below
|
||||||
/*Name=*/ ".ptx_str");
|
/*Name=*/ ".ptx_str");
|
||||||
|
|
||||||
llvm::Constant *constModuleName= llvm::ConstantDataArray::getString(*g->ctx, moduleNameStr.c_str(), true);
|
static llvm::Constant *constModuleName= llvm::ConstantDataArray::getString(*g->ctx, moduleNameStr.c_str(), true);
|
||||||
gvarModuleNameStr->setInitializer(constModuleName);
|
gvarModuleNameStr->setInitializer(constModuleName);
|
||||||
|
|
||||||
std::vector<llvm::Constant*> const_ptr_12_indices;
|
std::vector<llvm::Constant*> const_ptr_12_indices;
|
||||||
const_ptr_12_indices.push_back(llvm::Constant::getNullValue(llvm::Type::getInt32Ty(*g->ctx)));
|
const_ptr_12_indices.push_back(llvm::Constant::getNullValue(llvm::Type::getInt32Ty(*g->ctx)));
|
||||||
const_ptr_12_indices.push_back(llvm::ConstantInt::get(llvm::Type::getInt32Ty(*g->ctx),0));
|
const_ptr_12_indices.push_back(llvm::ConstantInt::get(llvm::Type::getInt32Ty(*g->ctx),0));
|
||||||
llvm::Constant* const_ptr_12 = llvm::ConstantExpr::getGetElementPtr(gvarModuleNameStr, const_ptr_12_indices);
|
static llvm::Constant* const_ptr_12 = llvm::ConstantExpr::getGetElementPtr(gvarModuleNameStr, const_ptr_12_indices);
|
||||||
args.push_back(const_ptr_12); /* const char * module_name */
|
args.push_back(const_ptr_12); /* const char * module_name */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user