aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
authorYonghong Song <yhs@fb.com>2020-10-06 20:29:09 -0700
committerYonghong Song <yhs@fb.com>2020-10-06 22:37:49 -0700
commitedd71db38b0c2292e6a36fb789a3ec3cbde6a023 (patch)
treef238a81db8bce94e2048454abf3ad1301df0b20d /llvm/lib/Bitcode/Reader/BitcodeReader.cpp
parent0c009e092e29a3dff16c5c0522979341fab3be62 (diff)
downloadllvm-edd71db38b0c2292e6a36fb789a3ec3cbde6a023.zip
llvm-edd71db38b0c2292e6a36fb789a3ec3cbde6a023.tar.gz
llvm-edd71db38b0c2292e6a36fb789a3ec3cbde6a023.tar.bz2
BPF: avoid duplicated globals for CORE relocations
This patch fixed two issues related with relocation globals. In LLVM, if a global, e.g. with name "g", is created and conflict with another global with the same name, LLVM will rename the global, e.g., with a new name "g.2". Since relocation global name has special meaning, we do not want llvm to change it, so internally we have logic to check whether duplication happens or not. If happens, just reuse the previous global. The first bug is related to non-btf-id relocation (BPFAbstractMemberAccess.cpp). Commit 54d9f743c8b0 ("BPF: move AbstractMemberAccess and PreserveDIType passes to EP_EarlyAsPossible") changed ModulePass to FunctionPass, i.e., handling each function at a time. But still just one BPFAbstractMemberAccess object is created so module level de-duplication still possible. Commit 40251fee0084 ("[BPF][NewPM] Make BPFTargetMachine properly adjust NPM optimizer pipeline") made a change to create a BPFAbstractMemberAccess object per function so module level de-duplication is not possible any more without going through all module globals. This patch simply changed the map which holds reloc globals as class static, so it will be available to all BPFAbstractMemberAccess objects for different functions. The second bug is related to btf-id relocation (BPFPreserveDIType.cpp). Before Commit 54d9f743c8b0, the pass is a ModulePass, so we have a local variable, incremented for each instance, and works fine. But after Commit 54d9f743c8b0, the pass becomes a FunctionPass. Local variable won't work properly since different functions will start with the same initial value. Fix the issue by change the local count variable as static, so it will be truely unique across the whole module compilation. Differential Revision: https://reviews.llvm.org/D88942
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
0 files changed, 0 insertions, 0 deletions