[BPF] handle external global properly
authorYonghong Song <yhs@fb.com>
Fri, 15 Mar 2019 17:39:10 +0000 (17:39 +0000)
committerYonghong Song <yhs@fb.com>
Fri, 15 Mar 2019 17:39:10 +0000 (17:39 +0000)
commit44ed286a2f80ba9b4d8a1b0ff84f44914915ea97
treede410bf898b5da069af4361a31b0f18356c8e49e
parent1cbbab9277af09f2da3f7eba7391452e8da8fe79
[BPF] handle external global properly

Previous commit 6bc58e6d3dbd ("[BPF] do not generate unused local/global types")
tried to exclude global variable from type generation. The condition is:
     if (Global.hasExternalLinkage())
       continue;
This is not right. It also excluded initialized globals.

The correct condition (from AssemblyWriter::printGlobal()) is:
  if (!GV->hasInitializer() && GV->hasExternalLinkage())
    Out << "external ";

Let us do the same in BTF type generation. Also added a test for it.

Signed-off-by: Yonghong Song <yhs@fb.com>
llvm-svn: 356279
llvm/lib/Target/BPF/BTFDebug.cpp
llvm/test/CodeGen/BPF/BTF/global-var-inited.ll [new file with mode: 0644]