llvm-6502/lib/Transforms
Arnold Schwaighofer dd8c386432 SimplifyCFG: Don't convert phis into selects if we could remove undef behavior
instead

We used to transform this:

  define void @test6(i1 %cond, i8* %ptr) {
  entry:
    br i1 %cond, label %bb1, label %bb2

  bb1:
    br label %bb2

  bb2:
    %ptr.2 = phi i8* [ %ptr, %entry ], [ null, %bb1 ]
    store i8 2, i8* %ptr.2, align 8
    ret void
  }

into this:

  define void @test6(i1 %cond, i8* %ptr) {
    %ptr.2 = select i1 %cond, i8* null, i8* %ptr
    store i8 2, i8* %ptr.2, align 8
    ret void
  }

because the simplifycfg transformation into selects would happen to happen
before the simplifycfg transformation that removes unreachable control flow
(We have 'unreachable control flow' due to the store to null which is undefined
behavior).

The existing transformation that removes unreachable control flow in simplifycfg
is:

  /// If BB has an incoming value that will always trigger undefined behavior
  /// (eg. null pointer dereference), remove the branch leading here.
  static bool removeUndefIntroducingPredecessor(BasicBlock *BB)

Now we generate:

  define void @test6(i1 %cond, i8* %ptr) {
    store i8 2, i8* %ptr.2, align 8
    ret void
  }

I did not see any impact on the test-suite + externals.

rdar://18596215

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219462 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-10 01:27:02 +00:00
..
Hello
InstCombine [InstCombine] Fix wrong folding of constant comparisons involving ashr and negative values. 2014-10-09 12:41:49 +00:00
Instrumentation Use triple's isiOS() and isOSDarwin() methods. 2014-10-09 05:43:30 +00:00
IPO Inliner: Non-local functions in COMDATs shouldn't be dropped 2014-10-08 19:32:32 +00:00
ObjCARC
Scalar [Reassociate] Don't canonicalize X - undef to X + (-undef). 2014-10-09 20:06:29 +00:00
Utils SimplifyCFG: Don't convert phis into selects if we could remove undef behavior 2014-10-10 01:27:02 +00:00
Vectorize
CMakeLists.txt
LLVMBuild.txt
Makefile