r191586 - TBAA: use the same format for scalar TBAA and struct-path aware TBAA.
Richard Smith
richard at metafoo.co.uk
Wed Oct 2 11:50:30 PDT 2013
Sorry for the delay. You might be able to reproduce this with:
$ cat repro.cc
#include <set>
void f(std::set<int> *p) { p->equal_range(0); }
$ clang -relaxed-aliasing -O1 -fsanitize=thread repro.cc
I can send you preprocessed source for the above with my version of
libstdc++ if you like. I'm working on a reduced testcase.
On Mon, Sep 30, 2013 at 7:23 PM, Richard Smith <richard at metafoo.co.uk>wrote:
> Hi Manman,
>
> I reverted this commit and follow-up commit r191695 in r191725.
>
> See my messages on llvm-commits for some crashes this triggered. FYI, the
> problematic test case is using -relaxed-aliasing. I'll try to get you a
> reduced testcase tomorrow.
>
>
> On Fri, Sep 27, 2013 at 4:06 PM, Manman Ren <manman.ren at gmail.com> wrote:
>
>> Author: mren
>> Date: Fri Sep 27 18:06:41 2013
>> New Revision: 191586
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=191586&view=rev
>> Log:
>> TBAA: use the same format for scalar TBAA and struct-path aware TBAA.
>>
>> Struct-path aware TBAA generates tags to specify the access path,
>> while scalar TBAA only generates tags to scalar types.
>>
>> Modified:
>> cfe/trunk/lib/CodeGen/CodeGenModule.cpp
>> cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
>> cfe/trunk/test/CodeGen/may-alias.c
>> cfe/trunk/test/CodeGen/tbaa-class.cpp
>> cfe/trunk/test/CodeGen/tbaa-for-vptr.cpp
>> cfe/trunk/test/CodeGen/tbaa-struct.cpp
>> cfe/trunk/test/CodeGen/tbaa.cpp
>>
>> Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=191586&r1=191585&r2=191586&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Fri Sep 27 18:06:41 2013
>> @@ -243,14 +243,14 @@ llvm::MDNode *CodeGenModule::getTBAAStru
>> 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
>>
>> Modified: cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp?rev=191586&r1=191585&r2=191586&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CodeGenTBAA.cpp Fri Sep 27 18:06:41 2013
>> @@ -50,16 +50,11 @@ llvm::MDNode *CodeGenTBAA::getRoot() {
>> return Root;
>> }
>>
>> -// For struct-path aware TBAA, the scalar type has the same format as
>> -// the struct type: name, offset, pointer to another node in the type
>> DAG.
>> -// For scalar TBAA, the scalar type is the same as the scalar tag:
>> -// name and a parent pointer.
>> +// For both scalar TBAA and struct-path aware TBAA, the scalar type has
>> the
>> +// same format: name, parent node, and offset.
>> llvm::MDNode *CodeGenTBAA::createTBAAScalarType(StringRef Name,
>> llvm::MDNode *Parent) {
>> - if (CodeGenOpts.StructPathTBAA)
>> - return MDHelper.createTBAAScalarTypeNode(Name, Parent);
>> - else
>> - return MDHelper.createTBAANode(Name, Parent);
>> + return MDHelper.createTBAAScalarTypeNode(Name, Parent);
>> }
>>
>> llvm::MDNode *CodeGenTBAA::getChar() {
>> @@ -211,8 +206,7 @@ CodeGenTBAA::CollectFields(uint64_t Base
>> uint64_t Offset = BaseOffset;
>> uint64_t Size = Context.getTypeSizeInChars(QTy).getQuantity();
>> llvm::MDNode *TBAAInfo = MayAlias ? getChar() : getTBAAInfo(QTy);
>> - llvm::MDNode *TBAATag = CodeGenOpts.StructPathTBAA ?
>> - getTBAAScalarTagInfo(TBAAInfo) : TBAAInfo;
>> + llvm::MDNode *TBAATag = getTBAAScalarTagInfo(TBAAInfo);
>> Fields.push_back(llvm::MDBuilder::TBAAStructField(Offset, Size,
>> TBAATag));
>> return true;
>> }
>> @@ -293,11 +287,12 @@ CodeGenTBAA::getTBAAStructTypeInfo(QualT
>> return StructMetadataCache[Ty] = NULL;
>> }
>>
>> +/// Return a TBAA tag node for both scalar TBAA and struct-path aware
>> TBAA.
>> llvm::MDNode *
>> CodeGenTBAA::getTBAAStructTagInfo(QualType BaseQTy, llvm::MDNode
>> *AccessNode,
>> uint64_t Offset) {
>> if (!CodeGenOpts.StructPathTBAA)
>> - return AccessNode;
>> + return getTBAAScalarTagInfo(AccessNode);
>>
>> const Type *BTy = Context.getCanonicalType(BaseQTy).getTypePtr();
>> TBAAPathTag PathTag = TBAAPathTag(BTy, AccessNode, Offset);
>>
>> Modified: cfe/trunk/test/CodeGen/may-alias.c
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/may-alias.c?rev=191586&r1=191585&r2=191586&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/test/CodeGen/may-alias.c (original)
>> +++ cfe/trunk/test/CodeGen/may-alias.c Fri Sep 27 18:06:41 2013
>> @@ -27,10 +27,12 @@ void test1(struct Test1MA *p1, struct Te
>> // PATH: store i32 3, i32* {{%.*}}, !tbaa [[TAG_test1_x:!.*]]
>> p2->x = 3;
>> }
>> -// CHECK: metadata !{metadata !"any pointer", metadata [[TAG_CHAR]]}
>> -// CHECK: [[TAG_CHAR]] = metadata !{metadata !"omnipotent char",
>> metadata [[TAG_CXX_TBAA:!.*]]}
>> +// CHECK: metadata !{metadata !"any pointer", metadata [[TYPE_CHAR:!.*]],
>> +// CHECK: [[TYPE_CHAR]] = metadata !{metadata !"omnipotent char",
>> metadata [[TAG_CXX_TBAA:!.*]],
>> // CHECK: [[TAG_CXX_TBAA]] = metadata !{metadata !"Simple C/C++ TBAA"}
>> -// CHECK: [[TAG_INT]] = metadata !{metadata !"int", metadata
>> [[TAG_CHAR]]}
>> +// CHECK: [[TAG_CHAR]] = metadata !{metadata [[TYPE_CHAR]], metadata
>> [[TYPE_CHAR]], i64 0}
>> +// CHECK: [[TAG_INT]] = metadata !{metadata [[TYPE_INT:!.*]], metadata
>> [[TYPE_INT]], i64 0}
>> +// CHECK: [[TYPE_INT]] = metadata !{metadata !"int", metadata
>> [[TYPE_CHAR]]
>>
>> // PATH: [[TYPE_CHAR:!.*]] = metadata !{metadata !"omnipotent char",
>> metadata !{{.*}}
>> // PATH: [[TAG_CHAR]] = metadata !{metadata [[TYPE_CHAR]], metadata
>> [[TYPE_CHAR]], i64 0}
>>
>> Modified: cfe/trunk/test/CodeGen/tbaa-class.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/tbaa-class.cpp?rev=191586&r1=191585&r2=191586&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/test/CodeGen/tbaa-class.cpp (original)
>> +++ cfe/trunk/test/CodeGen/tbaa-class.cpp Fri Sep 27 18:06:41 2013
>> @@ -198,10 +198,12 @@ uint32_t g12(StructC *C, StructD *D, uin
>> return b1->a.f32;
>> }
>>
>> -// CHECK: [[TAG_char:!.*]] = metadata !{metadata !"omnipotent char",
>> metadata [[TAG_cxx_tbaa:!.*]]}
>> +// CHECK: [[TYPE_char:!.*]] = metadata !{metadata !"omnipotent char",
>> metadata [[TAG_cxx_tbaa:!.*]],
>> // CHECK: [[TAG_cxx_tbaa]] = metadata !{metadata !"Simple C/C++ TBAA"}
>> -// CHECK: [[TAG_i32]] = metadata !{metadata !"int", metadata
>> [[TAG_char]]}
>> -// CHECK: [[TAG_i16]] = metadata !{metadata !"short", metadata
>> [[TAG_char]]}
>> +// CHECK: [[TAG_i32]] = metadata !{metadata [[TYPE_i32:!.*]], metadata
>> [[TYPE_i32]], i64 0}
>> +// CHECK: [[TYPE_i32]] = metadata !{metadata !"int", metadata
>> [[TYPE_char]],
>> +// CHECK: [[TAG_i16]] = metadata !{metadata [[TYPE_i16:!.*]], metadata
>> [[TYPE_i16]], i64 0}
>> +// CHECK: [[TYPE_i16]] = metadata !{metadata !"short", metadata
>> [[TYPE_char]],
>>
>> // PATH: [[TYPE_CHAR:!.*]] = metadata !{metadata !"omnipotent char",
>> metadata
>> // PATH: [[TAG_i32]] = metadata !{metadata [[TYPE_INT:!.*]], metadata
>> [[TYPE_INT]], i64 0}
>>
>> Modified: cfe/trunk/test/CodeGen/tbaa-for-vptr.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/tbaa-for-vptr.cpp?rev=191586&r1=191585&r2=191586&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/test/CodeGen/tbaa-for-vptr.cpp (original)
>> +++ cfe/trunk/test/CodeGen/tbaa-for-vptr.cpp Fri Sep 27 18:06:41 2013
>> @@ -23,5 +23,6 @@ void CallFoo(A *a) {
>>
>> // CHECK: %{{.*}} = load {{.*}} !tbaa ![[NUM:[0-9]+]]
>> // CHECK: store {{.*}} !tbaa ![[NUM]]
>> -// CHECK: [[NUM]] = metadata !{metadata !"vtable pointer", metadata
>> !{{.*}}}
>> +// CHECK: [[NUM]] = metadata !{metadata [[TYPE:!.*]], metadata [[TYPE]],
>> i64 0}
>> +// CHECK: [[TYPE]] = metadata !{metadata !"vtable pointer", metadata
>> !{{.*}}
>> // NOTBAA-NOT: = metadata !{metadata !"Simple C/C++ TBAA"}
>>
>> Modified: cfe/trunk/test/CodeGen/tbaa-struct.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/tbaa-struct.cpp?rev=191586&r1=191585&r2=191586&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/test/CodeGen/tbaa-struct.cpp (original)
>> +++ cfe/trunk/test/CodeGen/tbaa-struct.cpp Fri Sep 27 18:06:41 2013
>> @@ -65,10 +65,12 @@ void copy5(struct six *a, struct six *b)
>>
>> // CHECK: [[TS]] = metadata !{i64 0, i64 2, metadata !{{.*}}, i64 4, i64
>> 4, metadata !{{.*}}, i64 8, i64 1, metadata !{{.*}}, i64 12, i64 4,
>> metadata !{{.*}}}
>> // CHECK: [[CHAR:!.*]] = metadata !{metadata !"omnipotent char",
>> metadata !{{.*}}}
>> -// CHECK: [[INT:!.*]] = metadata !{metadata !"int", metadata [[CHAR]]}
>> +// CHECK: [[TAG_INT:!.*]] = metadata !{metadata [[INT:!.*]], metadata
>> [[INT]], i64 0}
>> +// CHECK: [[INT]] = metadata !{metadata !"int", metadata [[CHAR]]
>> +// CHECK: [[TAG_CHAR:!.*]] = metadata !{metadata [[CHAR]], metadata
>> [[CHAR]], i64 0}
>> // (offset, size) = (0,1) char; (4,2) short; (8,4) int; (12,1) char;
>> (16,4) int; (20,4) int
>> // CHECK: [[TS2]] = metadata !{i64 0, i64 1, metadata !{{.*}}, i64 4,
>> i64 2, metadata !{{.*}}, i64 8, i64 4, metadata !{{.*}}, i64 12, i64 1,
>> metadata !{{.*}}, i64 16, i64 4, metadata {{.*}}, i64 20, i64 4, metadata
>> {{.*}}}
>> // (offset, size) = (0,8) char; (0,2) char; (4,8) char
>> // CHECK: [[TS3]] = metadata !{i64 0, i64 8, metadata !{{.*}}, i64 0,
>> i64 2, metadata !{{.*}}, i64 4, i64 8, metadata !{{.*}}}
>> -// CHECK: [[TS4]] = metadata !{i64 0, i64 1, metadata [[CHAR]], i64 1,
>> i64 4, metadata [[INT]], i64 1, i64 1, metadata [[CHAR]], i64 2, i64 1,
>> metadata [[CHAR]]}
>> -// CHECK: [[TS5]] = metadata !{i64 0, i64 1, metadata [[CHAR]], i64 4,
>> i64 4, metadata [[INT]], i64 4, i64 1, metadata [[CHAR]], i64 5, i64 1,
>> metadata [[CHAR]]}
>> +// CHECK: [[TS4]] = metadata !{i64 0, i64 1, metadata [[TAG_CHAR]], i64
>> 1, i64 4, metadata [[TAG_INT]], i64 1, i64 1, metadata [[TAG_CHAR]], i64 2,
>> i64 1, metadata [[TAG_CHAR]]}
>> +// CHECK: [[TS5]] = metadata !{i64 0, i64 1, metadata [[TAG_CHAR]], i64
>> 4, i64 4, metadata [[TAG_INT]], i64 4, i64 1, metadata [[TAG_CHAR]], i64 5,
>> i64 1, metadata [[TAG_CHAR]]}
>>
>> Modified: cfe/trunk/test/CodeGen/tbaa.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/tbaa.cpp?rev=191586&r1=191585&r2=191586&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/test/CodeGen/tbaa.cpp (original)
>> +++ cfe/trunk/test/CodeGen/tbaa.cpp Fri Sep 27 18:06:41 2013
>> @@ -236,10 +236,13 @@ uint32_t g15(StructS *S, StructS3 *S3, u
>> return S->f32;
>> }
>>
>> -// CHECK: [[TAG_char]] = metadata !{metadata !"omnipotent char",
>> metadata [[TAG_cxx_tbaa:!.*]]}
>> +// CHECK: [[TYPE_char:!.*]] = metadata !{metadata !"omnipotent char",
>> metadata [[TAG_cxx_tbaa:!.*]],
>> // CHECK: [[TAG_cxx_tbaa]] = metadata !{metadata !"Simple C/C++ TBAA"}
>> -// CHECK: [[TAG_i32]] = metadata !{metadata !"int", metadata
>> [[TAG_char]]}
>> -// CHECK: [[TAG_i16]] = metadata !{metadata !"short", metadata
>> [[TAG_char]]}
>> +// CHECK: [[TAG_i32]] = metadata !{metadata [[TYPE_i32:!.*]], metadata
>> [[TYPE_i32]], i64 0}
>> +// CHECK: [[TYPE_i32]] = metadata !{metadata !"int", metadata
>> [[TYPE_char]],
>> +// CHECK: [[TAG_i16]] = metadata !{metadata [[TYPE_i16:!.*]], metadata
>> [[TYPE_i16]], i64 0}
>> +// CHECK: [[TYPE_i16]] = metadata !{metadata !"short", metadata
>> [[TYPE_char]],
>> +// CHECK: [[TAG_char]] = metadata !{metadata [[TYPE_char]], metadata
>> [[TYPE_char]], i64 0}
>>
>> // PATH: [[TYPE_CHAR:!.*]] = metadata !{metadata !"omnipotent char",
>> metadata
>> // PATH: [[TAG_i32]] = metadata !{metadata [[TYPE_INT:!.*]], metadata
>> [[TYPE_INT]], i64 0}
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131002/7fc2303d/attachment.html>
More information about the cfe-commits
mailing list