From ecb42c8b6a1f327aebb9c0f18a784c00fcda36ec Mon Sep 17 00:00:00 2001 From: Machiry Aravind Kumar Date: Fri, 6 Jul 2018 01:37:59 -0700 Subject: [PATCH] Adding support for vector operands (Patch 2) Added changes to `PAGBuilder` to correctly handle store instructions, in case of vector operands. --- lib/MemoryModel/PAGBuilder.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/MemoryModel/PAGBuilder.cpp b/lib/MemoryModel/PAGBuilder.cpp index 7f6af6cd5..a8329fa37 100644 --- a/lib/MemoryModel/PAGBuilder.cpp +++ b/lib/MemoryModel/PAGBuilder.cpp @@ -414,6 +414,27 @@ void PAGBuilder::visitStoreInst(StoreInst &inst) { NodeID src = getValueNode(inst.getValueOperand()); pag->addStoreEdge(src, dst); + } else { + // if this is a vector operand, process the individual operands. + if(isa(inst.getValueOperand()->getType()) && dyn_cast(inst.getValueOperand())) { + ConstantVector *CVExpr = dyn_cast(inst.getValueOperand()); + bool dstCreated = false; + NodeID vdst; + // iterate for each element in the vector + for(unsigned vindex = 0; vindex < CVExpr->getNumOperands(); ++vindex) { + if(CVExpr->getOperand(vindex)->getType()->isPointerTy()) { + NodeID vsrc = getValueNode(CVExpr->getOperand(vindex)); + // create dst node only if its required. i.e., if any of the element + // of the vector's value is a pointer type. + if(!dstCreated) { + vdst = getValueNode(inst.getPointerOperand()); + dstCreated = true; + } + pag->addStoreEdge(vsrc, vdst); + } + + } + } } }