Skip to content

Commit

Permalink
Fill debug values in created instructions
Browse files Browse the repository at this point in the history
Fill debug values in created instructions
  • Loading branch information
igorban-intel authored and aparshin-intel committed Mar 16, 2022
1 parent 3b94702 commit 8db8345
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions GenXIntrinsics/lib/GenXIntrinsics/GenXSingleElementVectorUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,20 +201,24 @@ static Value *createVectorToScalarValue(Value *Vector,
Instruction *InsertBefore,
size_t idx = 0) {
assert(hasSingleElementVector(Vector->getType()));
Instruction *Val = nullptr;
if (isa<UndefValue>(Vector))
return UndefValue::get(
getTypeFreeFromSingleElementVector(Vector->getType()));
else if (isa<PointerType>(Vector->getType()))
return new BitCastInst(
Vector, getTypeFreeFromSingleElementVector(Vector->getType()),
"sev.cast.", InsertBefore);
Val = new BitCastInst(Vector,
getTypeFreeFromSingleElementVector(Vector->getType()),
"sev.cast.", InsertBefore);
else if (auto *Const = dyn_cast<Constant>(Vector))
return Const->getAggregateElement(idx);
else {
auto *M = InsertBefore->getModule();
return ExtractElementInst::Create(Vector, getVectorIndex(*M, idx),
"sev.cast.", InsertBefore);
Val = ExtractElementInst::Create(Vector, getVectorIndex(*M, idx),
"sev.cast.", InsertBefore);
}
if (auto *InVector = dyn_cast<Instruction>(Vector))
Val->setDebugLoc(InVector->getDebugLoc());
return Val;
}

// This util accepts SEV-rich Value and returns new, SEV-free one
Expand All @@ -224,20 +228,24 @@ static Value *createVectorToScalarValue(Value *Vector,
static Value *createVectorToScalarValue(Value *Vector, BasicBlock *BB,
size_t idx = 0) {
assert(hasSingleElementVector(Vector->getType()));
Instruction *Val = nullptr;
if (isa<UndefValue>(Vector))
return UndefValue::get(
getTypeFreeFromSingleElementVector(Vector->getType()));
else if (isa<PointerType>(Vector->getType()))
return new BitCastInst(
Vector, getTypeFreeFromSingleElementVector(Vector->getType()),
"sev.cast.", BB);
Val = new BitCastInst(Vector,
getTypeFreeFromSingleElementVector(Vector->getType()),
"sev.cast.", BB);
else if (auto *Const = dyn_cast<Constant>(Vector))
return Const->getAggregateElement(idx);
else {
auto *M = BB->getModule();
return ExtractElementInst::Create(Vector, getVectorIndex(*M, idx),
"sev.cast.", BB);
Val = ExtractElementInst::Create(Vector, getVectorIndex(*M, idx),
"sev.cast.", BB);
}
if (auto *InVector = dyn_cast<Instruction>(Vector))
Val->setDebugLoc(InVector->getDebugLoc());
return Val;
}

// This util accepts Scalar Value and returns new SEV-rich Value
Expand Down

0 comments on commit 8db8345

Please sign in to comment.