Yuri
2010-May-08 01:24 UTC
[LLVMdev] Should the function operand flag 'sret' match the flag in function declaration?
I have these two instructions, first one inside some procedure, second one is an outside declaration. Code verification passes and it runs, but incorrectly. Every time I saw such situation coming from c++ compiler, attributes 'noalias sret' appear on both call and declaration. Does such situation make sense, or (as I guess it is) a bug in verifier? I think verifier should match at least 'sret' flag in call and declaration. ... call void @_Z7returnsi(%struct.MyString* %z, i32 %1) nounwind ... declare void @_Z7returnsi(%struct.MyString* noalias sret, i32) ... Yuri
Chris Lattner
2010-May-08 17:31 UTC
[LLVMdev] Should the function operand flag 'sret' match the flag in function declaration?
On May 7, 2010, at 6:24 PM, Yuri wrote:> I have these two instructions, first one inside some procedure, second > one is an outside declaration. > Code verification passes and it runs, but incorrectly.Right, this code has undefined behavior.> Every time I saw such situation coming from c++ compiler, attributes > 'noalias sret' appear on both call and declaration. > > Does such situation make sense, or (as I guess it is) a bug in verifier? > I think verifier should match at least 'sret' flag in call and declaration. > > ... > call void @_Z7returnsi(%struct.MyString* %z, i32 %1) nounwind > ... > declare void @_Z7returnsi(%struct.MyString* noalias sret, i32) > ...The verifier flags and rejects *invalid* IR, not IR with undefined behavior. Dan has been working on a pass (in lib/Analysis/Lint.cpp) that should catch this sort of thing. If it doesn't already, please send in a patch to make it catch it. Thanks! -Chris
Dan Gohman
2010-May-10 18:42 UTC
[LLVMdev] Should the function operand flag 'sret' match the flag in function declaration?
On May 8, 2010, at 10:31 AM, Chris Lattner wrote:> > On May 7, 2010, at 6:24 PM, Yuri wrote: > >> I have these two instructions, first one inside some procedure, second >> one is an outside declaration. >> Code verification passes and it runs, but incorrectly. > > Right, this code has undefined behavior. > >> Every time I saw such situation coming from c++ compiler, attributes >> 'noalias sret' appear on both call and declaration. >> >> Does such situation make sense, or (as I guess it is) a bug in verifier? >> I think verifier should match at least 'sret' flag in call and declaration. >> >> ... >> call void @_Z7returnsi(%struct.MyString* %z, i32 %1) nounwind >> ... >> declare void @_Z7returnsi(%struct.MyString* noalias sret, i32) >> ... > > The verifier flags and rejects *invalid* IR, not IR with undefined behavior. Dan has been working on a pass (in lib/Analysis/Lint.cpp) that should catch this sort of thing. If it doesn't already, please send in a patch to make it catch it. Thanks!The lint pass currently just does this: // TODO: Check sret attribute. So yes, please send a patch :-). Thanks, Dan
Seemingly Similar Threads
- [LLVMdev] Should the function operand flag 'sret' match the flag in function declaration?
- SRET consistency between declaration and call site
- [LLVMdev] What does "noalias sret" mean?
- [LLVMdev] Functions: sret and readnone
- SRET consistency between declaration and call site