Skip to content

Commit d6025c6

Browse files
author
Amirhossein Pashaeehir
committed
Change the error messages to show that the warnings are not the programmer's fault and the validation is not implemented yet.
Change the tests accordingly
1 parent 10a84ff commit d6025c6

File tree

6 files changed

+69
-37
lines changed

6 files changed

+69
-37
lines changed

llvm/lib/DWARFCFIChecker/DWARFCFIAnalysis.cpp

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ getCFARegOffsetInfo(const dwarf::UnwindRow &UnwindRow) {
5757
static SmallSet<DWARFRegNum, 4>
5858
getUnwindRuleRegSet(const dwarf::UnwindRow &UnwindRow, DWARFRegNum Reg) {
5959
auto MaybeLoc = UnwindRow.getRegisterLocations().getRegisterLocation(Reg);
60-
assert(MaybeLoc && "The register should be included in the unwinding row");
60+
assert(MaybeLoc && "the register should be included in the unwinding row");
6161
auto Loc = *MaybeLoc;
6262

6363
switch (Loc.getLocation()) {
@@ -111,7 +111,7 @@ DWARFCFIAnalysis::DWARFCFIAnalysis(MCContext *Context, MCInstrInfo const &MCII,
111111
assert(MaybeCurrentRow && "there should be at least one row");
112112
auto MaybeCFA = getCFARegOffsetInfo(*MaybeCurrentRow);
113113
assert(MaybeCFA &&
114-
"the CFA information should be describable in [Reg + Offset] in here");
114+
"the CFA information should be describable in [reg + offset] in here");
115115
auto CFA = *MaybeCFA;
116116

117117
// TODO: CFA register callee value is CFA's value, this should be in initial
@@ -129,8 +129,8 @@ void DWARFCFIAnalysis::update(const MCInst &Inst,
129129
const MCInstrDesc &MCInstInfo = MCII.get(Inst.getOpcode());
130130

131131
auto MaybePrevRow = State.getCurrentUnwindRow();
132-
assert(MaybePrevRow && "The analysis should have initialized the "
133-
"history with at least one row by now");
132+
assert(MaybePrevRow && "the analysis should have initialized the "
133+
"state with at least one row by now");
134134
auto PrevRow = *MaybePrevRow;
135135

136136
for (auto &&Directive : Directives)
@@ -157,7 +157,7 @@ void DWARFCFIAnalysis::update(const MCInst &Inst,
157157
}
158158

159159
auto MaybeNextRow = State.getCurrentUnwindRow();
160-
assert(MaybeNextRow && "Prev row existed, so should the current row.");
160+
assert(MaybeNextRow && "previous row existed, so should the current row");
161161
auto NextRow = *MaybeNextRow;
162162

163163
checkCFADiff(Inst, PrevRow, NextRow, Reads, Writes);
@@ -211,7 +211,7 @@ void DWARFCFIAnalysis::checkRegDiff(const MCInst &Inst, DWARFRegNum Reg,
211211
for (DWARFRegNum UsedReg : getUnwindRuleRegSet(PrevRow, Reg))
212212
if (Writes.count(UsedReg)) { // Case 1.b
213213
auto MaybeLLVMUsedReg = MCRI->getLLVMRegNum(UsedReg, IsEH);
214-
assert(MaybeLLVMUsedReg && "Instructions will always write to a "
214+
assert(MaybeLLVMUsedReg && "instructions will always write to a "
215215
"register that has an LLVM register number");
216216
Context->reportError(
217217
Inst.getLoc(),
@@ -224,18 +224,20 @@ void DWARFCFIAnalysis::checkRegDiff(const MCInst &Inst, DWARFRegNum Reg,
224224
}
225225
// Case 2
226226
if (PrevLoc.getLocation() != NextLoc.getLocation()) { // Case 2.a
227-
Context->reportWarning(Inst.getLoc(),
228-
formatv("uncheckable change happened to register "
229-
"{0} unwinding rule structure",
230-
RegName));
227+
Context->reportWarning(
228+
Inst.getLoc(),
229+
formatv("validating changes happening to register {0} unwinding "
230+
"rule structure is not implemented yet",
231+
RegName));
231232
return;
232233
}
233234
auto &&PrevRegSet = getUnwindRuleRegSet(PrevRow, Reg);
234235
if (PrevRegSet != getUnwindRuleRegSet(NextRow, Reg)) { // Case 2.b
235236
Context->reportWarning(
236-
Inst.getLoc(), formatv("uncheckable change happened to register {0} "
237-
"unwinding rule register set",
238-
RegName));
237+
Inst.getLoc(),
238+
formatv("validating changes happening to register {0} unwinding "
239+
"rule register set is not implemented yet",
240+
RegName));
239241
return;
240242
}
241243
// Case 2.c
@@ -244,7 +246,8 @@ void DWARFCFIAnalysis::checkRegDiff(const MCInst &Inst, DWARFRegNum Reg,
244246
Context->reportWarning(
245247
Inst.getLoc(),
246248
formatv("register {0} unwinding rule's offset is changed, and one of "
247-
"the rule's registers is modified by an unknown amount",
249+
"the rule's registers is modified, but validating the "
250+
"modification amount is not implemented yet",
248251
RegName));
249252
return;
250253
}
@@ -308,15 +311,17 @@ void DWARFCFIAnalysis::checkCFADiff(const MCInst &Inst,
308311
if (PrevCFA.Reg != NextCFA.Reg) { // Case 2.b
309312
Context->reportWarning(
310313
Inst.getLoc(),
311-
formatv("CFA register changed from register {0} to register {1}",
314+
formatv("CFA register changed from register {0} to register {1}, "
315+
"validating this change is not implemented yet",
312316
PrevCFARegName, NextCFARegName));
313317
return;
314318
}
315319
// Case 2.c
316320
if (Writes.count(PrevCFA.Reg)) { // Case 2.c.i
317321
Context->reportWarning(
318-
Inst.getLoc(), formatv("CFA offset is changed from {0} to {1}, CFA "
319-
"register {2} is changed by an unknown amount",
322+
Inst.getLoc(), formatv("CFA offset is changed from {0} to {1}, and CFA "
323+
"register {2} is modified, but validating the "
324+
"modification amount is not implemented yet",
320325
PrevCFA.Offset, NextCFA.Offset, PrevCFARegName));
321326
return;
322327
}

llvm/test/DWARFCFIChecker/X86/single-func-cfa-mistake.s

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ f:
1111
.cfi_undefined %flags
1212

1313
pushq %rbp
14-
# CHECK: warning: CFA offset is changed from 8 to 17, CFA register RSP is changed by an unknown amount
15-
# CHECK: warning: uncheckable change happened to register RBP unwinding rule structure
14+
# CHECK: warning: CFA offset is changed from 8 to 17, and CFA register RSP is modified, but validating the modification amount is not implemented yet
15+
# CHECK: warning: validating changes happening to register RBP unwinding rule structure is not implemented yet
1616
.cfi_def_cfa_offset 17
1717
.cfi_offset %rbp, -16
1818

1919
movq %rsp, %rbp
20-
# CHECK: warning: CFA register changed from register RSP to register RBP
20+
# CHECK: warning: CFA register changed from register RSP to register RBP, validating this change is not implemented yet
2121
.cfi_def_cfa_register %rbp
2222

2323
movl %edi, -4(%rbp)
@@ -27,7 +27,7 @@ f:
2727
addl $10, %eax
2828

2929
popq %rbp
30-
# CHECK: warning: CFA register changed from register RBP to register RSP
30+
# CHECK: warning: CFA register changed from register RBP to register RSP, validating this change is not implemented yet
3131
.cfi_def_cfa %rsp, 8
3232

3333
retq

llvm/test/DWARFCFIChecker/X86/single-func.s

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ f:
1111
.cfi_undefined %flags
1212

1313
pushq %rbp
14-
# CHECK: warning: CFA offset is changed from 8 to 16, CFA register RSP is changed by an unknown amount
15-
# CHECK: warning: uncheckable change happened to register RBP unwinding rule structure
14+
# CHECK: warning: CFA offset is changed from 8 to 16, and CFA register RSP is modified, but validating the modification amount is not implemented yet
15+
# CHECK: warning: validating changes happening to register RBP unwinding rule structure is not implemented yet
1616
.cfi_def_cfa_offset 16
1717
.cfi_offset %rbp, -16
1818

1919
movq %rsp, %rbp
20-
# CHECK: warning: CFA register changed from register RSP to register RBP
20+
# CHECK: warning: CFA register changed from register RSP to register RBP, validating this change is not implemented yet
2121
.cfi_def_cfa_register %rbp
2222

2323
movl %edi, -4(%rbp)
@@ -27,7 +27,7 @@ f:
2727
addl $10, %eax
2828

2929
popq %rbp
30-
# CHECK: warning: CFA register changed from register RBP to register RSP
30+
# CHECK: warning: CFA register changed from register RBP to register RSP, validating this change is not implemented yet
3131
.cfi_def_cfa %rsp, 8
3232

3333
retq

llvm/test/DWARFCFIChecker/X86/spill-two-reg-reversed.s

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,29 @@ _start:
1111
.cfi_same_value %rsi
1212

1313
pushq %rbp
14-
# CHECK: warning: uncheckable change happened to register RBP unwinding rule structure
1514
.cfi_adjust_cfa_offset 8
1615
.cfi_offset %rbp, -16
1716

1817
movq %rsp, %rbp
1918

2019
pushq %rdi
21-
# CHECK: warning: uncheckable change happened to register RDI unwinding rule structure
2220
.cfi_adjust_cfa_offset 8
2321
.cfi_rel_offset %rdi, 0
2422

2523
pushq %rsi
26-
# CHECK: warning: uncheckable change happened to register RSI unwinding rule structure
2724
.cfi_adjust_cfa_offset 8
2825
.cfi_rel_offset %rsi, 0
2926

3027
popq %rsi
31-
# CHECK: warning: uncheckable change happened to register RDI unwinding rule structure
3228
.cfi_adjust_cfa_offset -8
3329
.cfi_same_value %rdi
3430

3531
popq %rdi
3632
# CHECK: error: changed register RDI, that register RDI's unwinding rule uses, but there is no CFI directives about it
37-
# CHECK: warning: uncheckable change happened to register RSI unwinding rule structure
3833
.cfi_adjust_cfa_offset -8
3934
.cfi_same_value %rsi
4035

4136
popq %rbp
42-
# CHECK: warning: uncheckable change happened to register RBP unwinding rule structure
4337
.cfi_adjust_cfa_offset -8
4438
.cfi_same_value %rbp
4539

llvm/test/DWARFCFIChecker/X86/spill-two-reg.s

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,40 @@ _start:
1212
.cfi_same_value %rsi
1313

1414
pushq %rbp
15-
# CHECK: warning: uncheckable change happened to register RBP unwinding rule structure
15+
# CHECK: warning: CFA offset is changed from 8 to 16, and CFA register RSP is modified, but validating the modification amount is not implemented yet
16+
# CHECK: warning: validating changes happening to register RBP unwinding rule structure is not implemented yet
1617
.cfi_adjust_cfa_offset 8
1718
.cfi_offset %rbp, -16
1819

1920
movq %rsp, %rbp
2021

2122
pushq %rdi
22-
# CHECK: warning: uncheckable change happened to register RDI unwinding rule structure
23+
# CHECK: warning: CFA offset is changed from 16 to 24, and CFA register RSP is modified, but validating the modification amount is not implemented yet
24+
# CHECK: warning: validating changes happening to register RDI unwinding rule structure is not implemented yet
2325
.cfi_adjust_cfa_offset 8
2426
.cfi_rel_offset %rdi, 0
2527

2628
pushq %rsi
27-
# CHECK: warning: uncheckable change happened to register RSI unwinding rule structure
29+
# CHECK: warning: CFA offset is changed from 24 to 32, and CFA register RSP is modified, but validating the modification amount is not implemented yet
30+
# CHECK: warning: validating changes happening to register RSI unwinding rule structure is not implemented yet
2831
.cfi_adjust_cfa_offset 8
2932
.cfi_rel_offset %rsi, 0
3033

3134
popq %rsi
32-
# CHECK: warning: uncheckable change happened to register RSI unwinding rule structure
35+
# CHECK: warning: CFA offset is changed from 32 to 24, and CFA register RSP is modified, but validating the modification amount is not implemented yet
36+
# CHECK: warning: validating changes happening to register RSI unwinding rule structure is not implemented yet
3337
.cfi_adjust_cfa_offset -8
3438
.cfi_same_value %rsi
3539

3640
popq %rdi
37-
# CHECK: warning: uncheckable change happened to register RDI unwinding rule structure
41+
# CHECK: warning: CFA offset is changed from 24 to 16, and CFA register RSP is modified, but validating the modification amount is not implemented yet
42+
# CHECK: warning: validating changes happening to register RDI unwinding rule structure is not implemented yet
3843
.cfi_adjust_cfa_offset -8
3944
.cfi_same_value %rdi
4045

4146
popq %rbp
42-
# CHECK: warning: uncheckable change happened to register RBP unwinding rule structure
47+
# CHECK: warning: CFA offset is changed from 16 to 8, and CFA register RSP is modified, but validating the modification amount is not implemented yet
48+
# CHECK: warning: validating changes happening to register RBP unwinding rule structure is not implemented yet
4349
.cfi_adjust_cfa_offset -8
4450
.cfi_same_value %rbp
4551

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# RUN: not llvm-mc %s --validate-cfi --filetype=null 2>&1 \
2+
# RUN: | FileCheck %s --allow-empty
3+
.text
4+
.globl f
5+
.type f, @function
6+
f:
7+
.cfi_startproc
8+
9+
# TODO: Remove these lines when the initial frame directives set the callee saved registers
10+
.cfi_undefined %flags
11+
12+
.cfi_same_value %rax
13+
14+
pushq %rax
15+
.cfi_offset %rax, 16
16+
17+
addq $10, %rbx
18+
# CHECK: error: modified CFA register RSP but not changed CFA rule
19+
20+
addq $10, %rax
21+
# CHECK: error: did not modify CFA register RSP but changed CFA rule
22+
.cfi_adjust_cfa_offset 8
23+
24+
.Lfunc_end0:
25+
.size f, .Lfunc_end0-f
26+
.cfi_endproc
27+

0 commit comments

Comments
 (0)