mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
Eliminate trivial redundant loads across nocapture+readonly calls to uncaptured
pointer arguments. llvm-svn: 185776
This commit is contained in:
parent
181e3475a3
commit
7a38a8d88f
@ -450,6 +450,7 @@ AliasAnalysis::callCapturesBefore(const Instruction *I,
|
||||
return AliasAnalysis::ModRef;
|
||||
|
||||
unsigned ArgNo = 0;
|
||||
AliasAnalysis::ModRefResult R = AliasAnalysis::NoModRef;
|
||||
for (ImmutableCallSite::arg_iterator CI = CS.arg_begin(), CE = CS.arg_end();
|
||||
CI != CE; ++CI, ++ArgNo) {
|
||||
// Only look at the no-capture or byval pointer arguments. If this
|
||||
@ -463,12 +464,18 @@ AliasAnalysis::callCapturesBefore(const Instruction *I,
|
||||
// is impossible to alias the pointer we're checking. If not, we have to
|
||||
// assume that the call could touch the pointer, even though it doesn't
|
||||
// escape.
|
||||
if (!isNoAlias(AliasAnalysis::Location(*CI),
|
||||
AliasAnalysis::Location(Object))) {
|
||||
return AliasAnalysis::ModRef;
|
||||
if (isNoAlias(AliasAnalysis::Location(*CI),
|
||||
AliasAnalysis::Location(Object)))
|
||||
continue;
|
||||
if (CS.doesNotAccessMemory(ArgNo))
|
||||
continue;
|
||||
if (CS.onlyReadsMemory(ArgNo)) {
|
||||
R = AliasAnalysis::Ref;
|
||||
continue;
|
||||
}
|
||||
return AliasAnalysis::ModRef;
|
||||
}
|
||||
return AliasAnalysis::NoModRef;
|
||||
return R;
|
||||
}
|
||||
|
||||
// AliasAnalysis destructor: DO NOT move this to the header file for
|
||||
|
17
test/Transforms/GVN/readattrs.ll
Normal file
17
test/Transforms/GVN/readattrs.ll
Normal file
@ -0,0 +1,17 @@
|
||||
; RUN: opt -gvn -S -o - < %s | FileCheck %s
|
||||
|
||||
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
|
||||
target triple = "x86_64-unknown-linux-gnu"
|
||||
|
||||
declare void @use(i8* readonly nocapture)
|
||||
|
||||
define i8 @test() {
|
||||
%a = alloca i8
|
||||
store i8 1, i8* %a
|
||||
call void @use(i8* %a)
|
||||
%b = load i8* %a
|
||||
ret i8 %b
|
||||
; CHECK: define i8 @test
|
||||
; CHECK: call void @use(i8* %a)
|
||||
; CHECK-NEXT: ret i8 1
|
||||
}
|
Loading…
Reference in New Issue
Block a user