OSDN Git Service

Avoid output indeterminism between GCC and Clang builds.
authorPatrik Hagglund <patrik.h.hagglund@ericsson.com>
Mon, 20 Jun 2016 10:19:00 +0000 (10:19 +0000)
committerPatrik Hagglund <patrik.h.hagglund@ericsson.com>
Mon, 20 Jun 2016 10:19:00 +0000 (10:19 +0000)
commit44907069dab7a0aa0850b08f6f27fa83aeaa5cd2
tree307d7625e5b4cb7dac3ace76d0a365ccaec5106e
parent76e55eedd6666d53e0a4e02b7d699f54d8aa2d63
Avoid output indeterminism between GCC and Clang builds.

Remove dependency of the evalution order of function arguments, which
is unspecified.

The following test previously failed when built with GCC (but succeded
when built with Clang):

  ; RUN: opt -sroa -S < %s | FileCheck %s

  target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
  target triple = "x86_64-unknown-linux-gnu"

  %A = type {i16}

  @a = global %A* null
  @b = global i16 0

  ; CHECK-LABEL: @f1(
  ; CHECK: alloca %A
  ; CHECK-NEXT: extractvalue %A
  ; CHECK-NEXT: getelementptr inbounds %A

  define void @f1 (%A %a) {
    %1 = alloca %A
    store %A %a, %A* %1
    %2 = load i16, i16* @b
    %3 = icmp ne i16 %2, 0
    br i1 %3, label %bb1, label %bb2
  bb1:
    store %A* %1, %A** @a
    br label %bb2
  bb2:
    ret void
  }

Patch by David Stenberg.

Differential Revision: http://reviews.llvm.org/D21226

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273144 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/SROA.cpp