diff options
author | Eric Christopher <echristo@gmail.com> | 2020-07-16 11:40:43 -0700 |
---|---|---|
committer | Eric Christopher <echristo@gmail.com> | 2020-07-16 11:54:04 -0700 |
commit | 7bfaa40086359ed7e41c862ab0a65e0bb1be0aeb (patch) | |
tree | 3379937970fda6a5f2f62bb05c21d37c73deec26 /clang/lib/CodeGen/CodeGenFunction.cpp | |
parent | 8f0a8ed44e27c694b3b32721f913f32048564e5e (diff) | |
download | llvm-7bfaa40086359ed7e41c862ab0a65e0bb1be0aeb.zip llvm-7bfaa40086359ed7e41c862ab0a65e0bb1be0aeb.tar.gz llvm-7bfaa40086359ed7e41c862ab0a65e0bb1be0aeb.tar.bz2 |
Temporarily Revert "[AssumeBundles] Use operand bundles to encode alignment assumptions"
due to the performance bugs filed in https://bugs.llvm.org/show_bug.cgi?id=46753.
An SROA change soon may obviate some of these problems.
This reverts commit 8d09f20798ac180b1749276bff364682ce0196ab.
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.cpp | 36 |
1 files changed, 5 insertions, 31 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 4a7c845..8ce488f 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -2154,39 +2154,13 @@ void CodeGenFunction::emitAlignmentAssumption(llvm::Value *PtrValue, SourceLocation AssumptionLoc, llvm::Value *Alignment, llvm::Value *OffsetValue) { - if (Alignment->getType() != IntPtrTy) - Alignment = - Builder.CreateIntCast(Alignment, IntPtrTy, false, "casted.align"); - if (OffsetValue && OffsetValue->getType() != IntPtrTy) - OffsetValue = - Builder.CreateIntCast(OffsetValue, IntPtrTy, true, "casted.offset"); - llvm::Value *TheCheck = nullptr; + llvm::Value *TheCheck; + llvm::Instruction *Assumption = Builder.CreateAlignmentAssumption( + CGM.getDataLayout(), PtrValue, Alignment, OffsetValue, &TheCheck); if (SanOpts.has(SanitizerKind::Alignment)) { - llvm::Value *PtrIntValue = - Builder.CreatePtrToInt(PtrValue, IntPtrTy, "ptrint"); - - if (OffsetValue) { - bool IsOffsetZero = false; - if (const auto *CI = dyn_cast<llvm::ConstantInt>(OffsetValue)) - IsOffsetZero = CI->isZero(); - - if (!IsOffsetZero) - PtrIntValue = Builder.CreateSub(PtrIntValue, OffsetValue, "offsetptr"); - } - - llvm::Value *Zero = llvm::ConstantInt::get(IntPtrTy, 0); - llvm::Value *Mask = - Builder.CreateSub(Alignment, llvm::ConstantInt::get(IntPtrTy, 1)); - llvm::Value *MaskedPtr = Builder.CreateAnd(PtrIntValue, Mask, "maskedptr"); - TheCheck = Builder.CreateICmpEQ(MaskedPtr, Zero, "maskcond"); + emitAlignmentAssumptionCheck(PtrValue, Ty, Loc, AssumptionLoc, Alignment, + OffsetValue, TheCheck, Assumption); } - llvm::Instruction *Assumption = Builder.CreateAlignmentAssumption( - CGM.getDataLayout(), PtrValue, Alignment, OffsetValue); - - if (!SanOpts.has(SanitizerKind::Alignment)) - return; - emitAlignmentAssumptionCheck(PtrValue, Ty, Loc, AssumptionLoc, Alignment, - OffsetValue, TheCheck, Assumption); } void CodeGenFunction::emitAlignmentAssumption(llvm::Value *PtrValue, |