forked from OSchip/llvm-project
[FunctionAttrs] Volatile loads should disable readonly
A volatile load has side effects beyond what callers expect readonly to signify. For example, it is not safe to reorder two function calls which each perform a volatile load to the same memory location. llvm-svn: 270671
This commit is contained in:
parent
7c1841a55e
commit
124bdb7497
|
@ -463,6 +463,11 @@ determinePointerReadAttrs(Argument *A,
|
||||||
}
|
}
|
||||||
|
|
||||||
case Instruction::Load:
|
case Instruction::Load:
|
||||||
|
// A volatile load has side effects beyond what readonly can be relied
|
||||||
|
// upon.
|
||||||
|
if (cast<LoadInst>(I)->isVolatile())
|
||||||
|
return Attribute::None;
|
||||||
|
|
||||||
IsRead = true;
|
IsRead = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -104,3 +104,11 @@ define <4 x i32> @test12_2(<4 x i32*> %ptrs) {
|
||||||
%res = call <4 x i32> @test12_1(<4 x i32*> %ptrs)
|
%res = call <4 x i32> @test12_1(<4 x i32*> %ptrs)
|
||||||
ret <4 x i32> %res
|
ret <4 x i32> %res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
; CHECK: define i32 @volatile_load(
|
||||||
|
; CHECK-NOT: readonly
|
||||||
|
; CHECK: ret
|
||||||
|
define i32 @volatile_load(i32* %p) {
|
||||||
|
%load = load volatile i32, i32* %p
|
||||||
|
ret i32 %load
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue