[LLVMbugs] [Bug 10162] New: Operands of blockaddress incorrect when function is inlined.

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Jun 20 13:46:38 PDT 2011


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

           Summary: Operands of blockaddress incorrect when function is
                    inlined.
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: ahatanak at gmail.com
                CC: llvmbugs at cs.uiuc.edu


Compiling the code shown below (990208-1.c, adapted from torture test) with
clang and llc fails with the following error message:

$ clang 990208-1.c -o 990208-1.x86.ll -O3 -emit-llvm -S
$ llc 990208-1.x86.ll -o -
llc: 990208-1.x86.ll:27:33: error: referenced value is not a basic block
  store i8* blockaddress(@doit, %here.i), i8** @ptr1, align 8, !tbaa !0

There are no errors if __attribute__ ((noinline)) is added to function doit.

/// 990208-1.c
void *ptr1;
int i = 1;

//__attribute__ ((noinline))
void doit(void **pptr, int cond)
{
  if (cond) {
  //++i;
  here:
    *pptr = &&here;
  }
}

void f(int cond)
{
  doit (&ptr1, cond);
}

/// 990208-1.x86.ll
; ModuleID = '990208-1.c'
target datalayout =
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
target triple = "x86_64-unknown-linux-gnu"

@i = global i32 1, align 4
@ptr1 = common global i8* null, align 8

define void @doit(i8** nocapture %pptr, i32 %cond) nounwind uwtable {
entry:
  %tobool = icmp eq i32 %cond, 0
  br i1 %tobool, label %if.end, label %here

here:                                             ; preds = %entry
  store i8* blockaddress(@doit, %here), i8** %pptr, align 8, !tbaa !0
  br label %if.end

if.end:                                           ; preds = %entry, %here
  ret void
}

define void @f(i32 %cond) nounwind uwtable {
entry:
  %tobool.i = icmp eq i32 %cond, 0
  br i1 %tobool.i, label %doit.exit, label %here.i

here.i:                                           ; preds = %entry
  store i8* blockaddress(@doit, %here.i), i8** @ptr1, align 8, !tbaa !0
  br label %doit.exit

doit.exit:                                        ; preds = %entry, %here.i
  ret void
}

!0 = metadata !{metadata !"any pointer", metadata !1}
!1 = metadata !{metadata !"omnipotent char", metadata !2}
!2 = metadata !{metadata !"Simple C/C++ TBAA", null}

-- 
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