From 44ed286a2f80ba9b4d8a1b0ff84f44914915ea97 Mon Sep 17 00:00:00 2001 From: Yonghong Song Date: Fri, 15 Mar 2019 17:39:10 +0000 Subject: [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 llvm-svn: 356279 --- llvm/lib/Target/BPF/BTFDebug.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'llvm/lib/Target/BPF/BTFDebug.cpp') diff --git a/llvm/lib/Target/BPF/BTFDebug.cpp b/llvm/lib/Target/BPF/BTFDebug.cpp index 5d1d96fa4cd..d00bc015835 100644 --- a/llvm/lib/Target/BPF/BTFDebug.cpp +++ b/llvm/lib/Target/BPF/BTFDebug.cpp @@ -751,7 +751,7 @@ void BTFDebug::endModule() { const Module *M = MMI->getModule(); for (const GlobalVariable &Global : M->globals()) { // Ignore external globals for now. - if (Global.hasExternalLinkage()) + if (!Global.hasInitializer() && Global.hasExternalLinkage()) continue; SmallVector GVs; -- cgit v1.2.3