[PATCH] D12946: Avoid pointer truncation by InstCombine with IntToPtr combining

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 17 19:41:42 PDT 2015


majnemer added a subscriber: majnemer.
majnemer added a comment.

This patch seems highly suspect.  Pointee types are largely irrelevant given LLVM's value semantics.


================
Comment at: lib/Transforms/InstCombine/InstCombineCasts.cpp:1453
@@ -1451,1 +1452,3 @@
+      // The size of a pointer to code is not defined by a DataLayout
+      !EltTy->isFunctionTy() && !EltTy->isLabelTy()) {
     Type *Ty = DL.getIntPtrType(CI.getContext(), AS);
----------------
To quote http://llvm.org/docs/LangRef.html#pointer-type
> Note that LLVM does not permit pointers to void (void*) nor does it permit pointers to labels (label*). Use i8* instead.

================
Comment at: test/Transforms/InstCombine/combine-func-ptr.ll:1
@@ +1,2 @@
+; RUN: opt -O3 -S %s | FileCheck %s
+;
----------------
This is not ok.  Please run only instcombine.

================
Comment at: test/Transforms/InstCombine/combine-func-ptr.ll:5
@@ +4,3 @@
+;
+; CHECK-NOT: trunc
+
----------------
Please use more comprehensive check lines.


http://reviews.llvm.org/D12946





More information about the llvm-commits mailing list