diff options
author | Piotr Padlewski <prazek@google.com> | 2015-09-15 21:46:55 +0000 |
---|---|---|
committer | Piotr Padlewski <prazek@google.com> | 2015-09-15 21:46:55 +0000 |
commit | 4b1ac72cd47f11ec55239dfd2978d85fd8dfbaef (patch) | |
tree | adf2d1e5f704b886d2fe7a3f269c6cf509dc02d1 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 9d0ecf27a70106392780bc5daaa048d0532579fc (diff) | |
download | llvm-4b1ac72cd47f11ec55239dfd2978d85fd8dfbaef.zip llvm-4b1ac72cd47f11ec55239dfd2978d85fd8dfbaef.tar.gz llvm-4b1ac72cd47f11ec55239dfd2978d85fd8dfbaef.tar.bz2 |
Decorating vptr load & stores with !invariant.group
Adding !invariant.group to vptr load/stores for devirtualization purposes.
For more goto:
http://lists.llvm.org/pipermail/cfe-dev/2015-July/044227.html
http://reviews.llvm.org/D12026
llvm-svn: 247725
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index d9bb24e..bb3bbf2 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -507,9 +507,9 @@ llvm::MDNode *CodeGenModule::getTBAAStructTagInfo(QualType BaseTy, /// and struct-path aware TBAA, the tag has the same format: /// base type, access type and offset. /// When ConvertTypeToTag is true, we create a tag based on the scalar type. -void CodeGenModule::DecorateInstruction(llvm::Instruction *Inst, - llvm::MDNode *TBAAInfo, - bool ConvertTypeToTag) { +void CodeGenModule::DecorateInstructionWithTBAA(llvm::Instruction *Inst, + llvm::MDNode *TBAAInfo, + bool ConvertTypeToTag) { if (ConvertTypeToTag && TBAA) Inst->setMetadata(llvm::LLVMContext::MD_tbaa, TBAA->getTBAAScalarTagInfo(TBAAInfo)); @@ -517,6 +517,16 @@ void CodeGenModule::DecorateInstruction(llvm::Instruction *Inst, Inst->setMetadata(llvm::LLVMContext::MD_tbaa, TBAAInfo); } +void CodeGenModule::DecorateInstructionWithInvariantGroup( + llvm::Instruction *I, const CXXRecordDecl *RD) { + llvm::Metadata *MD = CreateMetadataIdentifierForType(QualType(RD->getTypeForDecl(), 0)); + auto *MetaDataNode = dyn_cast<llvm::MDNode>(MD); + // Check if we have to wrap MDString in MDNode. + if (!MetaDataNode) + MetaDataNode = llvm::MDNode::get(getLLVMContext(), MD); + I->setMetadata("invariant.group", MetaDataNode); +} + void CodeGenModule::Error(SourceLocation loc, StringRef message) { unsigned diagID = getDiags().getCustomDiagID(DiagnosticsEngine::Error, "%0"); getDiags().Report(Context.getFullLoc(loc), diagID) << message; |