Skip to content

Commit 3efa016

Browse files
committed
Revert accidentally pushed commit. It was not yet reviewed.
"Fix UB in DwarfExpression::emitLegacyZExt()" This reverts commit e37de5d.
1 parent 37ef303 commit 3efa016

File tree

2 files changed

+3
-28
lines changed

2 files changed

+3
-28
lines changed

llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -681,25 +681,9 @@ void DwarfExpression::emitLegacySExt(unsigned FromBits) {
681681
}
682682

683683
void DwarfExpression::emitLegacyZExt(unsigned FromBits) {
684-
// Heuristic to decide the most efficient encoding.
685-
// A ULEB can encode 7 1-bits per byte.
686-
if (FromBits / 7 < 1+1+1+1+1) {
687-
// (X & (1 << FromBits - 1))
688-
emitOp(dwarf::DW_OP_constu);
689-
emitUnsigned((1ULL << FromBits) - 1);
690-
} else {
691-
// Note that the DWARF 4 stack consists of pointer-sized elements,
692-
// so technically it doesn't make sense to shift left more than 64
693-
// bits. We leave that for the consumer to decide though. LLDB for
694-
// example uses APInt for the stack elements and can still deal
695-
// with this.
696-
emitOp(dwarf::DW_OP_lit1);
697-
emitOp(dwarf::DW_OP_constu);
698-
emitUnsigned(FromBits);
699-
emitOp(dwarf::DW_OP_shl);
700-
emitOp(dwarf::DW_OP_lit1);
701-
emitOp(dwarf::DW_OP_minus);
702-
}
684+
// (X & (1 << FromBits - 1))
685+
emitOp(dwarf::DW_OP_constu);
686+
emitUnsigned((1ULL << FromBits) - 1);
703687
emitOp(dwarf::DW_OP_and);
704688
}
705689

llvm/test/DebugInfo/X86/convert-debugloc.ll

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,11 @@
6464
; NOCONV: DW_AT_location (
6565
; NOCONV: {{.*}}, DW_OP_dup, DW_OP_constu 0x7, DW_OP_shr, DW_OP_lit0, DW_OP_not, DW_OP_mul, DW_OP_constu 0x8, DW_OP_shl, DW_OP_or, DW_OP_stack_value)
6666
; NOCONV: DW_AT_name ("y")
67-
; NOCONV: DW_TAG_variable
68-
; NOCONV: DW_AT_location (
69-
; NOCONV: DW_OP_constu 0x40, DW_OP_lit0, DW_OP_plus, DW_OP_lit1, DW_OP_constu 0x40, DW_OP_shl, DW_OP_lit1, DW_OP_minus, DW_OP_and, DW_OP_stack_value)
70-
; NOCONV: DW_AT_name ("z")
7167
; NOCONV: NULL
7268
; NOCONV: DW_TAG_base_type
7369
; NOCONV: DW_AT_name ("signed char")
7470
; NOCONV: DW_TAG_base_type
7571
; NOCONV: DW_AT_name ("int")
76-
; NOCONV: DW_TAG_base_type
77-
; NOCONV: DW_AT_name ("unsigned long long")
7872
; NOCONV: NULL
7973

8074

@@ -87,7 +81,6 @@ entry:
8781
;; will not attempt to eliminate. At the moment, only "convert" ops are folded.
8882
;; If you have to change the expression, the expected DWO_id also changes.
8983
call void @llvm.dbg.value(metadata i8 32, metadata !13, metadata !DIExpression(DW_OP_lit0, DW_OP_plus, DW_OP_LLVM_convert, 8, DW_ATE_signed, DW_OP_LLVM_convert, 32, DW_ATE_signed, DW_OP_stack_value)), !dbg !15
90-
call void @llvm.dbg.value(metadata i8 64, metadata !17, metadata !DIExpression(DW_OP_lit0, DW_OP_plus, DW_OP_LLVM_convert, 64, DW_ATE_unsigned, DW_OP_LLVM_convert, 128, DW_ATE_unsigned, DW_OP_LLVM_convert, 64, DW_ATE_unsigned, DW_OP_stack_value)), !dbg !15
9184
ret i8 %x, !dbg !16
9285
}
9386

@@ -118,5 +111,3 @@ declare void @llvm.dbg.value(metadata, metadata, metadata)
118111
!14 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
119112
!15 = !DILocation(line: 3, column: 14, scope: !7)
120113
!16 = !DILocation(line: 4, column: 3, scope: !7)
121-
!17 = !DILocalVariable(name: "z", scope: !7, file: !1, line: 3, type: !18)
122-
!18 = !DIBasicType(name: "unsigned long long", size: 64, encoding: DW_ATE_unsigned)

0 commit comments

Comments
 (0)