TBAA: use the same format for scalar TBAA and struct-path aware TBAA.
An updated version of r191586 with bug fix. Struct-path aware TBAA generates tags to specify the access path, while scalar TBAA only generates tags to scalar types. We should not generate a TBAA tag with null being the first field. When a TBAA type node is null, the tag should be null too. Make sure we don't decorate an instruction with a null TBAA tag. Added a testing case for the bug reported by Richard with -relaxed-aliasing and -fsanitizer=thread. llvm-svn: 192145
This commit is contained in:
@@ -243,14 +243,14 @@ llvm::MDNode *CodeGenModule::getTBAAStructTagInfo(QualType BaseTy,
|
||||
return TBAA->getTBAAStructTagInfo(BaseTy, AccessN, O);
|
||||
}
|
||||
|
||||
/// Decorate the instruction with a TBAA tag. For scalar TBAA, the tag
|
||||
/// is the same as the type. For struct-path aware TBAA, the tag
|
||||
/// is different from the type: base type, access type and offset.
|
||||
/// Decorate the instruction with a TBAA tag. For both scalar TBAA
|
||||
/// 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) {
|
||||
if (ConvertTypeToTag && TBAA && CodeGenOpts.StructPathTBAA)
|
||||
if (ConvertTypeToTag && TBAA)
|
||||
Inst->setMetadata(llvm::LLVMContext::MD_tbaa,
|
||||
TBAA->getTBAAScalarTagInfo(TBAAInfo));
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user