[llvm-commits] [llvm] r67682 - in /llvm/trunk: lib/AsmParser/LLParser.cpp test/Assembler/2009-03-24-ZextConstantExpr.ll
Chris Lattner
sabre at nondot.org
Tue Mar 24 23:36:36 PDT 2009
Author: lattner
Date: Wed Mar 25 01:36:36 2009
New Revision: 67682
URL: http://llvm.org/viewvc/llvm-project?rev=67682&view=rev
Log:
Fix a bug in our autoupgrade support: in an argument list to a function
call, we should treat "i64 zext" as the start of a constant expr, but
"i64 0 zext" as an argument with an obsolete attribute on it (this form
is already tested by test/Assembler/2007-07-30-AutoUpgradeZextSext.ll).
Make the autoupgrade logic more discerning to avoid treating "i64 zext"
as an old-style attribute, causing us to reject a valid constant expr.
This fixes PR3876.
Added:
llvm/trunk/test/Assembler/2009-03-24-ZextConstantExpr.ll
Modified:
llvm/trunk/lib/AsmParser/LLParser.cpp
Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=67682&r1=67681&r2=67682&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Wed Mar 25 01:36:36 2009
@@ -678,6 +678,7 @@
/// ParseOptionalAttrs - Parse a potentially empty attribute list. AttrKind
/// indicates what kind of attribute list this is: 0: function arg, 1: result,
/// 2: function attr.
+/// 3: function arg after value: FIXME: REMOVE IN LLVM 3.0
bool LLParser::ParseOptionalAttrs(unsigned &Attrs, unsigned AttrKind) {
Attrs = Attribute::None;
LocTy AttrLoc = Lex.getLoc();
@@ -686,9 +687,12 @@
switch (Lex.getKind()) {
case lltok::kw_sext:
case lltok::kw_zext:
- // Treat these as signext/zeroext unless they are function attrs.
+ // Treat these as signext/zeroext if they occur in the argument list after
+ // the value, as in "call i8 @foo(i8 10 sext)". If they occur before the
+ // value, as in "call i8 @foo(i8 sext (" then it is part of a constant
+ // expr.
// FIXME: REMOVE THIS IN LLVM 3.0
- if (AttrKind != 2) {
+ if (AttrKind == 3) {
if (Lex.getKind() == lltok::kw_sext)
Attrs |= Attribute::SExt;
else
@@ -700,7 +704,7 @@
if (AttrKind != 2 && (Attrs & Attribute::FunctionOnly))
return Error(AttrLoc, "invalid use of function-only attribute");
- if (AttrKind != 0 && (Attrs & Attribute::ParameterOnly))
+ if (AttrKind != 0 && AttrKind != 3 && (Attrs & Attribute::ParameterOnly))
return Error(AttrLoc, "invalid use of parameter-only attribute");
return false;
@@ -1085,7 +1089,7 @@
ParseValue(ArgTy, V, PFS) ||
// FIXME: Should not allow attributes after the argument, remove this in
// LLVM 3.0.
- ParseOptionalAttrs(ArgAttrs2, 0))
+ ParseOptionalAttrs(ArgAttrs2, 3))
return true;
ArgList.push_back(ParamInfo(ArgLoc, V, ArgAttrs1|ArgAttrs2));
}
Added: llvm/trunk/test/Assembler/2009-03-24-ZextConstantExpr.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/2009-03-24-ZextConstantExpr.ll?rev=67682&view=auto
==============================================================================
--- llvm/trunk/test/Assembler/2009-03-24-ZextConstantExpr.ll (added)
+++ llvm/trunk/test/Assembler/2009-03-24-ZextConstantExpr.ll Wed Mar 25 01:36:36 2009
@@ -0,0 +1,11 @@
+; RUN: llvm-as < %s | llvm-dis
+; PR3876
+ at gdtr = external global [0 x i8]
+
+define void @test() {
+ call zeroext i1 @paging_map(i64 zext (i32 and (i32 ptrtoint ([0 x i8]* @gdtr to i32), i32 -4096) to i64))
+ ret void
+}
+
+declare zeroext i1 @paging_map(i64)
+
More information about the llvm-commits
mailing list