aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/Local.cpp
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2018-02-13 01:09:46 +0000
committerVedant Kumar <vsk@apple.com>2018-02-13 01:09:46 +0000
commit96b7dc041b5e01949f654594b3761d8be7184ee5 (patch)
tree9bf58a0a000941b5059c6ca31f94b66ae514d94f /llvm/lib/Transforms/Utils/Local.cpp
parenteb7a85af426f4c41ca406d82a3de854050c4c1d2 (diff)
downloadllvm-96b7dc041b5e01949f654594b3761d8be7184ee5.zip
llvm-96b7dc041b5e01949f654594b3761d8be7184ee5.tar.gz
llvm-96b7dc041b5e01949f654594b3761d8be7184ee5.tar.bz2
[Utils] Salvage the debug info of DCE'ed 'xor' instructions
This salvages 259 debug values in a stage2 build of clang. Differential Revision: https://reviews.llvm.org/D43207 llvm-svn: 324973
Diffstat (limited to 'llvm/lib/Transforms/Utils/Local.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/Local.cpp32
1 files changed, 21 insertions, 11 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index 39169f9..13668e7 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -1536,17 +1536,27 @@ void llvm::salvageDebugInfo(Instruction &I) {
for (auto *DII : DbgUsers)
applyOffset(DII, Offset.getSExtValue());
} else if (auto *BI = dyn_cast<BinaryOperator>(&I)) {
- if (BI->getOpcode() == Instruction::Add ||
- BI->getOpcode() == Instruction::Or)
- if (auto *ConstInt = dyn_cast<ConstantInt>(I.getOperand(1)))
- if (ConstInt->getBitWidth() <= 64) {
- uint64_t Val = ConstInt->getSExtValue();
- for (auto *DII : DbgUsers)
- if (BI->getOpcode() == Instruction::Add)
- applyOffset(DII, Val);
- else if (BI->getOpcode() == Instruction::Or)
- applyOps(DII, {dwarf::DW_OP_constu, Val, dwarf::DW_OP_or});
- }
+ auto *ConstInt = dyn_cast<ConstantInt>(I.getOperand(1));
+ if (!ConstInt || ConstInt->getBitWidth() > 64)
+ return;
+
+ uint64_t Val = ConstInt->getSExtValue();
+ for (auto *DII : DbgUsers) {
+ switch (BI->getOpcode()) {
+ case Instruction::Add:
+ applyOffset(DII, Val);
+ break;
+ case Instruction::Or:
+ applyOps(DII, {dwarf::DW_OP_constu, Val, dwarf::DW_OP_or});
+ break;
+ case Instruction::Xor:
+ applyOps(DII, {dwarf::DW_OP_constu, Val, dwarf::DW_OP_xor});
+ break;
+ default:
+ // TODO: Salvage constants from each kind of binop we know about.
+ continue;
+ }
+ }
} else if (isa<LoadInst>(&I)) {
MetadataAsValue *AddrMD = wrapMD(I.getOperand(0));
for (auto *DII : DbgUsers) {