http://llvm.org/bugs/show_bug.cgi?id=3060

           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: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]
                CC: [email protected]


The new constant IRgen is too aggressive because it is possible to evaluate
expressions with side effects to constants.
--
[EMAIL PROTECTED]:CodeGen$ cat if.c
int g0(void);

int f0(void) {
  if (g0() && 0)
    return 0;
  return 1;
}
[EMAIL PROTECTED]:CodeGen$ clang -emit-llvm -o - -O3 if.c
; ModuleID = 'if.c'
target datalayout =
"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
target triple = "i686-apple-darwin10.0.0d3"

define i32 @f0() nounwind readnone {
entry:
        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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to