[llvm] r263850 - Have DataLayout::isLegalInteger() accept uint64_t
Michael Kuperstein via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 18 16:19:29 PDT 2016
Author: mkuper
Date: Fri Mar 18 18:19:29 2016
New Revision: 263850
URL: http://llvm.org/viewvc/llvm-project?rev=263850&view=rev
Log:
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
Added:
llvm/trunk/test/Transforms/SROA/pr26972.ll
Modified:
llvm/trunk/include/llvm/IR/DataLayout.h
Modified: llvm/trunk/include/llvm/IR/DataLayout.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DataLayout.h?rev=263850&r1=263849&r2=263850&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DataLayout.h (original)
+++ llvm/trunk/include/llvm/IR/DataLayout.h Fri Mar 18 18:19:29 2016
@@ -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 {
Added: llvm/trunk/test/Transforms/SROA/pr26972.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SROA/pr26972.ll?rev=263850&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/SROA/pr26972.ll (added)
+++ llvm/trunk/test/Transforms/SROA/pr26972.ll Fri Mar 18 18:19:29 2016
@@ -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)
More information about the llvm-commits
mailing list