[PATCH] D63967: Handle IntToPtr in isBytewiseValue

Vitaly Buka via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 11 18:44:40 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL365858: Handle IntToPtr in isBytewiseValue (authored by vitalybuka, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D63967?vs=207180&id=209394#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D63967

Files:
  cfe/trunk/test/CodeGenCXX/auto-var-init.cpp
  llvm/trunk/lib/Analysis/ValueTracking.cpp
  llvm/trunk/unittests/Analysis/ValueTrackingTest.cpp


Index: llvm/trunk/lib/Analysis/ValueTracking.cpp
===================================================================
--- llvm/trunk/lib/Analysis/ValueTracking.cpp
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp
@@ -3218,6 +3218,17 @@
     }
   }
 
+  if (auto *CE = dyn_cast<ConstantExpr>(C)) {
+    if (CE->getOpcode() == Instruction::IntToPtr) {
+      auto PS = DL.getPointerSizeInBits(
+          cast<PointerType>(CE->getType())->getAddressSpace());
+      return isBytewiseValue(
+          ConstantExpr::getIntegerCast(CE->getOperand(0),
+                                       Type::getIntNTy(Ctx, PS), false),
+          DL);
+    }
+  }
+
   auto Merge = [&](Value *LHS, Value *RHS) -> Value * {
     if (LHS == RHS)
       return LHS;
Index: llvm/trunk/unittests/Analysis/ValueTrackingTest.cpp
===================================================================
--- llvm/trunk/unittests/Analysis/ValueTrackingTest.cpp
+++ llvm/trunk/unittests/Analysis/ValueTrackingTest.cpp
@@ -794,11 +794,11 @@
         "i16* inttoptr (i64 0 to i16*)",
     },
     {
-        "",
+        "i8 -1",
         "i16* inttoptr (i64 -1 to i16*)",
     },
     {
-        "",
+        "i8 -86",
         "i16* inttoptr (i64 -6148914691236517206 to i16*)",
     },
     {
@@ -806,7 +806,7 @@
         "i16* inttoptr (i48 -1 to i16*)",
     },
     {
-        "",
+        "i8 -1",
         "i16* inttoptr (i96 -1 to i16*)",
     },
     {
Index: cfe/trunk/test/CodeGenCXX/auto-var-init.cpp
===================================================================
--- cfe/trunk/test/CodeGenCXX/auto-var-init.cpp
+++ cfe/trunk/test/CodeGenCXX/auto-var-init.cpp
@@ -1042,14 +1042,8 @@
 // CHECK:            %uninit = alloca [4 x i32*], align
 // CHECK-NEXT:       call void @{{.*}}used{{.*}}%uninit)
 // PATTERN-O1-LABEL: @test_intptr4_uninit()
-// PATTERN-O1:       %1 = getelementptr inbounds [4 x i32*], [4 x i32*]* %uninit, i64 0, i64 0
-// PATTERN-O1-NEXT:  store i32* inttoptr (i64 -6148914691236517206 to i32*), i32** %1, align 16
-// PATTERN-O1-NEXT:  %2 = getelementptr inbounds [4 x i32*], [4 x i32*]* %uninit, i64 0, i64 1
-// PATTERN-O1-NEXT:  store i32* inttoptr (i64 -6148914691236517206 to i32*), i32** %2, align 8
-// PATTERN-O1-NEXT:  %3 = getelementptr inbounds [4 x i32*], [4 x i32*]* %uninit, i64 0, i64 2
-// PATTERN-O1-NEXT:  store i32* inttoptr (i64 -6148914691236517206 to i32*), i32** %3, align 16
-// PATTERN-O1-NEXT:  %4 = getelementptr inbounds [4 x i32*], [4 x i32*]* %uninit, i64 0, i64 3
-// PATTERN-O1-NEXT:  store i32* inttoptr (i64 -6148914691236517206 to i32*), i32** %4, align 8
+// PATTERN-O1:       %1 = bitcast [4 x i32*]* %uninit to i8*
+// PATTERN-O1-NEXT:  call void @llvm.memset.p0i8.i64(i8* nonnull align 16 %1, i8 -86, i64 32, i1 false)
 // ZERO-LABEL:       @test_intptr4_uninit()
 // ZERO:             call void @llvm.memset{{.*}}, i8 0,
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63967.209394.patch
Type: text/x-patch
Size: 2866 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190712/d834f9ca/attachment.bin>


More information about the cfe-commits mailing list