Artur Pietrek
2009-Apr-16 15:50 UTC
[LLVMdev] Patch: MSIL backend global pointers initialization
Hi Anton> > > The interesting for me part of the CallInst is printf(i8* noalias %0, i32 > > 123). > > I was diging in doxygen documentation but I really can't see the easy way > to > > compare those instructions and again finish with reinvented (but working) > > wheel ;). > Ah, sorry. I missed that you're doing variadic calls, not casting > variadic function to definite ones. I think you can construct CallSite > and then iterate over the arguments grabbing their types and construct > function type after that. >So what do you think about that: // CallSites have equal signatures bool MSILWriter::cmpCallSite(CallSite A, CallSite B) { return (getCallSiteFType(A)==getCallSiteFType(B) && A.getAttributes()==B.getAttributes()); } // Comparision for std::lower_bound used in MSILWriter::printExternals() bool MSILWriter::compareCallSite(CallSite A, CallSite B) { return getCallSiteFType(A)<getCallSiteFType(B); } // Constructs function type from given CallSite FunctionType* MSILWriter::getCallSiteFType(CallSite CS) { std::vector<const Type *> params; CallSite::arg_iterator AI=CS.arg_begin(), AE = CS.arg_end(); for ( ; AI!=AE; ++AI ) params.push_back((*AI)->getType()); return FunctionType::get(CS.getCalledFunction()->getReturnType(), params,CS.getCalledFunction()->isVarArg()); } Thanks! Regards, Artur -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090416/43320474/attachment.html>
Anton Korobeynikov
2009-Apr-16 19:49 UTC
[LLVMdev] Patch: MSIL backend global pointers initialization
Hi, Artur> // CallSites have equal signatures > bool MSILWriter::cmpCallSite(CallSite A, CallSite B) { > return (getCallSiteFType(A)==getCallSiteFType(B) && > A.getAttributes()==B.getAttributes()); > }As it is impossible to honour argument attributes in MSIL I don't see why you should compare attributes. You seems to have the same MSIL call signature for calls with different param attrs.> // Comparision for std::lower_bound used in MSILWriter::printExternals() > bool MSILWriter::compareCallSite(CallSite A, CallSite B) { > return getCallSiteFType(A)<getCallSiteFType(B); > }Hrm... You're building type for each comparison, which seems to be quite inefficient. Why don't iterate over all variadic call sites of the function and build a single map CS => FunctionType? Also, here it seems you're trying to rely on (instable) numeric representation of pointers which can be quite unstable and in general bad for tests, etc.> > // Constructs function type from given CallSiteAt least - from arguments of the call :)> FunctionType* MSILWriter::getCallSiteFType(CallSite CS) { > std::vector<const Type *> params; > CallSite::arg_iterator AI=CS.arg_begin(), AE = CS.arg_end();Why don't shorten life of AI, AE and not define them in the for() loop header?> for ( ; AI!=AE; ++AI ) > params.push_back((*AI)->getType());-- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University
Artur Pietrek
2009-Apr-16 22:22 UTC
[LLVMdev] Patch: MSIL backend global pointers initialization
Hello Anton> > // CallSites have equal signatures > > bool MSILWriter::cmpCallSite(CallSite A, CallSite B) { > > return (getCallSiteFType(A)==getCallSiteFType(B) && > > A.getAttributes()==B.getAttributes()); > > } > As it is impossible to honour argument attributes in MSIL I don't see > why you should compare attributes. You seems to have the same MSIL > call signature for calls with different param attrs.I need to check attributes for signed or unsigned ints. I guess it would be better to check just the sign extension.> > > // Comparision for std::lower_bound used in MSILWriter::printExternals() > > bool MSILWriter::compareCallSite(CallSite A, CallSite B) { > > return getCallSiteFType(A)<getCallSiteFType(B); > > } > Hrm... You're building type for each comparison, which seems to be > quite inefficient. Why don't iterate over all variadic call sites of > the function and build a single map CS => FunctionType?Good point, thanks.> Also, here it > seems you're trying to rely on (instable) numeric representation of > pointers which can be quite unstable and in general bad for tests, > etc. >Could you suggest the best way to compare FunctionTypes?> > > // Constructs function type from given CallSite > At least - from arguments of the call :)> > FunctionType* MSILWriter::getCallSiteFType(CallSite CS) { > > std::vector<const Type *> params; > > CallSite::arg_iterator AI=CS.arg_begin(), AE = CS.arg_end(); > Why don't shorten life of AI, AE and not define them in the for() loop > header? > > for ( ; AI!=AE; ++AI ) > > params.push_back((*AI)->getType()); >Thanks, Artur -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090417/b9f4b1d1/attachment.html>
Possibly Parallel Threads
- [LLVMdev] Patch: MSIL backend global pointers initialization
- [LLVMdev] Patch: MSIL backend global pointers initialization
- [LLVMdev] Patch: MSIL backend global pointers initialization
- [LLVMdev] Problem about "llc -march=msil"
- [LLVMdev] Patch: MSIL backend global pointers initialization