[llvm] r223903 - DataLayout: Be more verbose when diagnosing problems in pointer specs
David Majnemer
david.majnemer at gmail.com
Tue Dec 9 17:38:28 PST 2014
Author: majnemer
Date: Tue Dec 9 19:38:28 2014
New Revision: 223903
URL: http://llvm.org/viewvc/llvm-project?rev=223903&view=rev
Log:
DataLayout: Be more verbose when diagnosing problems in pointer specs
Added:
llvm/trunk/test/Assembler/invalid-datalayout6.ll
llvm/trunk/test/Assembler/invalid-datalayout7.ll
llvm/trunk/test/Assembler/invalid-datalayout8.ll
llvm/trunk/test/Assembler/invalid-datalayout9.ll
Modified:
llvm/trunk/lib/IR/DataLayout.cpp
Modified: llvm/trunk/lib/IR/DataLayout.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DataLayout.cpp?rev=223903&r1=223902&r2=223903&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DataLayout.cpp (original)
+++ llvm/trunk/lib/IR/DataLayout.cpp Tue Dec 9 19:38:28 2014
@@ -197,8 +197,8 @@ void DataLayout::reset(StringRef Desc) {
static std::pair<StringRef, StringRef> split(StringRef Str, char Separator) {
assert(!Str.empty() && "parse error, string can't be empty here");
std::pair<StringRef, StringRef> Split = Str.split(Separator);
- assert((!Split.second.empty() || Split.first == Str) &&
- "a trailing separator is not allowed");
+ if (Split.second.empty() && Split.first != Str)
+ report_fatal_error("Trailing separator in datalayout string");
return Split;
}
@@ -213,7 +213,8 @@ static unsigned getInt(StringRef R) {
/// Convert bits into bytes. Assert if not a byte width multiple.
static unsigned inBytes(unsigned Bits) {
- assert(Bits % 8 == 0 && "number of bits must be a byte width multiple");
+ if (Bits % 8)
+ report_fatal_error("number of bits must be a byte width multiple");
return Bits / 8;
}
@@ -251,10 +252,16 @@ void DataLayout::parseSpecifier(StringRe
report_fatal_error("Invalid address space, must be a 24bit integer");
// Size.
+ if (Rest.empty())
+ report_fatal_error(
+ "Missing size specification for pointer in datalayout string");
Split = split(Rest, ':');
unsigned PointerMemSize = inBytes(getInt(Tok));
// ABI alignment.
+ if (Rest.empty())
+ report_fatal_error(
+ "Missing alignment specification for pointer in datalayout string");
Split = split(Rest, ':');
unsigned PointerABIAlign = inBytes(getInt(Tok));
Added: llvm/trunk/test/Assembler/invalid-datalayout6.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/invalid-datalayout6.ll?rev=223903&view=auto
==============================================================================
--- llvm/trunk/test/Assembler/invalid-datalayout6.ll (added)
+++ llvm/trunk/test/Assembler/invalid-datalayout6.ll Tue Dec 9 19:38:28 2014
@@ -0,0 +1,3 @@
+; RUN: not llvm-as < %s 2>&1 | FileCheck %s
+target datalayout = "a:"
+; CHECK: Trailing separator in datalayout string
Added: llvm/trunk/test/Assembler/invalid-datalayout7.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/invalid-datalayout7.ll?rev=223903&view=auto
==============================================================================
--- llvm/trunk/test/Assembler/invalid-datalayout7.ll (added)
+++ llvm/trunk/test/Assembler/invalid-datalayout7.ll Tue Dec 9 19:38:28 2014
@@ -0,0 +1,3 @@
+; RUN: not llvm-as < %s 2>&1 | FileCheck %s
+target datalayout = "p:52"
+; CHECK: number of bits must be a byte width multiple
Added: llvm/trunk/test/Assembler/invalid-datalayout8.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/invalid-datalayout8.ll?rev=223903&view=auto
==============================================================================
--- llvm/trunk/test/Assembler/invalid-datalayout8.ll (added)
+++ llvm/trunk/test/Assembler/invalid-datalayout8.ll Tue Dec 9 19:38:28 2014
@@ -0,0 +1,3 @@
+; RUN: not llvm-as < %s 2>&1 | FileCheck %s
+target datalayout = "e-p"
+; CHECK: Missing size specification for pointer in datalayout string
Added: llvm/trunk/test/Assembler/invalid-datalayout9.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/invalid-datalayout9.ll?rev=223903&view=auto
==============================================================================
--- llvm/trunk/test/Assembler/invalid-datalayout9.ll (added)
+++ llvm/trunk/test/Assembler/invalid-datalayout9.ll Tue Dec 9 19:38:28 2014
@@ -0,0 +1,3 @@
+; RUN: not llvm-as < %s 2>&1 | FileCheck %s
+target datalayout = "e-p:64"
+; CHECK: Missing alignment specification for pointer in datalayout string
More information about the llvm-commits
mailing list