[LLVMbugs] [Bug 2672] New: Nested GEP in a static initializer fails.

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Wed Aug 13 05:39:55 CDT 2008


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

           Summary: Nested GEP in a static initializer fails.
           Product: new-bugs
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: rich at pennware.com
                CC: llvmbugs at cs.uiuc.edu


Analysis:
It seems that EmitConstantValueOnly in AsmPrinter.cpp can only handle one level
of GEP. This example has two levels and the inner level is not recognized as a
constant expression by getIndexedOffset() in TargetData.cpp.

It seems that EmitConstantValueOnly should recursively go through the GEP
arguments. Does that sound right?

The following code snippet fails during code generation with llc:

; ModuleID = 't0052.ubc'
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-s0:0:64-f80:32:32"
target triple = "i386-elf"
@i = global i32 ptrtoint (i32* getelementptr (i32* @i, i32 sub (i32 0, i32
ptrtoint (i32* getelementptr (i32* null, i32 1) to i32))) to i32)            ;
<i32*> [#uses=1]

define i32 @main(...) nounwind {
entry:
        %retval = alloca i32            ; <i32*> [#uses=2]
        store i32 0, i32* %retval
        br label %return

return:         ; preds = %entry
        load i32* %retval               ; <i32>:0 [#uses=1]
        ret i32 %0
}

The abort:
[~/ellcc/ellcc] main% llc t0052.ubc
llc: /home/rich/llvm-trunk-new/include/llvm/Support/Casting.h:199: typename
llvm::cast_retty<To, From>::ret_type llvm::cast(const Y&) [with X =
llvm::ConstantInt, Y = llvm::Value*]: Assertion `isa<X>(Val) && "cast<Ty>()
argument of incompatible type!"' failed.
llc[0x8b592da]
llc[0x8b5940c]
[0x110400]
/lib/libc.so.6(abort+0x101)[0xa62f91]
/lib/libc.so.6(__assert_fail+0xee)[0xa5a93e]
llc(_ZN4llvm4castINS_11ConstantIntEPNS_5ValueEEENS_10cast_rettyIT_T0_E8ret_typeERKS6_+0x4c)[0x83f7a70]
llc(_ZNK4llvm10TargetData16getIndexedOffsetEPKNS_4TypeEPKPNS_5ValueEj+0x184)[0x8a6e984]
llc(_ZN4llvm10AsmPrinter21EmitConstantValueOnlyEPKNS_8ConstantE+0x2d6)[0x88d4f3e]
llc(_ZN4llvm10AsmPrinter21EmitConstantValueOnlyEPKNS_8ConstantE+0x51a)[0x88d5182]
llc(_ZN4llvm10AsmPrinter18EmitGlobalConstantEPKNS_8ConstantE+0x1643)[0x88d6a11]
llc[0x863bf5f]
llc[0x863c00f]
llc(_ZN4llvm13FPPassManager14doFinalizationERNS_6ModuleE+0x46)[0x8ae93e6]
llc(_ZN4llvm23FunctionPassManagerImpl14doFinalizationERNS_6ModuleE+0x3f)[0x8ae94e1]
llc(_ZN4llvm19FunctionPassManager14doFinalizationEv+0x28)[0x8ae0a24]
llc(main+0x9d1)[0x83ce1a3]
/lib/libc.so.6(__libc_start_main+0xe0)[0xa4e390]
llc[0x83cc801]
Abort


-- 
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 LLVMbugs mailing list