summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorMichael Kuperstein <michael.kuperstein@gmail.com>2016-03-18 23:19:29 +0000
committerMichael Kuperstein <michael.kuperstein@gmail.com>2016-03-18 23:19:29 +0000
commit5abc2765fa884196b988ec432e655d6f21edfe2c (patch)
tree59e790516b7725ed6c17102015b7ec12a048caf0 /llvm
parent86bc631793a7a8ba912a97b5da082f2ade1417a1 (diff)
downloadbcm5719-llvm-5abc2765fa884196b988ec432e655d6f21edfe2c.tar.gz
bcm5719-llvm-5abc2765fa884196b988ec432e655d6f21edfe2c.zip
Have DataLayout::isLegalInteger() accept uint64_t
While not strictly necessary, since we don't support large integer types, this avoids bugs due to silent truncation from uint64_t to a 32-bit unsigned (e.g. DL.isLegalInteger(DL.getTypeSizeInBits(Ty) ) This fixes PR26972. Differential Revision: http://reviews.llvm.org/D18258 llvm-svn: 263850
Diffstat (limited to 'llvm')
-rw-r--r--llvm/include/llvm/IR/DataLayout.h4
-rw-r--r--llvm/test/Transforms/SROA/pr26972.ll17
2 files changed, 19 insertions, 2 deletions
diff --git a/llvm/include/llvm/IR/DataLayout.h b/llvm/include/llvm/IR/DataLayout.h
index 585580c9c0b..6caa968ae4d 100644
--- a/llvm/include/llvm/IR/DataLayout.h
+++ b/llvm/include/llvm/IR/DataLayout.h
@@ -236,14 +236,14 @@ public:
/// 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 {
diff --git a/llvm/test/Transforms/SROA/pr26972.ll b/llvm/test/Transforms/SROA/pr26972.ll
new file mode 100644
index 00000000000..a71058c05b9
--- /dev/null
+++ b/llvm/test/Transforms/SROA/pr26972.ll
@@ -0,0 +1,17 @@
+; 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"
+
+; Make sure we properly handle allocas where the allocated
+; size overflows a uint32_t. This specific constant results in
+; the size in bits being 32 after truncation to a 32-bit int.
+; 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)
OpenPOWER on IntegriCloud