[llvm-dev] tbaa error: Access type node must be a valid scalar type

Sanjoy Das via llvm-dev llvm-dev at lists.llvm.org
Sat May 19 15:33:40 PDT 2018


Hi Nat,

On Sat, May 19, 2018 at 2:49 PM, Nat! via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> I am upgrading my clang fork from 5.0 to 6.0 and I am hit by this error:
>
> Access type node must be a valid scalar type
>
>   %4 = load %"struct.Foo::p.test1::"*, %"struct.Foo::p.test1::"**
> %_param.addr, align 8, !tbaa !16
> !16 = !{!15, !15, i64 0}
> !15 = !{!"p.test1::", !13, i64 0, !13, i64 8}
>
> It looks like !16 is referencing !15, which is a struct. !13 is
> !13 = !{!"any pointer", !8, i64 0}
>
> But the %4 instruction just deals with pointers, so why is there a problem ?
> The code itself is generated using clang CodeGen routines.
> (I wouldn't even know how to manipulate !tbaa directly :)

The TBAA scheme is described in more detail here
https://llvm.org/docs/LangRef.html#id918 but I suspect the correct
TBAA metadata is  "!16 = !{!15, !13, i64 0}"

Right now the "!tbaa !16" with "!16 = !{!15, !15, i64 0}" tag is
roughly saying "this loads a scalar of type !15 from a pointer of type
!15" which isn't quite right -- it is loading a scalar of type !13 ==
(any pointer) from a pointer of type !15.

> If I remove the !tbaa from %4, llc assembles it fine.
> My compiler output didn't change.When I use the 5.0 compiler I get the same
> (wrong ?) tbaa output. But it didn't used to matter.

It probably did matter, in that before LLVM would silently infer bogus
aliasing information :)

For a quick fix, you can consider dropping TBAA metadata that does not
verify.  See how TBAAVerifier is used in BitcodeReader.

-- Sanjoy


More information about the llvm-dev mailing list