On Thu, Apr 9, 2015 at 10:47 AM, Jonathan Roelofs <jonathan at codesourcery.com> wrote:>> Again, I asked the LLVM list if, since LLVM is a typed assembly >> language, if I could just look for pointer plus offset followed by a >> dereference. They seemed to suggest that looking for that idiom would> JFTR, we're one big community, and it's not as segregated into "the clang > devs" vs "the llvm devs" as you might think.On the LLVM list I was told "That would need to be in Clang" so I am writing the front-end list.> It's encouraged to cc both lists (as appropriate) when having these sorts of > discussions that span the interface between the two projects. This helps > give context to statements like "well I asked the other list", without > having to dig for that other message. At the very least you should provide a > link to the other discussion.Ok, in the future I will write both list, but I initially thought it was a purely backend question. The other discussion starts here: http://lists.cs.uiuc.edu/pipermail/llvmdev/2015-April/084280.html So now that I am writing both lists: where can I intercept a Clang/LLVM compile that will catch expressions that locally look like a[n] or *(a+n) ? My guess is sometime after a[n] is lowered to *(a+n) (if you do that) and sometime before optimization passes start chewing on it. Gry
Gábor Horváth
2015-Apr-09 18:17 UTC
[LLVMdev] [cfe-dev] want to intercept array dereferences
Probably you should take a look at sema/TreeTransform. 2015. ápr. 9. du. 8:06 ezt írta ("Gry Gunvor" <gry.gunvor at gmail.com>):> On Thu, Apr 9, 2015 at 10:47 AM, Jonathan Roelofs > <jonathan at codesourcery.com> wrote: > >> Again, I asked the LLVM list if, since LLVM is a typed assembly > >> language, if I could just look for pointer plus offset followed by a > >> dereference. They seemed to suggest that looking for that idiom would > > > JFTR, we're one big community, and it's not as segregated into "the clang > > devs" vs "the llvm devs" as you might think. > > On the LLVM list I was told "That would need to be in Clang" so I am > writing the front-end list. > > > It's encouraged to cc both lists (as appropriate) when having these > sorts of > > discussions that span the interface between the two projects. This helps > > give context to statements like "well I asked the other list", without > > having to dig for that other message. At the very least you should > provide a > > link to the other discussion. > > Ok, in the future I will write both list, but I initially thought it > was a purely backend question. The other discussion starts here: > http://lists.cs.uiuc.edu/pipermail/llvmdev/2015-April/084280.html > > So now that I am writing both lists: where can I intercept a > Clang/LLVM compile that will catch expressions that locally look like > a[n] or *(a+n) ? > > My guess is sometime after a[n] is lowered to *(a+n) (if you do that) > and sometime before optimization passes start chewing on it. > > Gry > _______________________________________________ > cfe-dev mailing list > cfe-dev at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150409/2e82599a/attachment.html>
Jonathan Roelofs
2015-Apr-09 18:24 UTC
[LLVMdev] [cfe-dev] want to intercept array dereferences
On 4/9/15 11:59 AM, Gry Gunvor wrote:> On Thu, Apr 9, 2015 at 10:47 AM, Jonathan Roelofs > <jonathan at codesourcery.com> wrote: >>> Again, I asked the LLVM list if, since LLVM is a typed assembly >>> language, if I could just look for pointer plus offset followed by a >>> dereference. They seemed to suggest that looking for that idiom would > >> JFTR, we're one big community, and it's not as segregated into "the clang >> devs" vs "the llvm devs" as you might think. > > On the LLVM list I was told "That would need to be in Clang" so I am > writing the front-end list. > >> It's encouraged to cc both lists (as appropriate) when having these sorts of >> discussions that span the interface between the two projects. This helps >> give context to statements like "well I asked the other list", without >> having to dig for that other message. At the very least you should provide a >> link to the other discussion. > > Ok, in the future I will write both list, but I initially thought it > was a purely backend question. The other discussion starts here: > http://lists.cs.uiuc.edu/pipermail/llvmdev/2015-April/084280.html > > So now that I am writing both lists: where can I intercept a > Clang/LLVM compile that will catch expressions that locally look like > a[n] or *(a+n) ?CodeGen for the former happens in CodeGenFunction::EmitArraySubscriptExpr(). For the latter, you'll need to look for UO_Deref in EmitUnaryOpLValue(), and work backwards up the AST to find the BinOp for the +. This might be a little tricky as not every dereference will have that addition binop as its child node, and not every one that you find there is actually a case of array indexing.> > My guess is sometime after a[n] is lowered to *(a+n) (if you do that) > and sometime before optimization passes start chewing on it.As Bruce told you in the other thread, it's probably too late to look for it in llvm. The best place really is to do it in Clang, though it might depend on why you want to do this particular transformation. If you're trying to do bounds checking, the sanitizers already do that. Jon> > Gry >-- Jon Roelofs jonathan at codesourcery.com CodeSourcery / Mentor Embedded
> The best place really is to do it in Clang, though it might depend > on why you want to do this particular transformation. If you're trying to do > bounds checking, the sanitizers already do that.Ah, well bounds checking passes do need to know that information. Perhaps it would work to just hack on one of the sanitizers and get it to gen the code I want rather than generating a software bounds check? Gry
Apparently Analagous Threads
- [LLVMdev] want to intercept array dereferences
- [LLVMdev] want to intercept array dereferences
- [LLVMdev] how much RAM do I really need to build a devel version of LLVM?
- Fwd: getting started changing the emitted code: at one instruction at function top
- The builtins library of compiler-rt is a performance HOG^WKILLER