Commit first round work of PR1373. "noalias" is now fully supported in

VMCore, BitCode, and Assembly. Documentation and test case paramattrs.ll
updated also.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37432 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Zhou Sheng 2007-06-05 05:28:26 +00:00
parent 45beb482c4
commit febca3499e
7 changed files with 18 additions and 6 deletions

View File

@ -784,6 +784,9 @@ a power of 2.</p>
<dt><tt>sret</tt></dt> <dt><tt>sret</tt></dt>
<dd>This indicates that the parameter specifies the address of a structure <dd>This indicates that the parameter specifies the address of a structure
that is the return value of the function in the source program.</dd> that is the return value of the function in the source program.</dd>
<dt><tt>noalias</tt></dt>
<dd>This indicates that the parameter not alias any other object or any
other "noalias" objects during the function call.
<dt><tt>noreturn</tt></dt> <dt><tt>noreturn</tt></dt>
<dd>This function attribute indicates that the function never returns. This <dd>This function attribute indicates that the function never returns. This
indicates to LLVM that every call to this function should be treated as if indicates to LLVM that every call to this function should be treated as if

View File

@ -35,7 +35,8 @@ enum Attributes {
NoReturn = 1 << 2, ///< mark the function as not returning NoReturn = 1 << 2, ///< mark the function as not returning
InReg = 1 << 3, ///< force argument to be passed in register InReg = 1 << 3, ///< force argument to be passed in register
StructRet = 1 << 4, ///< hidden pointer to structure to return StructRet = 1 << 4, ///< hidden pointer to structure to return
NoUnwind = 1 << 5 ///< Function doesn't unwind stack NoUnwind = 1 << 5, ///< Function doesn't unwind stack
NoAlias = 1 << 6 ///< Considered to not alias after call.
}; };
} }

View File

@ -229,6 +229,7 @@ inreg { return INREG; }
sret { return SRET; } sret { return SRET; }
nounwind { return NOUNWIND; } nounwind { return NOUNWIND; }
noreturn { return NORETURN; } noreturn { return NORETURN; }
noalias { return NOALIAS; }
void { RET_TY(Type::VoidTy, VOID); } void { RET_TY(Type::VoidTy, VOID); }
float { RET_TY(Type::FloatTy, FLOAT); } float { RET_TY(Type::FloatTy, FLOAT); }

View File

@ -1101,7 +1101,7 @@ Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) {
%token <OtherOpVal> EXTRACTELEMENT INSERTELEMENT SHUFFLEVECTOR %token <OtherOpVal> EXTRACTELEMENT INSERTELEMENT SHUFFLEVECTOR
// Function Attributes // Function Attributes
%token NORETURN INREG SRET NOUNWIND %token NORETURN INREG SRET NOUNWIND NOALIAS
// Visibility Styles // Visibility Styles
%token DEFAULT HIDDEN PROTECTED %token DEFAULT HIDDEN PROTECTED
@ -1224,10 +1224,11 @@ OptCallingConv : /*empty*/ { $$ = CallingConv::C; } |
CHECK_FOR_ERROR CHECK_FOR_ERROR
}; };
ParamAttr : ZEXT { $$ = ParamAttr::ZExt; } ParamAttr : ZEXT { $$ = ParamAttr::ZExt; }
| SEXT { $$ = ParamAttr::SExt; } | SEXT { $$ = ParamAttr::SExt; }
| INREG { $$ = ParamAttr::InReg; } | INREG { $$ = ParamAttr::InReg; }
| SRET { $$ = ParamAttr::StructRet; } | SRET { $$ = ParamAttr::StructRet; }
| NOALIAS { $$ = ParamAttr::NoAlias; }
; ;
OptParamAttrs : /* empty */ { $$ = ParamAttr::None; } OptParamAttrs : /* empty */ { $$ = ParamAttr::None; }

View File

@ -99,6 +99,8 @@ ParamAttrsList::getParamAttrsText(uint16_t Attrs) {
Result += "nounwind "; Result += "nounwind ";
if (Attrs & ParamAttr::InReg) if (Attrs & ParamAttr::InReg)
Result += "inreg "; Result += "inreg ";
if (Attrs & ParamAttr::NoAlias)
Result += "noalias ";
if (Attrs & ParamAttr::StructRet) if (Attrs & ParamAttr::StructRet)
Result += "sret "; Result += "sret ";
return Result; return Result;

View File

@ -8,6 +8,8 @@
declare i16 @"test"(i16 sext %arg) sext declare i16 @"test"(i16 sext %arg) sext
declare i8 @"test2" (i16 zext %a2) zext declare i8 @"test2" (i16 zext %a2) zext
declare i32 @"test3"(i32* noalias %p)
declare void @exit(i32) noreturn nounwind declare void @exit(i32) noreturn nounwind
define i32 @main(i32 %argc, i8 **%argv) nounwind inreg { define i32 @main(i32 %argc, i8 **%argv) nounwind inreg {

View File

@ -473,6 +473,8 @@ CppWriter::printTypeInternal(const Type* Ty) {
Out << " | ParamAttr::SExt"; Out << " | ParamAttr::SExt";
if (attrs & ParamAttr::ZExt) if (attrs & ParamAttr::ZExt)
Out << " | ParamAttr::ZExt"; Out << " | ParamAttr::ZExt";
if (attrs & ParamAttr::NoAlias)
Out << " | ParamAttr::NoAlias";
if (attrs & ParamAttr::StructRet) if (attrs & ParamAttr::StructRet)
Out << " | ParamAttr::StructRet"; Out << " | ParamAttr::StructRet";
if (attrs & ParamAttr::InReg) if (attrs & ParamAttr::InReg)