[LLVMbugs] [Bug 18355] New: Undef handling in constant folding

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jan 2 10:39:44 PST 2014


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

            Bug ID: 18355
           Summary: Undef handling in constant folding
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Core LLVM classes
          Assignee: unassignedbugs at nondot.org
          Reporter: realprincewall at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Let me use the code at
http://llvm.org/docs/doxygen/html/ConstantFold_8cpp_source.html to explain the
problem.

In function llvm::ConstantFoldBinaryInstruction, Undef is handled first with a
switch block as quoted below. Note that there is no default case in the switch.
Therefore, Undef operations can go beyond the "if (isa<UndefValue>(C1) ||
isa<UndefValue>(C2)) " block.

00871 Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode,
00872                                               Constant *C1, Constant *C2)
{
00873   // Handle UndefValue up front.
00874   if (isa<UndefValue>(C1) || isa<UndefValue>(C2)) {
00875     switch (Opcode) {
00876     case Instruction::Xor:

Is this intentional? As per the code below, 

01038   // At this point we know neither constant is an UndefValue.
01039   if (ConstantInt *CI1 = dyn_cast<ConstantInt>(C1)) {

It is assumed that no Undef will reach there. Is this issue a missing default
case in switch or just bad comments? Thanks!

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140102/1c161d0f/attachment.html>


More information about the llvm-bugs mailing list