From be9dccd64d25227832f9cf0c1775acfa072be529 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Sat, 18 Oct 2014 11:00:12 +0000 Subject: Preserve AA metadata when combining (cast (load (...))) -> (load (cast (...))). llvm-svn: 220141 --- llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'llvm/lib/Transforms') diff --git a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp index cfdfa00e805..e57091340c0 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp @@ -319,6 +319,8 @@ static Instruction *combineLoadToOperationType(InstCombiner &IC, LoadInst &LI) { Value *Ptr = LI.getPointerOperand(); unsigned AS = LI.getPointerAddressSpace(); + AAMDNodes AAInfo; + LI.getAAMetadata(AAInfo); // Fold away bit casts of the loaded value by loading the desired type. if (LI.hasOneUse()) @@ -326,6 +328,7 @@ static Instruction *combineLoadToOperationType(InstCombiner &IC, LoadInst &LI) { LoadInst *NewLoad = IC.Builder->CreateAlignedLoad( IC.Builder->CreateBitCast(Ptr, BC->getDestTy()->getPointerTo(AS)), LI.getAlignment(), LI.getName()); + NewLoad->setAAMetadata(AAInfo); BC->replaceAllUsesWith(NewLoad); IC.EraseInstFromFunction(*BC); return &LI; -- cgit v1.2.3