aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorPiotr Padlewski <prazek@google.com>2015-09-15 21:46:50 +0000
committerPiotr Padlewski <prazek@google.com>2015-09-15 21:46:50 +0000
commit9d0ecf27a70106392780bc5daaa048d0532579fc (patch)
treeea21020787736504c4589cb62ff791c0cfea0edd /clang/lib/CodeGen/CodeGenModule.cpp
parent338c9d0ade222e60bca1ad9f76fb837d071bd41f (diff)
downloadllvm-9d0ecf27a70106392780bc5daaa048d0532579fc.zip
llvm-9d0ecf27a70106392780bc5daaa048d0532579fc.tar.gz
llvm-9d0ecf27a70106392780bc5daaa048d0532579fc.tar.bz2
Added llvm.module flag for strict vtable pointers
It is dangerous to do LTO on code with strict-vtable-pointers, because one module has invariant.group.barriers, and the other one not. In the future I want to just strip all invariant.group metadata from vptrs loads/stores and get rid of invariant.group.barrier calls. http://reviews.llvm.org/D12580 llvm-svn: 247724
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index b679f32..d9bb24e 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -398,6 +398,22 @@ void CodeGenModule::Release() {
// Indicate that we want CodeView in the metadata.
getModule().addModuleFlag(llvm::Module::Warning, "CodeView", 1);
}
+ if (CodeGenOpts.OptimizationLevel > 0 && CodeGenOpts.StrictVTablePointers) {
+ // We don't support LTO with 2 with different StrictVTablePointers
+ // FIXME: we could support it by stripping all the information introduced
+ // by StrictVTablePointers.
+
+ getModule().addModuleFlag(llvm::Module::Error, "StrictVTablePointers",1);
+
+ llvm::Metadata *Ops[2] = {
+ llvm::MDString::get(VMContext, "StrictVTablePointers"),
+ llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
+ llvm::Type::getInt32Ty(VMContext), 1))};
+
+ getModule().addModuleFlag(llvm::Module::Require,
+ "StrictVTablePointersRequirement",
+ llvm::MDNode::get(VMContext, Ops));
+ }
if (DebugInfo)
// We support a single version in the linked module. The LLVM
// parser will drop debug info with a different version number