[LLVMbugs] [Bug 2486] New: llvm incorrectly inlines functions containing setjmp

bugzilla-daemon at cs.uiuc.edu bugzilla-daemon at cs.uiuc.edu
Sun Jun 22 17:53:47 PDT 2008


           Summary: llvm incorrectly inlines functions containing setjmp
           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: sharparrow1 at yahoo.com
                CC: llvmbugs at cs.uiuc.edu


#include <setjmp.h>      
#include <stdio.h>
jmp_buf g;
static int a() {longjmp(g,1);}
static void b(int* x) {if (setjmp(g))return;*x = 10;a();}
int main() {int a = 1; b(&a); printf("%d\n", a); return 0;}

This program should print out "10".

Output with llvm-gcc -O3 -emit-llvm -S:

target datalayout =
target triple = "i386-pc-linux-gnu"
        %struct.__jmp_buf_tag = type { [6 x i32], i32, %struct.__sigset_t }
        %struct.__sigset_t = type { [32 x i32] }
@g = common global [1 x %struct.__jmp_buf_tag] zeroinitializer, align 32       
; <[1 x %struct.__jmp_buf_tag]*> [#uses=1]
@.str = internal constant [4 x i8] c"%d\0A\00"          ; <[4 x i8]*> [#uses=1]

declare i32 @_setjmp(%struct.__jmp_buf_tag*) nounwind 

declare void @longjmp(%struct.__jmp_buf_tag*, i32) noreturn nounwind 

define i32 @main() nounwind  {
        tail call i32 @_setjmp( %struct.__jmp_buf_tag* getelementptr ([1 x
%struct.__jmp_buf_tag]* @g, i32 0, i32 0) ) nounwind                 ; <i32>:0
        icmp eq i32 %0, 0               ; <i1>:1 [#uses=1]
        br i1 %1, label %bb.i, label %b.exit

bb.i:           ; preds = %entry
        tail call void @longjmp( %struct.__jmp_buf_tag* getelementptr ([1 x
%struct.__jmp_buf_tag]* @g, i32 0, i32 0), i32 1 ) noreturn nounwind 

b.exit:         ; preds = %entry
        tail call i32 (i8*, ...)* @printf( i8* noalias  getelementptr ([4 x
i8]* @.str, i32 0, i32 0), i32 1 ) nounwind                 ; <i32>:2 [#uses=0]
        ret i32 0

declare i32 @printf(i8*, ...) nounwind 

As should be obvious, this program prints out "1".

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