https://bugs.llvm.org/show_bug.cgi?id=38756
Bug ID: 38756
Summary: Debug: illegal value and unreachable lines seen when
conditional stores merged
Product: new-bugs
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: new bugs
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected],
[email protected],
[email protected],
[email protected]
The test below causes debuggers to report an illegal variable value and step
onto a line that isn't executed. The test was originally intended to stimulate
SimplifyCFG's mergeConditionalStores method (merging the conditional stores to
"global") but is likely triggering bad behaviour elsewhere.
I've used an up-to-date toolchain (r340912), and compiled with "clang++
test.cpp -g -O2 -o a.out" for x86_64. To be clear, the program should pass
through both "else" blocks of the conditionals as bar == 4, and "lolret" should
accumulate the values zero, two, and six. however:
* Single stepping, we step onto "lolret += 4", immediately followed by
"lolret += 3". The latter is not actually executed, and stepping on both
branches of a conditional is misleading anyway,
* "lolret" appears with the value five at one step of the program, which
is a value it never has (neither does anything else). This appears on
the "if (bar & 2)" line, but,
* Control flow really bounces around, I observe more backward steps in
this test than forward steps.
To be completely clear, here's a trace of hitting the unreachable line and
finding the illegal value:
Starting program: /tmp/a.out
Temporary breakpoint 2, main () at test.cpp:6
6 volatile int foo = 4;
(gdb) s
7 int bar = foo;
(gdb) s
10 if (bar & 1) {
(gdb) s
23 lolret += 4;
(gdb) s
20 lolret += 3;
(gdb)
18 if (bar & 2) {
(gdb) print lolret
$10 = 5
(gdb)
-------->8--------
int global = 0;
int
main()
{
volatile int foo = 4;
int bar = foo;
int lolret = 0;
if (bar & 1) {
bar += 1;
lolret += 1;
} else {
global = 2;
lolret += 2;
}
if (bar & 2) {
bar += 2;
lolret += 3;
} else {
global = 5;
lolret += 4;
}
return lolret;
}
--------8<--------
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs