summaryrefslogtreecommitdiffstats
path: root/llvm/lib/AsmParser
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-07-28 20:12:04 +0000
committerDan Gohman <gohman@apple.com>2010-07-28 20:12:04 +0000
commita7e5a240935a547d028a43800fdb8b8bcb47386f (patch)
tree92adfb5df05b97c01c3be040774f3a3c8518982b /llvm/lib/AsmParser
parentd5010898ab66a638a7f7e427380a8b419e34561c (diff)
downloadbcm5719-llvm-a7e5a240935a547d028a43800fdb8b8bcb47386f.tar.gz
bcm5719-llvm-a7e5a240935a547d028a43800fdb8b8bcb47386f.zip
Define a maximum supported alignment value for load, store, and
alloca instructions (constrained by their internal encoding), and add error checking for it. Fix an instcombine bug which generated huge alignment values (null is infinitely aligned). This fixes undefined behavior noticed by John Regehr. llvm-svn: 109643
Diffstat (limited to 'llvm/lib/AsmParser')
-rw-r--r--llvm/lib/AsmParser/LLParser.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index 61b1ae5e97c..e581a694586 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -1154,6 +1154,8 @@ bool LLParser::ParseOptionalAlignment(unsigned &Alignment) {
if (ParseUInt32(Alignment)) return true;
if (!isPowerOf2_32(Alignment))
return Error(AlignLoc, "alignment is not a power of two");
+ if (Alignment > MaximumAlignment)
+ return Error(AlignLoc, "huge alignments are not supported yet");
return false;
}
@@ -1176,6 +1178,7 @@ bool LLParser::ParseOptionalCommaAlign(unsigned &Alignment,
if (Lex.getKind() != lltok::kw_align)
return Error(Lex.getLoc(), "expected metadata or 'align'");
+ LocTy AlignLoc = Lex.getLoc();
if (ParseOptionalAlignment(Alignment)) return true;
}
OpenPOWER on IntegriCloud