llvm.org GIT mirror llvm / 5aae26a
Revert alignment assumptions changes Revert r351104-6, r351109, r351110, r351119, r351134, and r351153. These changes fail on the sanitizer bots. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@351159 91177308-0d34-0410-b5e6-96231b3b80d8 Vlad Tsyrklevich 1 year, 10 months ago
1 changed file(s) with 7 addition(s) and 19 deletion(s). Raw diff Collapse all Expand all
22332233 private:
22342234 /// Helper function that creates an assume intrinsic call that
22352235 /// represents an alignment assumption on the provided Ptr, Mask, Type
2236 /// and Offset. It may be sometimes useful to do some other logic
2237 /// based on this alignment check, thus it can be stored into 'TheCheck'.
2236 /// and Offset.
22382237 CallInst *CreateAlignmentAssumptionHelper(const DataLayout &DL,
22392238 Value *PtrValue, Value *Mask,
2240 Type *IntPtrTy, Value *OffsetValue,
2241 Value **TheCheck) {
2239 Type *IntPtrTy,
2240 Value *OffsetValue) {
22422241 Value *PtrIntValue = CreatePtrToInt(PtrValue, IntPtrTy, "ptrint");
22432242
22442243 if (OffsetValue) {
22572256 Value *Zero = ConstantInt::get(IntPtrTy, 0);
22582257 Value *MaskedPtr = CreateAnd(PtrIntValue, Mask, "maskedptr");
22592258 Value *InvCond = CreateICmpEQ(MaskedPtr, Zero, "maskcond");
2260 if (TheCheck)
2261 *TheCheck = InvCond;
2262
22632259 return CreateAssumption(InvCond);
22642260 }
22652261
22702266 /// An optional offset can be provided, and if it is provided, the offset
22712267 /// must be subtracted from the provided pointer to get the pointer with the
22722268 /// specified alignment.
2273 ///
2274 /// It may be sometimes useful to do some other logic
2275 /// based on this alignment check, thus it can be stored into 'TheCheck'.
22762269 CallInst *CreateAlignmentAssumption(const DataLayout &DL, Value *PtrValue,
22772270 unsigned Alignment,
2278 Value *OffsetValue = nullptr,
2279 Value **TheCheck = nullptr) {
2271 Value *OffsetValue = nullptr) {
22802272 assert(isa(PtrValue->getType()) &&
22812273 "trying to create an alignment assumption on a non-pointer?");
22822274 auto *PtrTy = cast(PtrValue->getType());
22842276
22852277 Value *Mask = ConstantInt::get(IntPtrTy, Alignment > 0 ? Alignment - 1 : 0);
22862278 return CreateAlignmentAssumptionHelper(DL, PtrValue, Mask, IntPtrTy,
2287 OffsetValue, TheCheck);
2279 OffsetValue);
22882280 }
22892281
22902282 /// Create an assume intrinsic call that represents an alignment
22942286 /// must be subtracted from the provided pointer to get the pointer with the
22952287 /// specified alignment.
22962288 ///
2297 /// It may be sometimes useful to do some other logic
2298 /// based on this alignment check, thus it can be stored into 'TheCheck'.
2299 ///
23002289 /// This overload handles the condition where the Alignment is dependent
23012290 /// on an existing value rather than a static value.
23022291 CallInst *CreateAlignmentAssumption(const DataLayout &DL, Value *PtrValue,
23032292 Value *Alignment,
2304 Value *OffsetValue = nullptr,
2305 Value **TheCheck = nullptr) {
2293 Value *OffsetValue = nullptr) {
23062294 assert(isa(PtrValue->getType()) &&
23072295 "trying to create an alignment assumption on a non-pointer?");
23082296 auto *PtrTy = cast(PtrValue->getType());
23202308 ConstantInt::get(IntPtrTy, 0), "mask");
23212309
23222310 return CreateAlignmentAssumptionHelper(DL, PtrValue, Mask, IntPtrTy,
2323 OffsetValue, TheCheck);
2311 OffsetValue);
23242312 }
23252313 };
23262314