Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

[clang cfg] BinaryOperators built in wrong order for CFG #6563

Open Quuxplusone opened 14 years ago

Quuxplusone commented 14 years ago
Bugzilla Link PR6097
Status REOPENED
Importance P normal
Reported by Mike Stump (mikestump@comcast.net)
Reported on 2010-01-20 19:17:46 -0800
Last modified on 2010-03-12 00:57:40 -0800
Version trunk
Hardware PC All
CC kremenek@apple.com, llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
$ cat t5.c
int foo1();
int foo2();
int main() {
  return foo1() + foo2();
}
mrs $ clang -cc1 -analyze -cfg-dump -fexceptions  t5.c

 [ B4 (ENTRY) ]
    Predecessors (0):
    Successors (1): B3

 [ B1 ]
      1: return [B2.1] + [B3.1];
    Predecessors (1): B2
    Successors (1): B0

 [ B2 ]
      1: foo1()
    Predecessors (1): B3
    Successors (2): B1 B0

 [ B3 ]
      1: foo2()
    Predecessors (1): B4
    Successors (2): B2 B0

 [ B0 (EXIT) ]
    Predecessors (3): B1 B2 B3
    Successors (0):
$ clang -S t5.c
$ grep foo t5.s
    callq   _foo1
    callq   _foo2

Order should be B4 -> B2 -> B3 -> B1.
Quuxplusone commented 14 years ago

Right now the order is B4 -> B3 -> B2 -> B1.

Why is that not a valid ordering? Does the standard say something about the order of evaluation of the subexpressions of a binary expression?

Quuxplusone commented 14 years ago

Chris said he wanted things in codegen order in general. I just noticed this deviation from that order.

Quuxplusone commented 14 years ago

Ah, okay. So the idea is to have the LHS evaluated first?