[PATCH] D61325: Treat a narrowing PtrToInt like Trunc when generating asm
Shoaib Meenai via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 23 09:26:35 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL361508: [AsmPrinter] Treat a narrowing PtrToInt like Trunc (authored by smeenai, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D61325?vs=197461&id=201001#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D61325/new/
https://reviews.llvm.org/D61325
Files:
llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/trunk/test/CodeGen/X86/ptrtoint-narrow.ll
Index: llvm/trunk/test/CodeGen/X86/ptrtoint-narrow.ll
===================================================================
--- llvm/trunk/test/CodeGen/X86/ptrtoint-narrow.ll
+++ llvm/trunk/test/CodeGen/X86/ptrtoint-narrow.ll
@@ -0,0 +1,6 @@
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s
+
+ at ptr = external global i8, align 1
+ at ref = constant i32 ptrtoint (i8* @ptr to i32), align 4
+
+; CHECK: .long ptr{{$}}
Index: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -2231,7 +2231,10 @@
// We can emit the pointer value into this slot if the slot is an
// integer slot equal to the size of the pointer.
- if (DL.getTypeAllocSize(Ty) == DL.getTypeAllocSize(Op->getType()))
+ //
+ // If the pointer is larger than the resultant integer, then
+ // as with Trunc just depend on the assembler to truncate it.
+ if (DL.getTypeAllocSize(Ty) <= DL.getTypeAllocSize(Op->getType()))
return OpExpr;
// Otherwise the pointer is smaller than the resultant integer, mask off
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61325.201001.patch
Type: text/x-patch
Size: 1197 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190523/f78c4f8f/attachment.bin>
More information about the llvm-commits
mailing list