diff options
| author | Vedant Kumar <vsk@apple.com> | 2018-09-15 04:08:52 +0000 |
|---|---|---|
| committer | Vedant Kumar <vsk@apple.com> | 2018-09-15 04:08:52 +0000 |
| commit | 1b02dad9f267c45834c3d499f0fef0053dc322a0 (patch) | |
| tree | d4cd428f57a8602e381734edf1939f2892f3e0ed /llvm/lib/CodeGen | |
| parent | d197ebf3edff040be12b11975500f973f7a7e65c (diff) | |
| download | bcm5719-llvm-1b02dad9f267c45834c3d499f0fef0053dc322a0.tar.gz bcm5719-llvm-1b02dad9f267c45834c3d499f0fef0053dc322a0.zip | |
[CodeGenPrepare] Preserve debug locs in OptimizeExtractBits
CodeGenPrepare has a transform that sinks {lshr, trunc} pairs to make it
easier for the backend to emit fancy extract-bits instructions (e.g UBFX).
Teach it to preserve debug locations and salvage debug values.
llvm-svn: 342319
Diffstat (limited to 'llvm/lib/CodeGen')
| -rw-r--r-- | llvm/lib/CodeGen/CodeGenPrepare.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp index cf1966f4677..ec4451ffa75 100644 --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -1405,6 +1405,7 @@ SinkShiftAndTruncate(BinaryOperator *ShiftI, Instruction *User, ConstantInt *CI, else InsertedShift = BinaryOperator::CreateLShr(ShiftI->getOperand(0), CI, "", &*InsertPt); + InsertedShift->setDebugLoc(ShiftI->getDebugLoc()); // Sink the trunc BasicBlock::iterator TruncInsertPt = TruncUserBB->getFirstInsertionPt(); @@ -1413,6 +1414,7 @@ SinkShiftAndTruncate(BinaryOperator *ShiftI, Instruction *User, ConstantInt *CI, InsertedTrunc = CastInst::Create(TruncI->getOpcode(), InsertedShift, TruncI->getType(), "", &*TruncInsertPt); + InsertedTrunc->setDebugLoc(TruncI->getDebugLoc()); MadeChange = true; @@ -1504,6 +1506,7 @@ static bool OptimizeExtractBits(BinaryOperator *ShiftI, ConstantInt *CI, else InsertedShift = BinaryOperator::CreateLShr(ShiftI->getOperand(0), CI, "", &*InsertPt); + InsertedShift->setDebugLoc(ShiftI->getDebugLoc()); MadeChange = true; } @@ -1513,8 +1516,10 @@ static bool OptimizeExtractBits(BinaryOperator *ShiftI, ConstantInt *CI, } // If we removed all uses, nuke the shift. - if (ShiftI->use_empty()) + if (ShiftI->use_empty()) { + salvageDebugInfo(*ShiftI); ShiftI->eraseFromParent(); + } return MadeChange; } |

