Revert a bit of r137667; the logic in question can safely handle atomic load/store.
llvm-svn: 137702
This commit is contained in:
parent
311186a6ef
commit
a917d4f9b4
|
@ -163,15 +163,15 @@ bool FunctionAttrs::AddReadAttrs(const CallGraphSCC &SCC) {
|
||||||
ReadsMemory = true;
|
ReadsMemory = true;
|
||||||
continue;
|
continue;
|
||||||
} else if (LoadInst *LI = dyn_cast<LoadInst>(I)) {
|
} else if (LoadInst *LI = dyn_cast<LoadInst>(I)) {
|
||||||
// Ignore non-volatile loads from local memory.
|
// Ignore non-volatile loads from local memory. (Atomic is okay here.)
|
||||||
if (LI->isUnordered()) {
|
if (!LI->isVolatile()) {
|
||||||
AliasAnalysis::Location Loc = AA->getLocation(LI);
|
AliasAnalysis::Location Loc = AA->getLocation(LI);
|
||||||
if (AA->pointsToConstantMemory(Loc, /*OrLocal=*/true))
|
if (AA->pointsToConstantMemory(Loc, /*OrLocal=*/true))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else if (StoreInst *SI = dyn_cast<StoreInst>(I)) {
|
} else if (StoreInst *SI = dyn_cast<StoreInst>(I)) {
|
||||||
// Ignore non-volatile stores to local memory.
|
// Ignore non-volatile stores to local memory. (Atomic is okay here.)
|
||||||
if (SI->isUnordered()) {
|
if (!SI->isVolatile()) {
|
||||||
AliasAnalysis::Location Loc = AA->getLocation(SI);
|
AliasAnalysis::Location Loc = AA->getLocation(SI);
|
||||||
if (AA->pointsToConstantMemory(Loc, /*OrLocal=*/true))
|
if (AA->pointsToConstantMemory(Loc, /*OrLocal=*/true))
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
; RUN: opt -basicaa -functionattrs -S < %s | FileCheck %s
|
||||||
|
|
||||||
|
; Atomic load/store to local doesn't affect whether a function is
|
||||||
|
; readnone/readonly.
|
||||||
|
define i32 @test1(i32 %x) uwtable ssp {
|
||||||
|
; CHECK: define i32 @test1(i32 %x) uwtable readnone ssp {
|
||||||
|
entry:
|
||||||
|
%x.addr = alloca i32, align 4
|
||||||
|
store atomic i32 %x, i32* %x.addr seq_cst, align 4
|
||||||
|
%r = load atomic i32* %x.addr seq_cst, align 4
|
||||||
|
ret i32 %r
|
||||||
|
}
|
||||||
|
|
||||||
|
; A function with an Acquire load is not readonly.
|
||||||
|
define i32 @test2(i32* %x) uwtable ssp {
|
||||||
|
; CHECK: define i32 @test2(i32 %x) uwtable ssp {
|
||||||
|
entry:
|
||||||
|
%r = load atomic i32* %x seq_cst, align 4
|
||||||
|
ret i32 %r
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue