From 9f469dcfec806f44cd41e9a6c67a359fb29cd0c9 Mon Sep 17 00:00:00 2001 From: akashk4 <akashk4@illinois.edu> Date: Wed, 8 Jan 2020 12:27:24 -0600 Subject: [PATCH] Updating with apt changes to function declaration types to Function Callee --- .../Transforms/DFG2LLVM_X86/DFG2LLVM_X86.cpp | 98 +++++++++---------- 1 file changed, 45 insertions(+), 53 deletions(-) diff --git a/hpvm/lib/Transforms/DFG2LLVM_X86/DFG2LLVM_X86.cpp b/hpvm/lib/Transforms/DFG2LLVM_X86/DFG2LLVM_X86.cpp index 4823c8039d..667efbba7d 100644 --- a/hpvm/lib/Transforms/DFG2LLVM_X86/DFG2LLVM_X86.cpp +++ b/hpvm/lib/Transforms/DFG2LLVM_X86/DFG2LLVM_X86.cpp @@ -73,29 +73,29 @@ class CGT_X86 : public CodeGenTraversal { private: //Member variables - Constant* malloc; + FunctionCallee malloc; // VISC Runtime API - Constant* llvm_visc_x86_launch; - Constant* llvm_visc_x86_wait; - Constant* llvm_visc_x86_argument_ptr; - - Constant* llvm_visc_streamLaunch; - Constant* llvm_visc_streamPush; - Constant* llvm_visc_streamPop; - Constant* llvm_visc_streamWait; - Constant* llvm_visc_createBindInBuffer; - Constant* llvm_visc_createBindOutBuffer; - Constant* llvm_visc_createEdgeBuffer; - Constant* llvm_visc_createLastInputBuffer; - Constant* llvm_visc_createThread; + FunctionCallee llvm_visc_x86_launch; + FunctionCallee llvm_visc_x86_wait; + FunctionCallee llvm_visc_x86_argument_ptr; + + FunctionCallee llvm_visc_streamLaunch; + FunctionCallee llvm_visc_streamPush; + FunctionCallee llvm_visc_streamPop; + FunctionCallee llvm_visc_streamWait; + FunctionCallee llvm_visc_createBindInBuffer; + FunctionCallee llvm_visc_createBindOutBuffer; + FunctionCallee llvm_visc_createEdgeBuffer; + FunctionCallee llvm_visc_createLastInputBuffer; + FunctionCallee llvm_visc_createThread; //Constant* llvm_visc_freeThreads; - Constant* llvm_visc_bufferPush; - Constant* llvm_visc_bufferPop; - Constant* llvm_visc_x86_dstack_push; - Constant* llvm_visc_x86_dstack_pop; - Constant* llvm_visc_x86_getDimLimit; - Constant* llvm_visc_x86_getDimInstance; - + FunctionCallee llvm_visc_bufferPush; + FunctionCallee llvm_visc_bufferPop; + FunctionCallee llvm_visc_x86_dstack_push; + FunctionCallee llvm_visc_x86_dstack_pop; + FunctionCallee llvm_visc_x86_getDimLimit; + FunctionCallee llvm_visc_x86_getDimInstance; + //Functions std::vector<IntrinsicInst*>* getUseList(Value* LI); Value* addLoop(Instruction* I, Value* limit, const Twine& indexName = ""); @@ -227,17 +227,16 @@ void CGT_X86::initRuntimeAPI() { initializeTimerSet(I); switchToTimer(visc_TimerID_NONE, I); // Insert code for initializing the sceduling policy - Function *IP = cast<Function>(M.getOrInsertFunction("llvm_visc_policy_init", - runtimeModule->getFunction("llvm_visc_policy_init")->getFunctionType())); + FunctionCallee IP = M.getOrInsertFunction("llvm_visc_policy_init", + runtimeModule->getFunction("llvm_visc_policy_init")->getFunctionType()); CallInst *IPCallInst = CallInst::Create(IP, ArrayRef<Value*>(), "", I); DEBUG(errs() << *IPCallInst << "\n"); // If device abstraction is enabled, we add a runtime call to start the // device status simulation if (DeviceAbstraction) { - Function *ID = - cast<Function>(M.getOrInsertFunction("llvm_visc_deviceAbstraction_start", - runtimeModule->getFunction("llvm_visc_deviceAbstraction_start")->getFunctionType())); + FunctionCallee ID = M.getOrInsertFunction("llvm_visc_deviceAbstraction_start", + runtimeModule->getFunction("llvm_visc_deviceAbstraction_start")->getFunctionType()); CallInst *IDCallInst = CallInst::Create(ID, ArrayRef<Value*>(), "", I); DEBUG(errs() << *IDCallInst << "\n"); } @@ -248,8 +247,8 @@ void CGT_X86::initRuntimeAPI() { // Insert code for clearing the sceduling policy I = cast<Instruction>(*VC->user_begin()); - IP = cast<Function>(M.getOrInsertFunction("llvm_visc_policy_clear", - runtimeModule->getFunction("llvm_visc_policy_clear")->getFunctionType())); + IP = M.getOrInsertFunction("llvm_visc_policy_clear", + runtimeModule->getFunction("llvm_visc_policy_clear")->getFunctionType()); IPCallInst = CallInst::Create(IP, ArrayRef<Value*>(), "", I); errs() << *IPCallInst << "\n"; @@ -259,9 +258,8 @@ void CGT_X86::initRuntimeAPI() { // If device abstraction is enabled, we add a runtime call to end the // device status simulation if (DeviceAbstraction) { - Function *ID = - cast<Function>(M.getOrInsertFunction("llvm_visc_deviceAbstraction_end", - runtimeModule->getFunction("llvm_visc_deviceAbstraction_end")->getFunctionType())); + FunctionCallee ID = M.getOrInsertFunction("llvm_visc_deviceAbstraction_end", + runtimeModule->getFunction("llvm_visc_deviceAbstraction_end")->getFunctionType()); CallInst *IDCallInst = CallInst::Create(ID, ArrayRef<Value*>(), "", I); DEBUG(errs() << *IDCallInst << "\n"); } @@ -277,14 +275,7 @@ std::vector<IntrinsicInst*>* CGT_X86::getUseList(Value* GraphID) { ue = GraphID->user_end(); ui!=ue; ++ui) { if(IntrinsicInst* waitI = dyn_cast<IntrinsicInst>(*ui)) { UseList->push_back(waitI); - } - //else if (PHINode* PN = dyn_cast<PHINode>(*ui)){ - //errs() << "Found PhiNode use of graphID\n"; - //std::vector<IntrinsicInst*>* phiUseList = getUseList(PN); - //UseList->insert(UseList->end(), phiUseList->begin(), phiUseList->end()); - //free(phiUseList); - //} - else { + } else { llvm_unreachable("Error: Operation on Graph ID not supported!\n"); } } @@ -584,7 +575,8 @@ Function* CGT_X86::createLaunchFunction(DFInternalNode* N) { DEBUG(errs() << "Generating Code for Streaming Launch Function\n"); // Give a name to the argument which is used pass data to this thread Argument* data = &*LaunchFunc->arg_begin(); - Argument* graphID = &*(++LaunchFunc->arg_begin()); + // NOTE-HS: Check correctness with Maria + Argument* graphID = &*(LaunchFunc->arg_begin() + 1); data->setName("data.addr"); graphID->setName("graphID"); // Add a basic block to this empty function and a return null statement to it @@ -1508,10 +1500,10 @@ void CGT_X86::codeGen(DFInternalNode* N) { // its first statement BasicBlock *BB = &*NodeGenFunc->begin(); std::vector<Value *> Args; // TODO: add the device type as argument? - Function *RTF = - cast<Function>(M.getOrInsertFunction("llvm_visc_deviceAbstraction_waitOnDeviceStatus", - runtimeModule->getFunction("llvm_visc_deviceAbstraction_waitOnDeviceStatus")->getFunctionType())); - CallInst *RTFInst = CallInst::Create(RTF, Args, "", BB->getFirstNonPHI()); + FunctionCallee RTF = + M.getOrInsertFunction("llvm_visc_deviceAbstraction_waitOnDeviceStatus", + runtimeModule->getFunction("llvm_visc_deviceAbstraction_waitOnDeviceStatus")->getFunctionType()); + CallInst *RTFInst = CallInst::Create(RTF, Args, "", BB->getFirstNonPHI()); } } @@ -1606,7 +1598,7 @@ void CGT_X86::codeGen(DFInternalNode* N) { NameV.push_back(ConstantInt::get(Type::getInt8Ty(M.getContext()), '\0')); ArrayType *NameType = ArrayType::get(IntegerType::get(M.getContext(), 8), nameSize); - AllocaInst *AI = new AllocaInst(NameType, nullptr, "", BBcurrent); + AllocaInst *AI = new AllocaInst(NameType, 0, nullptr, "", BBcurrent); Constant *NameConst = ConstantArray::get(NameType, NameV); StoreInst *StI = new StoreInst(NameConst, AI, BBcurrent); CastInst *BI = BitCastInst::CreatePointerCast(AI, @@ -1614,9 +1606,9 @@ void CGT_X86::codeGen(DFInternalNode* N) { std::vector<Value *> Args; Args.push_back(BI); Args.push_back(ConstantInt::get(Type::getInt64Ty(M.getContext()), -1, true)); - Function *RTF = - cast<Function>(M.getOrInsertFunction("llvm_visc_policy_getVersion", - runtimeModule->getFunction("llvm_visc_policy_getVersion")->getFunctionType())); + FunctionCallee RTF = + M.getOrInsertFunction("llvm_visc_policy_getVersion", + runtimeModule->getFunction("llvm_visc_policy_getVersion")->getFunctionType()); CallInst *RTFInst = CallInst::Create(RTF, Args, "", BBcurrent); ConstantInt *CmpConst = @@ -1651,9 +1643,9 @@ void CGT_X86::codeGen(DFInternalNode* N) { if (DeviceAbstraction) { // Prepare arguments and function for call to wait for device runtime call std::vector<Value *> Args; // TODO: add the device type as argument? - Function *RTF = - cast<Function>(M.getOrInsertFunction("llvm_visc_deviceAbstraction_waitOnDeviceStatus", - runtimeModule->getFunction("llvm_visc_deviceAbstraction_waitOnDeviceStatus")->getFunctionType())); + FunctionCallee RTF = + M.getOrInsertFunction("llvm_visc_deviceAbstraction_waitOnDeviceStatus", + runtimeModule->getFunction("llvm_visc_deviceAbstraction_waitOnDeviceStatus")->getFunctionType()); CallInst *RTFInst = CallInst::Create(RTF, Args, "", GenFuncCI); } } @@ -1677,8 +1669,8 @@ void CGT_X86::codeGen(DFInternalNode* N) { // Prepare arguments and function for call to wait for device runtime call std::vector<Value *> Args; // TODO: add the device type as argument? Function *RTF = - cast<Function>(M.getOrInsertFunction("llvm_visc_deviceAbstraction_waitOnDeviceStatus", - runtimeModule->getFunction("llvm_visc_deviceAbstraction_waitOnDeviceStatus")->getFunctionType())); + M.getOrInsertFunction("llvm_visc_deviceAbstraction_waitOnDeviceStatus", + runtimeModule->getFunction("llvm_visc_deviceAbstraction_waitOnDeviceStatus")->getFunctionType()); CallInst *RTFInst = CallInst::Create(RTF, Args, "", GenFuncCI); } } -- GitLab