[PATCH] D69571: [ValueTracking] Allow context-sensitive nullness check for non-pointers

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 8 14:59:44 PST 2019


lebedev.ri requested changes to this revision.
lebedev.ri added a comment.
This revision now requires changes to proceed.

Yep, that looks like a miscompile to me.
alive doesn't support phi's yet, so i'm not 100% sure,
but if i manually unroll it (since we know we will return after first iteration),
i get

  ; ModuleID = './example.ll'
  source_filename = "./example.ll"
  define zeroext i8 @test(i8* %arg) local_unnamed_addr {
  bb:
    %tmp4 = load i8, i8* %arg, align 1
    %tmp5 = zext i8 %tmp4 to i32
    %tmp6 = shl nuw nsw i32 0, 3
    %tmp7 = shl nuw nsw i32 %tmp5, %tmp6
    %tmp8 = trunc i32 %tmp7 to i8
    %tmp9 = or i8 0, %tmp8
    %tmp10 = add nuw nsw i32 0, 1
    ret i8 %tmp9
  }

which is just

  define zeroext i8 @test(i8* nocapture readonly %arg) local_unnamed_addr #0 {
  bb:
    %tmp4 = load i8, i8* %arg, align 1
    ret i8 %tmp4
  }

And that replacement says the load is always 0.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69571/new/

https://reviews.llvm.org/D69571





More information about the llvm-commits mailing list