diff options
author | Timur Iskhodzhanov <timurrrr@google.com> | 2013-10-22 18:15:24 +0000 |
---|---|---|
committer | Timur Iskhodzhanov <timurrrr@google.com> | 2013-10-22 18:15:24 +0000 |
commit | 827365ea8f535d1a6749cf40957006c7484f15a7 (patch) | |
tree | b73f3cccdaaaf7c179aac073dfc63426a185684f /clang/lib/CodeGen/MicrosoftCXXABI.cpp | |
parent | d70a055394ee16eef09dd031369e24472005da73 (diff) | |
download | bcm5719-llvm-827365ea8f535d1a6749cf40957006c7484f15a7.tar.gz bcm5719-llvm-827365ea8f535d1a6749cf40957006c7484f15a7.zip |
Use GEPs correctly when adjusting this in MicrosoftCXXABI
Reviewed at http://llvm-reviews.chandlerc.com/D1977
llvm-svn: 193176
Diffstat (limited to 'clang/lib/CodeGen/MicrosoftCXXABI.cpp')
-rw-r--r-- | clang/lib/CodeGen/MicrosoftCXXABI.cpp | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/MicrosoftCXXABI.cpp b/clang/lib/CodeGen/MicrosoftCXXABI.cpp index ba7de89b2fc..48bf6844f7f 100644 --- a/clang/lib/CodeGen/MicrosoftCXXABI.cpp +++ b/clang/lib/CodeGen/MicrosoftCXXABI.cpp @@ -632,8 +632,16 @@ llvm::Value *MicrosoftCXXABI::adjustThisArgumentForVirtualCall( if (!StaticOffset.isZero()) { assert(StaticOffset.isPositive()); This = CGF.Builder.CreateBitCast(This, charPtrTy); - This = CGF.Builder - .CreateConstInBoundsGEP1_64(This, StaticOffset.getQuantity()); + if (ML.VBase) { + // Non-virtual adjustment might result in a pointer outside the allocated + // object, e.g. if the final overrider class is laid out after the virtual + // base that declares a method in the most derived class. + // FIXME: Update the code that emits this adjustment in thunks prologues. + This = CGF.Builder.CreateConstGEP1_32(This, StaticOffset.getQuantity()); + } else { + This = CGF.Builder.CreateConstInBoundsGEP1_32(This, + StaticOffset.getQuantity()); + } } return This; } @@ -713,7 +721,8 @@ llvm::Value *MicrosoftCXXABI::adjustThisParameterInVirtualFunctionPrologue( This = CGF.Builder.CreateBitCast(This, charPtrTy); assert(Adjustment.isPositive()); - This = CGF.Builder.CreateConstGEP1_64(This, -Adjustment.getQuantity()); + This = + CGF.Builder.CreateConstInBoundsGEP1_32(This, -Adjustment.getQuantity()); return CGF.Builder.CreateBitCast(This, thisTy); } |