[llvm-dev] RFC: We need to explicitly state that some functions are reserved by LLVM

Chris Lattner via llvm-dev llvm-dev at lists.llvm.org
Thu Oct 26 20:53:58 PDT 2017


On Oct 26, 2017, at 8:14 PM, Chandler Carruth via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> I've gotten a fantastic bug report. Consider the LLVM IR:
> 
> target triple = "x86_64-unknown-linux-gnu"
> 
> define internal i8* @access({ i8* }* %arg, i64) {
>   ret i8* undef
> }
> 
> define i8* @g({ i8* }* %arg) {
> bb:
>   %tmp = alloca { i8* }*, align 8
>   store { i8* }* %arg, { i8* }** %tmp, align 8
>   br i1 undef, label %bb4, label %bb1
> 
> bb1:
>   %tmp2 = load { i8* }*, { i8* }** %tmp, align 8
>   %tmp3 = call i8* @access({ i8* }* %tmp2, i64 undef)
>   br label %bb4
> 
> bb4:
>   ret i8* undef
> }
> 
> This IR, if compiled with `opt -passes='cgscc(inline,argpromotion)' -disable-output` hits a bunch of asserts in the LazyCallGraph.
> 
> The problem here is that `argpromotion` turns a normal looking function `i8* @access({ i8* }* %arg, i64)` and turn it into a magical function `i8* @access(i8* %arg, i64)`. This latter signature is the POSIX `access` function that LLVM's `TargetLibraryInfo` knows magical things about.

I don’t think this is an argpromotion bug.  We don’t want any transformation that changes internal functions to know about these sorts of things.

I think the right fix is to make TargetLibraryInfo treat non-externally visible functions as unknown.

-Chris



More information about the llvm-dev mailing list