[llvm] r270671 - [FunctionAttrs] Volatile loads should disable readonly

Sean Silva via llvm-commits llvm-commits at lists.llvm.org
Wed May 25 10:07:19 PDT 2016


This is scary. Was this a recent regression?

On Tue, May 24, 2016 at 10:53 PM, David Majnemer via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: majnemer
> Date: Wed May 25 00:53:04 2016
> New Revision: 270671
>
> URL: http://llvm.org/viewvc/llvm-project?rev=270671&view=rev
> Log:
> [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.
>
> Modified:
>     llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp
>     llvm/trunk/test/Transforms/FunctionAttrs/readattrs.ll
>
> Modified: llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp?rev=270671&r1=270670&r2=270671&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp (original)
> +++ llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp Wed May 25 00:53:04
> 2016
> @@ -463,6 +463,11 @@ determinePointerReadAttrs(Argument *A,
>      }
>
>      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;
>        break;
>
>
> Modified: llvm/trunk/test/Transforms/FunctionAttrs/readattrs.ll
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/FunctionAttrs/readattrs.ll?rev=270671&r1=270670&r2=270671&view=diff
>
> ==============================================================================
> --- llvm/trunk/test/Transforms/FunctionAttrs/readattrs.ll (original)
> +++ llvm/trunk/test/Transforms/FunctionAttrs/readattrs.ll Wed May 25
> 00:53:04 2016
> @@ -104,3 +104,11 @@ define <4 x i32> @test12_2(<4 x i32*> %p
>    %res = call <4 x i32> @test12_1(<4 x i32*> %ptrs)
>    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
> +}
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160525/1414a82b/attachment.html>


More information about the llvm-commits mailing list