Chris Lattner
2011-Feb-24 18:32 UTC
[LLVMdev] Implementing platform specific library call simplification
On Feb 24, 2011, at 12:41 AM, John Criswell wrote:>>>> At the moment I've got this working locally by adding code to the >>>> simplify-libcalls pass. However this will break on targets where >>>> iprintf() isn't available. Is there a sensible place to add information >>>> about which library functions are available for a particular target? >>> I'd suggest adding a bool argument (HasIPrintf) to the createSimplifyLibCallsPass function and the pass constructor. Then clang (or whatever is setting up the pass manager) can query the appropriate target info to pass down this flag. > > Sorry to jump into something midstream, but I just happened to read the > above paragraph and thought I should comment. Adding a boolean argument > to a pass's constructor method is one of the things I have learned not > to do. If I ever give a "How Not to Write an LLVM Pass" talk, this will > be one of the things in the list.FWIW, the patch didn't do that. SimplifyLibcalls depends on TargetLibraryInfo, which is an analysis pass. -Chris
Frits van Bommel
2011-Feb-24 18:57 UTC
[LLVMdev] Implementing platform specific library call simplification
On Thu, Feb 24, 2011 at 7:32 PM, Chris Lattner <clattner at apple.com> wrote:> On Feb 24, 2011, at 12:41 AM, John Criswell wrote: >> Sorry to jump into something midstream, but I just happened to read the >> above paragraph and thought I should comment. Adding a boolean argument >> to a pass's constructor method is one of the things I have learned not >> to do. If I ever give a "How Not to Write an LLVM Pass" talk, this will >> be one of the things in the list. > > FWIW, the patch didn't do that. SimplifyLibcalls depends on TargetLibraryInfo, which is an analysis pass.However, TargetLibraryInfo does take a target triple (not a bool though) as constructor argument, defaulting to all-unknown. Maybe instead of being an ImmutablePass it should be a ModulePass so it can use Module::getTargetTriple() in runOnModule()? That should make it more compatible with opt & bugpoint.
Chris Lattner
2011-Feb-24 19:03 UTC
[LLVMdev] Implementing platform specific library call simplification
On Feb 24, 2011, at 10:57 AM, Frits van Bommel wrote:> On Thu, Feb 24, 2011 at 7:32 PM, Chris Lattner <clattner at apple.com> wrote: >> On Feb 24, 2011, at 12:41 AM, John Criswell wrote: >>> Sorry to jump into something midstream, but I just happened to read the >>> above paragraph and thought I should comment. Adding a boolean argument >>> to a pass's constructor method is one of the things I have learned not >>> to do. If I ever give a "How Not to Write an LLVM Pass" talk, this will >>> be one of the things in the list. >> >> FWIW, the patch didn't do that. SimplifyLibcalls depends on TargetLibraryInfo, which is an analysis pass. > > However, TargetLibraryInfo does take a target triple (not a bool > though) as constructor argument, defaulting to all-unknown. > Maybe instead of being an ImmutablePass it should be a ModulePass so > it can use Module::getTargetTriple() in runOnModule()? > That should make it more compatible with opt & bugpoint.opt already passes the triple into the pass. bugpoint could do the same if it is interesting. We already have similar issues with TargetData. -Chris
Maybe Matching Threads
- [LLVMdev] Implementing platform specific library call simplification
- [LLVMdev] Implementing platform specific library call simplification
- [LLVMdev] Implementing platform specific library call simplification
- [LLVMdev] Implementing platform specific library call simplification
- [LLVMdev] Implementing platform specific library call simplification