[PATCH] D78575: [Analysis] recognize the 'null' pointer constant as not poison

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 21 11:53:23 PDT 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rGcf30aafa2d1e: [Analysis] recognize the 'null' pointer constant as not poison (authored by spatel).
Herald added a project: LLVM.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78575

Files:
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/test/Transforms/InstSimplify/freeze.ll


Index: llvm/test/Transforms/InstSimplify/freeze.ll
===================================================================
--- llvm/test/Transforms/InstSimplify/freeze.ll
+++ llvm/test/Transforms/InstSimplify/freeze.ll
@@ -51,12 +51,9 @@
   ret i32()* %k
 }
 
-; TODO: This is not poison.
-
 define i32* @make_const_null() {
 ; CHECK-LABEL: @make_const_null(
-; CHECK-NEXT:    [[K:%.*]] = freeze i32* null
-; CHECK-NEXT:    ret i32* [[K]]
+; CHECK-NEXT:    ret i32* null
 ;
   %k = freeze i32* null
   ret i32* %k
@@ -208,8 +205,7 @@
 
 define i32* @gep_inbounds_null() {
 ; CHECK-LABEL: @gep_inbounds_null(
-; CHECK-NEXT:    [[K:%.*]] = freeze i32* null
-; CHECK-NEXT:    ret i32* [[K]]
+; CHECK-NEXT:    ret i32* null
 ;
   %p = getelementptr inbounds i32, i32* null, i32 0
   %k = freeze i32* %p
Index: llvm/lib/Analysis/ValueTracking.cpp
===================================================================
--- llvm/lib/Analysis/ValueTracking.cpp
+++ llvm/lib/Analysis/ValueTracking.cpp
@@ -4693,8 +4693,9 @@
     if (isa<UndefValue>(C) || isa<ConstantExpr>(C))
       return false;
 
-    // TODO: Add ConstantFP and pointers.
-    if (isa<ConstantInt>(C) || isa<GlobalVariable>(C) )
+    // TODO: Add ConstantFP.
+    if (isa<ConstantInt>(C) || isa<GlobalVariable>(C) ||
+        isa<ConstantPointerNull>(C))
       return true;
 
     if (C->getType()->isVectorTy())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78575.259067.patch
Type: text/x-patch
Size: 1369 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200421/7af74317/attachment.bin>


More information about the llvm-commits mailing list