[LLVMdev] noreturn attribute on a call instruction vs noreturn on a function

170 views
Skip to first unread message

Kostya Serebryany

unread,
Nov 28, 2012, 8:47:16 AM11/28/12
to llv...@cs.uiuc.edu
Hi, 

Building the following C code I get a call instruction that has no noreturn attribute, while the function itself does have it. 

void foo(void **b) {
  __builtin_longjmp(b, 1);
}


define void @_Z3fooPPv(i8** %b) noreturn nounwind uwtable {
entry:
  %0 = bitcast i8** %b to i8*
  tail call void @llvm.eh.sjlj.longjmp(i8* %0)   <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  unreachable
}

declare void @llvm.eh.sjlj.longjmp(i8*) noreturn nounwind  <<<<<<<<<<<<<<<<<


I've hit this in asan where it checks the noreturn attribute in the call instruction, but not in the function object. 
Who is wrong here? Should asan also check noreturn in the called function? 

Thanks, 

--kcc 

Duncan Sands

unread,
Nov 28, 2012, 11:05:24 AM11/28/12
to llv...@cs.uiuc.edu
Hi Kostya,
I think you should consider the call no-return if either the call or the
callee has the no-return attribute.

Ciao, Duncan.

>
> Thanks,
>
> --kcc
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLV...@cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>

_______________________________________________
LLVM Developers mailing list
LLV...@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

Kostya Serebryany

unread,
Nov 29, 2012, 3:58:05 AM11/29/12
to Duncan Sands, llv...@cs.uiuc.edu
On Wed, Nov 28, 2012 at 8:05 PM, Duncan Sands <bald...@free.fr> wrote:
Hi Kostya,


On 28/11/12 14:47, Kostya Serebryany wrote:
Hi,

Building the following C code I get a call instruction that has no noreturn
attribute, while the function itself does have it.

void foo(void **b) {
   __builtin_longjmp(b, 1);
}


define void @_Z3fooPPv(i8** %b) noreturn nounwind uwtable {
entry:
   %0 = bitcast i8** %b to i8*
   tail call void @llvm.eh.sjlj.longjmp(i8* %0)
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
   unreachable
}

declare void @llvm.eh.sjlj.longjmp(i8*) noreturn nounwind  <<<<<<<<<<<<<<<<<


I've hit this in asan where it checks the noreturn attribute in the call
instruction, but not in the function object.
Who is wrong here? Should asan also check noreturn in the called function?

I think you should consider the call no-return if either the call or the
callee has the no-return attribute.

Thanks, I've fixed this in asan pass. 

--kcc 

Nuno Lopes

unread,
Nov 29, 2012, 5:21:00 PM11/29/12
to Kostya Serebryany, llv...@cs.uiuc.edu
You can use CallInst::hasFnAttr(). It checks for attributes in the
instruction and in the function decl.

http://llvm.org/docs/doxygen/html/Instructions_8cpp_source.html#l00345

Nuno

Kostya Serebryany

unread,
Nov 30, 2012, 6:13:17 AM11/30/12
to Nuno Lopes, llv...@cs.uiuc.edu
On Fri, Nov 30, 2012 at 2:21 AM, Nuno Lopes <nunop...@sapo.pt> wrote:
You can use CallInst::hasFnAttr().  It checks for attributes in the instruction and in the function decl.

Indeed.... 
And we have 
    bool doesNotReturn() const { return hasFnAttr(Attributes::NoReturn); }
and asan code called CI->doesNotReturn  and it did not work, but now it works. 
Hmm. 
Anyway, thanks! 

--kcc 
Reply all
Reply to author
Forward
0 new messages