From 210a29de7bcc6dcf73fec98efe38e2e1fac83c50 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Fri, 27 Apr 2018 21:41:36 +0000 Subject: Fix a bug in GlobalOpt's handling of DIExpressions. This patch adds support for fragment expressions TryToShrinkGlobalToBoolean() which were previously just dropped. Thanks to Reid Kleckner for providing me a reproducer! llvm-svn: 331086 --- llvm/lib/Transforms/IPO/GlobalOpt.cpp | 14 +++++--------- llvm/lib/Transforms/Utils/Local.cpp | 4 ++-- 2 files changed, 7 insertions(+), 11 deletions(-) (limited to 'llvm/lib/Transforms') diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp index 96a1f4d69dd..1ae5dde5fc8 100644 --- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp +++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp @@ -1668,15 +1668,11 @@ static bool TryToShrinkGlobalToBoolean(GlobalVariable *GV, Constant *OtherVal) { // val * (ValOther - ValInit) + ValInit: // DW_OP_deref DW_OP_constu // DW_OP_mul DW_OP_constu DW_OP_plus DW_OP_stack_value - E = DIExpression::get(NewGV->getContext(), - {dwarf::DW_OP_deref, - dwarf::DW_OP_constu, - ValMinus, - dwarf::DW_OP_mul, - dwarf::DW_OP_constu, - ValInit, - dwarf::DW_OP_plus, - dwarf::DW_OP_stack_value}); + SmallVector Ops = { + dwarf::DW_OP_deref, dwarf::DW_OP_constu, ValMinus, + dwarf::DW_OP_mul, dwarf::DW_OP_constu, ValInit, + dwarf::DW_OP_plus}; + E = DIExpression::prependOpcodes(E, Ops, DIExpression::WithStackValue); DIGlobalVariableExpression *DGVE = DIGlobalVariableExpression::get(NewGV->getContext(), DGV, E); NewGV->addDebugInfo(DGVE); diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp index edb01d1dda3..2f7d414e4dc 100644 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -1522,8 +1522,8 @@ void llvm::salvageDebugInfo(Instruction &I) { auto doSalvage = [&](DbgInfoIntrinsic *DII, SmallVectorImpl &Ops) { auto *DIExpr = DII->getExpression(); - DIExpr = DIExpression::doPrepend(DIExpr, Ops, - DIExpression::WithStackValue); + DIExpr = + DIExpression::prependOpcodes(DIExpr, Ops, DIExpression::WithStackValue); DII->setOperand(0, wrapMD(I.getOperand(0))); DII->setOperand(2, MetadataAsValue::get(I.getContext(), DIExpr)); DEBUG(dbgs() << "SALVAGE: " << *DII << '\n'); -- cgit v1.2.3