This was causing us to miscompile
llvm::SymbolTableListTraits::getListOwner(), which uses data member
pointers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@196545
91177308-0d34-0410-b5e6-
96231b3b80d8
Base = AdjustVirtualBase(CGF, RD, Base, VirtualBaseAdjustmentOffset,
VBPtrOffset);
}
+
+ // Cast to char*.
+ Base = Builder.CreateBitCast(Base, Builder.getInt8Ty()->getPointerTo(AS));
+
+ // Apply the offset, which we assume is non-null.
llvm::Value *Addr =
Builder.CreateInBoundsGEP(Base, FieldOffset, "memptr.offset");
}
}
+
+namespace Test3 {
+// Make sure we cast 'this' to i8* before using GEP.
+
+struct A {
+ int a;
+ int b;
+};
+
+int *load_data(A *a, int A::*mp) {
+ return &(a->*mp);
+// CHECK-LABEL: define i32* @"\01?load_data@Test3@@YAPAHPAUA@1@PQ21@H@Z"{{.*}} {
+// CHECK: %[[a:.*]] = load %"struct.Test3::A"** %{{.*}}, align 4
+// CHECK: %[[mp:.*]] = load i32* %{{.*}}, align 4
+// CHECK: %[[a_i8:.*]] = bitcast %"struct.Test3::A"* %[[a]] to i8*
+// CHECK: getelementptr inbounds i8* %[[a_i8]], i32 %[[mp]]
+// CHECK: }
+}
+
+}