summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2019-07-29 17:22:40 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2019-07-29 17:22:40 +0000
commitdd9682196be6741879c76fa12e89164537d1f96d (patch)
tree95e7edad50d26ec1f870a0655faa459a0a8c934e /llvm/lib
parent6a253d378bc05c30b3d9f32fdaf973714de3e99c (diff)
downloadbcm5719-llvm-dd9682196be6741879c76fa12e89164537d1f96d.tar.gz
bcm5719-llvm-dd9682196be6741879c76fa12e89164537d1f96d.zip
ThinLTOBitcodeWriter: Include globals associated with type metadata globals in the merged module.
Globals that are associated with globals with type metadata need to appear in the merged module because they will reference the global's section directly. Differential Revision: https://reviews.llvm.org/D65312 llvm-svn: 367242
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp b/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
index 24c476376c1..f0dea11e1b1 100644
--- a/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
+++ b/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp
@@ -218,10 +218,18 @@ void splitAndWriteThinLTOBitcode(
promoteTypeIds(M, ModuleId);
- // Returns whether a global has attached type metadata. Such globals may
- // participate in CFI or whole-program devirtualization, so they need to
- // appear in the merged module instead of the thin LTO module.
+ // Returns whether a global or its associated global has attached type
+ // metadata. The former may participate in CFI or whole-program
+ // devirtualization, so they need to appear in the merged module instead of
+ // the thin LTO module. Similarly, globals that are associated with globals
+ // with type metadata need to appear in the merged module because they will
+ // reference the global's section directly.
auto HasTypeMetadata = [](const GlobalObject *GO) {
+ if (MDNode *MD = GO->getMetadata(LLVMContext::MD_associated))
+ if (auto *AssocVM = dyn_cast_or_null<ValueAsMetadata>(MD->getOperand(0)))
+ if (auto *AssocGO = dyn_cast<GlobalObject>(AssocVM->getValue()))
+ if (AssocGO->hasMetadata(LLVMContext::MD_type))
+ return true;
return GO->hasMetadata(LLVMContext::MD_type);
};
OpenPOWER on IntegriCloud