summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2018-09-05 10:18:36 +0000
committerJonas Devlieghere <jonas@devlieghere.com>2018-09-05 10:18:36 +0000
commit965b598b2a9cf9a77fd9a4586484554eaed38ede (patch)
treeb0beecaa2e2692b1dcadc86e878475fd2e2f19c5 /llvm/lib/CodeGen
parente157cea3eca853a4b7e9b22e1119883ad1836f41 (diff)
downloadbcm5719-llvm-965b598b2a9cf9a77fd9a4586484554eaed38ede.tar.gz
bcm5719-llvm-965b598b2a9cf9a77fd9a4586484554eaed38ede.zip
[DebugInfo] Normalize common kinds of DWARF sub-expressions.
Normalize common kinds of DWARF sub-expressions to make debug info encoding a bit more compact: DW_OP_constu [X < 32] -> DW_OP_litX DW_OP_constu [all ones] -> DW_OP_lit0, DW_OP_not (64-bit only) Differential revision: https://reviews.llvm.org/D51640 llvm-svn: 341457
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp26
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h3
2 files changed, 21 insertions, 8 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp
index d8d1a5e8f84..af51d276634 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp
@@ -24,6 +24,20 @@
using namespace llvm;
+void DwarfExpression::emitConstu(uint64_t Value) {
+ if (Value < 32)
+ emitOp(dwarf::DW_OP_lit0 + Value);
+ else if (Value == std::numeric_limits<uint64_t>::max()) {
+ // Only do this for 64-bit values as the DWARF expression stack uses
+ // target-address-size values.
+ emitOp(dwarf::DW_OP_lit0);
+ emitOp(dwarf::DW_OP_not);
+ } else {
+ emitOp(dwarf::DW_OP_constu);
+ emitUnsigned(Value);
+ }
+}
+
void DwarfExpression::addReg(int DwarfReg, const char *Comment) {
assert(DwarfReg >= 0 && "invalid negative dwarf register number");
assert((LocationKind == Unknown || LocationKind == Register) &&
@@ -72,14 +86,12 @@ void DwarfExpression::addOpPiece(unsigned SizeInBits, unsigned OffsetInBits) {
}
void DwarfExpression::addShr(unsigned ShiftBy) {
- emitOp(dwarf::DW_OP_constu);
- emitUnsigned(ShiftBy);
+ emitConstu(ShiftBy);
emitOp(dwarf::DW_OP_shr);
}
void DwarfExpression::addAnd(unsigned Mask) {
- emitOp(dwarf::DW_OP_constu);
- emitUnsigned(Mask);
+ emitConstu(Mask);
emitOp(dwarf::DW_OP_and);
}
@@ -181,8 +193,7 @@ void DwarfExpression::addSignedConstant(int64_t Value) {
void DwarfExpression::addUnsignedConstant(uint64_t Value) {
assert(LocationKind == Implicit || LocationKind == Unknown);
LocationKind = Implicit;
- emitOp(dwarf::DW_OP_constu);
- emitUnsigned(Value);
+ emitConstu(Value);
}
void DwarfExpression::addUnsignedConstant(const APInt &Value) {
@@ -373,8 +384,7 @@ void DwarfExpression::addExpression(DIExpressionCursor &&ExprCursor,
break;
case dwarf::DW_OP_constu:
assert(LocationKind != Register);
- emitOp(dwarf::DW_OP_constu);
- emitUnsigned(Op->getArg(0));
+ emitConstu(Op->getArg(0));
break;
case dwarf::DW_OP_stack_value:
LocationKind = Implicit;
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h
index 0637d952eba..d47c4d1d296 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h
@@ -138,6 +138,9 @@ protected:
/// Emit a raw unsigned value.
virtual void emitUnsigned(uint64_t Value) = 0;
+ /// Emit a normalized unsigned constant.
+ void emitConstu(uint64_t Value);
+
/// Return whether the given machine register is the frame register in the
/// current function.
virtual bool isFrameRegister(const TargetRegisterInfo &TRI, unsigned MachineReg) = 0;
OpenPOWER on IntegriCloud