mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
TBAA: add isTBAAVtableAccess to MDNode so clients can call the function
instead of having its own implementation. The implementation of isTBAAVtableAccess is in TypeBasedAliasAnalysis.cpp since it is related to the format of TBAA metadata. The path for struct-path tbaa will be exercised by test/Instrumentation/ThreadSanitizer/read_from_global.ll, vptr_read.ll, and vptr_update.ll when struct-path tbaa is on by default. llvm-svn: 190216
This commit is contained in:
parent
450526b5a9
commit
de03bcdbec
@ -161,6 +161,9 @@ public:
|
||||
return V->getValueID() == MDNodeVal;
|
||||
}
|
||||
|
||||
/// Check whether MDNode is a vtable access.
|
||||
bool isTBAAVtableAccess() const;
|
||||
|
||||
/// Methods for metadata merging.
|
||||
static MDNode *getMostGenericTBAA(MDNode *A, MDNode *B);
|
||||
static MDNode *getMostGenericFPMath(MDNode *A, MDNode *B);
|
||||
|
@ -458,6 +458,25 @@ TypeBasedAliasAnalysis::getModRefInfo(ImmutableCallSite CS1,
|
||||
return AliasAnalysis::getModRefInfo(CS1, CS2);
|
||||
}
|
||||
|
||||
bool MDNode::isTBAAVtableAccess() const {
|
||||
if (!EnableStructPathTBAA) {
|
||||
if (getNumOperands() < 1) return false;
|
||||
if (MDString *Tag1 = dyn_cast<MDString>(getOperand(0))) {
|
||||
if (Tag1->getString() == "vtable pointer") return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// For struct-path aware TBAA, we use the access type of the tag.
|
||||
if (getNumOperands() < 2) return false;
|
||||
MDNode *Tag = cast_or_null<MDNode>(getOperand(1));
|
||||
if (!Tag) return false;
|
||||
if (MDString *Tag1 = dyn_cast<MDString>(Tag->getOperand(0))) {
|
||||
if (Tag1->getString() == "vtable pointer") return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
MDNode *MDNode::getMostGenericTBAA(MDNode *A, MDNode *B) {
|
||||
if (!A || !B)
|
||||
return NULL;
|
||||
|
@ -240,12 +240,8 @@ bool ThreadSanitizer::doInitialization(Module &M) {
|
||||
}
|
||||
|
||||
static bool isVtableAccess(Instruction *I) {
|
||||
if (MDNode *Tag = I->getMetadata(LLVMContext::MD_tbaa)) {
|
||||
if (Tag->getNumOperands() < 1) return false;
|
||||
if (MDString *Tag1 = dyn_cast<MDString>(Tag->getOperand(0))) {
|
||||
if (Tag1->getString() == "vtable pointer") return true;
|
||||
}
|
||||
}
|
||||
if (MDNode *Tag = I->getMetadata(LLVMContext::MD_tbaa))
|
||||
return Tag->isTBAAVtableAccess();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user