Closed pcc closed 6 years ago
r326960
For the vtordisp lines:
This walks VBaseMap in iteration order: http://llvm-cs.pcc.me.uk/tools/clang/lib/CodeGen/MicrosoftCXXABI.cpp#1199
for (VBOffsets::const_iterator I = VBaseMap.begin(), E = VBaseMap.end(); I != E; ++I) { ... }
VBaseMap has type ASTRecordLayout::VBaseOffsetsMapTy which is a llvm::DenseMap<const CXXRecordDecl *, VBaseInfo> -- so even if DenseMap promises sorted iteration order, it'd be sorted by pointer value.
The vbtableNs are probably from the same loop actually: The loop calls GetVirtualBaseClassOffset() which calls GetVBaseOffsetFromVBPtr() which creates the vbtableN vars.
The loop initializes some in-memory structures (it's in initializeHiddenVirtualInheritanceMembers()), and the nondeterminism only means that we do this in a different order. So we should fix it, but it's not a flaky miscompile.
Extended Description
$ clang -cc1 -internal-isystem .../lib/clang/7.0.0/include -nostdsysteminc .../clang/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp -fno-rtti -std=c++11 -Wno-inaccessible-base -triple=i386-pc-win32 -emit-llvm -o - > /tmp/1 $ clang -cc1 -internal-isystem .../lib/clang/7.0.0/include -nostdsysteminc .../clang/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp -fno-rtti -std=c++11 -Wno-inaccessible-base -triple=i386-pc-win32 -emit-llvm -o - | diff -u /tmp/1 -
shows a diff most of the time, e.g.
--- /tmp/1 2018-01-30 17:18:22.750623402 -0800 +++ - 2018-01-30 17:28:37.603706299 -0800 @@ -618,10 +618,10 @@ %vbptr16 = getelementptr inbounds i8, i8 %35, i32 0 %36 = bitcast i8 %vbptr16 to i32* %vbtable17 = load i32, i32** %36, align 4