From 8db834532b07d306c54e61c6b77ac74a4a792f4d Mon Sep 17 00:00:00 2001 From: Igor Gorban Date: Fri, 25 Feb 2022 21:30:45 +0000 Subject: [PATCH] Fill debug values in created instructions Fill debug values in created instructions --- .../GenXSingleElementVectorUtil.cpp | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/GenXIntrinsics/lib/GenXIntrinsics/GenXSingleElementVectorUtil.cpp b/GenXIntrinsics/lib/GenXIntrinsics/GenXSingleElementVectorUtil.cpp index e8d74f6f..ec1b70d7 100644 --- a/GenXIntrinsics/lib/GenXIntrinsics/GenXSingleElementVectorUtil.cpp +++ b/GenXIntrinsics/lib/GenXIntrinsics/GenXSingleElementVectorUtil.cpp @@ -201,20 +201,24 @@ static Value *createVectorToScalarValue(Value *Vector, Instruction *InsertBefore, size_t idx = 0) { assert(hasSingleElementVector(Vector->getType())); + Instruction *Val = nullptr; if (isa(Vector)) return UndefValue::get( getTypeFreeFromSingleElementVector(Vector->getType())); else if (isa(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(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(Vector)) + Val->setDebugLoc(InVector->getDebugLoc()); + return Val; } // This util accepts SEV-rich Value and returns new, SEV-free one @@ -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(Vector)) return UndefValue::get( getTypeFreeFromSingleElementVector(Vector->getType())); else if (isa(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(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(Vector)) + Val->setDebugLoc(InVector->getDebugLoc()); + return Val; } // This util accepts Scalar Value and returns new SEV-rich Value