llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Operands of blockaddress incorrect when function is inlined.

Open ahatanak opened this issue 15 years ago • 2 comments

Bugzilla Link 10162
Resolution FIXED
Resolved on Oct 21, 2011 15:45
Version trunk
OS Linux
CC @efriedma-quic

Extended Description

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}

ahatanak avatar Jun 20 '11 22:06 ahatanak

r142684.

efriedma-quic avatar Oct 21 '11 22:10 efriedma-quic

I see two issues here: one, constructing a bad blockaddress like this in memory doesn't trigger any assertions or the verifier, and two, I'm not really sure what the inliner is actually expected to do here. (The whole idea of trying to remap block addresses in the way ValueMapper does it seems very suspicious.)

efriedma-quic avatar Jun 21 '11 01:06 efriedma-quic