[LLVMbugs] [Bug 3060] New: New IRgen of 'if' with constants is broken.

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Wed Nov 12 16:58:47 PST 2008


           Summary: New IRgen of 'if' with constants is broken.
           Product: clang
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: LLVM Codegen
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: daniel at zuster.org
                CC: llvmbugs at cs.uiuc.edu

The new constant IRgen is too aggressive because it is possible to evaluate
expressions with side effects to constants.
ddunbar at lordcrumb:CodeGen$ cat if.c
int g0(void);

int f0(void) {
  if (g0() && 0)
    return 0;
  return 1;
ddunbar at lordcrumb:CodeGen$ clang -emit-llvm -o - -O3 if.c
; ModuleID = 'if.c'
target datalayout =
target triple = "i686-apple-darwin10.0.0d3"

define i32 @f0() nounwind readnone {
        ret i32 1

The same issue occurs in other places, for example with the comma operator.

Chris and I discussed and came up with a plan to have tryEvaluate return more
information about the folded constant. The idea would be to have the result be
one of
(1) not evaluatable
(2) C99 ICE, which should never have side effects or labels
(3) constant value bla, with optional bits indicating if the expression has
side effects and if the expression has labels (useful for consumers in
different contexts). One can imagine other bits like imprecise-floating-point
result being useful in time.

This bug is a placeholder for this work.

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list