r326960 - [ms] Emit vtordisp initializers in a deterministic order.

Nico Weber via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 7 15:15:20 PST 2018


Author: nico
Date: Wed Mar  7 15:15:20 2018
New Revision: 326960

URL: http://llvm.org/viewvc/llvm-project?rev=326960&view=rev
Log:
[ms] Emit vtordisp initializers in a deterministic order.

No effective behavior change, just for cleanliness.
Analysis and typing by me, actual patch mostly by Reid.

Fixes PR36159.
https://reviews.llvm.org/D44223

Modified:
    cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp

Modified: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp?rev=326960&r1=326959&r2=326960&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp Wed Mar  7 15:15:20 2018
@@ -1196,15 +1196,16 @@ void MicrosoftCXXABI::initializeHiddenVi
   unsigned AS = getThisAddress(CGF).getAddressSpace();
   llvm::Value *Int8This = nullptr;  // Initialize lazily.
 
-  for (VBOffsets::const_iterator I = VBaseMap.begin(), E = VBaseMap.end();
-        I != E; ++I) {
+  for (const CXXBaseSpecifier &S : RD->vbases()) {
+    const CXXRecordDecl *VBase = S.getType()->getAsCXXRecordDecl();
+    auto I = VBaseMap.find(VBase);
+    assert(I != VBaseMap.end());
     if (!I->second.hasVtorDisp())
       continue;
 
     llvm::Value *VBaseOffset =
-        GetVirtualBaseClassOffset(CGF, getThisAddress(CGF), RD, I->first);
-    uint64_t ConstantVBaseOffset =
-        Layout.getVBaseClassOffset(I->first).getQuantity();
+        GetVirtualBaseClassOffset(CGF, getThisAddress(CGF), RD, VBase);
+    uint64_t ConstantVBaseOffset = I->second.VBaseOffset.getQuantity();
 
     // vtorDisp_for_vbase = vbptr[vbase_idx] - offsetof(RD, vbase).
     llvm::Value *VtorDispValue = Builder.CreateSub(




More information about the cfe-commits mailing list