barannikov88 added inline comments.
================ Comment at: clang/test/CodeGenCXX/const-init-cxx11.cpp:353 }; - // CHECK: @_ZN14VirtualMembersL13sGlobalMemoryE = internal global { i8** } { i8** getelementptr inbounds ({ [3 x i8*] }, { [3 x i8*] }* @_ZTVN14VirtualMembers12nsMemoryImplE, i32 0, inrange i32 0, i32 2) } + // CHECK: @_ZN14VirtualMembersL13sGlobalMemoryE = internal global %"struct.VirtualMembers::nsMemoryImpl" { ptr getelementptr inbounds ({ [3 x ptr] }, ptr @_ZTVN14VirtualMembers12nsMemoryImplE, i32 0, inrange i32 0, i32 2) } __attribute__((used)) ---------------- nikic wrote: > barannikov88 wrote: > > This was one suspicious change. An anonymous struct became named. > > > Not sure why exactly this happened, but should be harmless. I believe we > sometimes generate anon structs for initializaton because the types used for > initialization are not always compatible with the nominal LLVM memory type -- > I guess there previously was a mismatch in pointer types here or something. This is where the behavior diverges: ``` llvm::Constant *ConstantAggregateBuilder::buildFrom( CodeGenModule &CGM, ArrayRef<llvm::Constant *> Elems, ArrayRef<CharUnits> Offsets, CharUnits StartOffset, CharUnits Size, bool NaturalLayout, llvm::Type *DesiredTy, bool AllowOversized) { ... // Pick the type to use. If the type is layout identical to the desired // type then use it, otherwise use whatever the builder produced for us. if (llvm::StructType *DesiredSTy = dyn_cast<llvm::StructType>(DesiredTy)) { if (DesiredSTy->isLayoutIdentical(STy)) STy = DesiredSTy; } ... ``` With typed pointers, STy and DesiredSTy respectively are: ``` { i8** } %struct.nsMemoryImpl = type { i32 (...)** } ``` `isLayoutIdentical`, despite its name, actually checks for full equivalence of structs, not just the layout. That is, it is no different from `operator==`. The code snippet above is the only use of `isLayoutIdentical`. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D150887/new/ https://reviews.llvm.org/D150887 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits