mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-01 15:11:24 +00:00
Teach memdep to use pointsToConstantMemory to determine that loads
from constant memory don't alias any stores. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117636 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1cfb043901
commit
cd5c123a1d
@ -161,8 +161,9 @@ getCallSiteDependencyFrom(CallSite CS, bool isReadOnlyCall,
|
||||
}
|
||||
|
||||
/// getPointerDependencyFrom - Return the instruction on which a memory
|
||||
/// location depends. If isLoad is true, this routine ignore may-aliases with
|
||||
/// read-only operations.
|
||||
/// location depends. If isLoad is true, this routine ignores may-aliases with
|
||||
/// read-only operations. If isLoad is false, this routine ignores may-aliases
|
||||
/// with reads from read-only locations.
|
||||
MemDepResult MemoryDependenceAnalysis::
|
||||
getPointerDependencyFrom(const AliasAnalysis::Location &MemLoc, bool isLoad,
|
||||
BasicBlock::iterator ScanIt, BasicBlock *BB) {
|
||||
@ -225,17 +226,21 @@ getPointerDependencyFrom(const AliasAnalysis::Location &MemLoc, bool isLoad,
|
||||
Value *Pointer = LI->getPointerOperand();
|
||||
uint64_t PointerSize = AA->getTypeStoreSize(LI->getType());
|
||||
MDNode *TBAATag = LI->getMetadata(LLVMContext::MD_tbaa);
|
||||
AliasAnalysis::Location LoadLoc(Pointer, PointerSize, TBAATag);
|
||||
|
||||
// If we found a pointer, check if it could be the same as our pointer.
|
||||
AliasAnalysis::AliasResult R =
|
||||
AA->alias(AliasAnalysis::Location(Pointer, PointerSize, TBAATag),
|
||||
MemLoc);
|
||||
AliasAnalysis::AliasResult R = AA->alias(LoadLoc, MemLoc);
|
||||
if (R == AliasAnalysis::NoAlias)
|
||||
continue;
|
||||
|
||||
// May-alias loads don't depend on each other without a dependence.
|
||||
if (isLoad && R == AliasAnalysis::MayAlias)
|
||||
continue;
|
||||
|
||||
// Stores don't alias loads from read-only memory.
|
||||
if (!isLoad && AA->pointsToConstantMemory(LoadLoc))
|
||||
continue;
|
||||
|
||||
// Stores depend on may and must aliased loads, loads depend on must-alias
|
||||
// loads.
|
||||
return MemDepResult::getDef(Inst);
|
||||
|
@ -25,6 +25,29 @@ define i8 @test0_no(i8* %a, i8* %b) nounwind {
|
||||
ret i8 %y
|
||||
}
|
||||
|
||||
; CHECK: @test1_yes
|
||||
; CHECK-NEXT: load i8* %b
|
||||
; CHECK-NEXT: store i8 1, i8* %a
|
||||
; CHECK-NEXT: ret i8 %y
|
||||
define i8 @test1_yes(i8* %a, i8* %b) nounwind {
|
||||
store i8 0, i8* %a
|
||||
%y = load i8* %b, !tbaa !5
|
||||
store i8 1, i8* %a
|
||||
ret i8 %y
|
||||
}
|
||||
|
||||
; CHECK: @test1_no
|
||||
; CHECK-NEXT: store i8 0, i8* %a
|
||||
; CHECK-NEXT: load i8* %b
|
||||
; CHECK-NEXT: store i8 1, i8* %a
|
||||
; CHECK-NEXT: ret i8 %y
|
||||
define i8 @test1_no(i8* %a, i8* %b) nounwind {
|
||||
store i8 0, i8* %a
|
||||
%y = load i8* %b, !tbaa !6
|
||||
store i8 1, i8* %a
|
||||
ret i8 %y
|
||||
}
|
||||
|
||||
; Root note.
|
||||
!0 = metadata !{ }
|
||||
; Some type.
|
||||
|
Loading…
Reference in New Issue
Block a user