forked from OSchip/llvm-project
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
This commit is contained in:
parent
338c9d0ade
commit
9d0ecf27a7
|
@ -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
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// RUN: FileCheck --check-prefix=CHECK-CTORS %s < %t.ll
|
||||
// RUN: FileCheck --check-prefix=CHECK-NEW %s < %t.ll
|
||||
// RUN: FileCheck --check-prefix=CHECK-DTORS %s < %t.ll
|
||||
// RUN: FileCheck --check-prefix=CHECK-LINK-REQ %s < %t.ll
|
||||
|
||||
typedef __typeof__(sizeof(0)) size_t;
|
||||
void *operator new(size_t, void*) throw();
|
||||
|
@ -191,3 +192,11 @@ struct DynamicFromStatic;
|
|||
// CHECK-DTORS-LABEL: define linkonce_odr void @_ZN14DynamicDerivedD2Ev
|
||||
// CHECK-DTORS-NOT: call i8* @llvm.invariant.group.barrier(
|
||||
// CHECK-DTORS-LABEL: }
|
||||
|
||||
|
||||
// CHECK-LINK-REQ: !llvm.module.flags = !{![[FIRST:.*]], ![[SEC:.*]]{{.*}}}
|
||||
|
||||
// CHECK-LINK-REQ: ![[FIRST]] = !{i32 1, !"StrictVTablePointers", i32 1}
|
||||
// CHECK-LINK-REQ: ![[SEC]] = !{i32 3, !"StrictVTablePointersRequirement", ![[META:.*]]}
|
||||
// CHECK-LINK-REQ: ![[META]] = !{!"StrictVTablePointers", i32 1}
|
||||
|
||||
|
|
Loading…
Reference in New Issue