[PATCH] D18258: Have DataLayout::isLegalInteger accept a uint64_t
Michael Kuperstein via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 17 16:58:03 PDT 2016
mkuper created this revision.
mkuper added reviewers: spatel, joker.eph.
mkuper added a subscriber: llvm-commits.
Integer type sizes may have up to IntegerType::MAX_INT_BITS, which is currently 1<<23, so nothing that fits into an unsigned int will not be legal. However, having a uint64_t passed here avoids bugs due to truncation from uint64_t, as in PR26972.
Alternatively, we can require always checking for < UINT_MAX (or, better yet, for < MAX_INT_BITS) explicitly before calling DataLayout::isLegalInteger(), but that would make code like "DL.isLegalInteger(DL.getTypeSizeInBits(Ty))" (which we currently have in several places) wrong.
http://reviews.llvm.org/D18258
Files:
include/llvm/IR/DataLayout.h
test/Transforms/SROA/pr26972.ll
Index: test/Transforms/SROA/pr26972.ll
===================================================================
--- test/Transforms/SROA/pr26972.ll
+++ test/Transforms/SROA/pr26972.ll
@@ -0,0 +1,14 @@
+; RUN: opt < %s -sroa -S | FileCheck %s
+target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-linux"
+
+; CHECK-LABEL: fn1
+; CHECK-NEXT: ret void
+define void @fn1() {
+ %a = alloca [1073741825 x i32], align 16
+ %t0 = bitcast [1073741825 x i32]* %a to i8*
+ call void @llvm.lifetime.end(i64 4294967300, i8* %t0)
+ ret void
+}
+
+declare void @llvm.lifetime.end(i64, i8* nocapture)
Index: include/llvm/IR/DataLayout.h
===================================================================
--- include/llvm/IR/DataLayout.h
+++ include/llvm/IR/DataLayout.h
@@ -236,14 +236,14 @@
/// on any known one. This returns false if the integer width is not legal.
///
/// The width is specified in bits.
- bool isLegalInteger(unsigned Width) const {
+ bool isLegalInteger(uint64_t Width) const {
for (unsigned LegalIntWidth : LegalIntWidths)
if (LegalIntWidth == Width)
return true;
return false;
}
- bool isIllegalInteger(unsigned Width) const { return !isLegalInteger(Width); }
+ bool isIllegalInteger(uint64_t Width) const { return !isLegalInteger(Width); }
/// Returns true if the given alignment exceeds the natural stack alignment.
bool exceedsNaturalStackAlignment(unsigned Align) const {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18258.50989.patch
Type: text/x-patch
Size: 1501 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160317/7a7b7e67/attachment.bin>
More information about the llvm-commits
mailing list