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
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user