Hi Duncan, On 5/6/12 6:12 PM, Duncan Sands wrote:> Hi Ralf, > >> Is there a clean way to attach metadata nodes to Arguments and/or >> BasicBlocks? > > not at the moment. Feel free to work on adding this functionality!I am looking into that now. I decided to temporarily go for the following syntax for BasicBlock metadata (subject to discussion): entry: !property_1 !0, !property_2 !1 %x = fadd float %a, %b It seems that I have to touch lots of files for this: BasicBlock.h/.cpp, Metadata.cpp, LLParser.cpp, AsmParser, AsmWriter, BitcodeReader.cpp, BitcodeWriter.cpp so far. I basically went and duplicated code that handles metadata attached to instructions. Concerning Argument metadata, I am unsure of how to best represent this in LLVM IR. The following seems to be better than putting the metadata somewhere before the first block or anywhere else, but the space in the parameter list looks a bit crowded... declare void test(i32 %param1 !property1 !0, !property2 !1, float* %param2 readonly !property2 !1) Cheers, Ralf
On May 7, 2012, at 7:21 AM, Ralf Karrenberg <Chareos at gmx.de> wrote:> Hi Duncan, > > On 5/6/12 6:12 PM, Duncan Sands wrote: >> Hi Ralf, >> >>> Is there a clean way to attach metadata nodes to Arguments and/or >>> BasicBlocks? >> >> not at the moment. Feel free to work on adding this functionality! > > I am looking into that now. > I decided to temporarily go for the following syntax for BasicBlock > metadata (subject to discussion): > > entry: > !property_1 !0, !property_2 !1 > %x = fadd float %a, %b > > It seems that I have to touch lots of files for this: > BasicBlock.h/.cpp, Metadata.cpp, LLParser.cpp, AsmParser, AsmWriter, > BitcodeReader.cpp, BitcodeWriter.cpp so far. > I basically went and duplicated code that handles metadata attached to > instructions.What kind of things might basic block metadata be used for? Dan
Hi Dan, I am using it to store results of a vectorization analysis. A BasicBlock has certain properties in this context, e.g. we mark control flow that may never diverge in different instances ("threads" if you think in terms of CUDA) of the same function by marking the corresponding blocks. This information is later used when linearizing the function (control flow to data flow conversion). I'll be happy to give you more detail on this if you want to :). I could imagine there are other things that could make use of this, or am I wrong with that? Cheers, Ralf On 5/7/12 11:58 PM, Dan Gohman wrote:> > On May 7, 2012, at 7:21 AM, Ralf Karrenberg<Chareos at gmx.de> wrote: > >> Hi Duncan, >> >> On 5/6/12 6:12 PM, Duncan Sands wrote: >>> Hi Ralf, >>> >>>> Is there a clean way to attach metadata nodes to Arguments and/or >>>> BasicBlocks? >>> >>> not at the moment. Feel free to work on adding this functionality! >> >> I am looking into that now. >> I decided to temporarily go for the following syntax for BasicBlock >> metadata (subject to discussion): >> >> entry: >> !property_1 !0, !property_2 !1 >> %x = fadd float %a, %b >> >> It seems that I have to touch lots of files for this: >> BasicBlock.h/.cpp, Metadata.cpp, LLParser.cpp, AsmParser, AsmWriter, >> BitcodeReader.cpp, BitcodeWriter.cpp so far. >> I basically went and duplicated code that handles metadata attached to >> instructions. > > What kind of things might basic block metadata be used for? > > Dan > >
If we were to implement the #unroll pragma, we would want to add metadata to loop headers. But, it's not a big deal since we can simply add this metadata to block terminators. -----Original Message----- From: llvmdev-bounces at cs.uiuc.edu [mailto:llvmdev-bounces at cs.uiuc.edu] On Behalf Of Dan Gohman Sent: Tuesday, May 08, 2012 00:58 To: Ralf Karrenberg Cc: llvmdev at cs.uiuc.edu List Subject: Re: [LLVMdev] Metadata for Argument, BasicBlock On May 7, 2012, at 7:21 AM, Ralf Karrenberg <Chareos at gmx.de> wrote:> Hi Duncan, > > On 5/6/12 6:12 PM, Duncan Sands wrote: >> Hi Ralf, >> >>> Is there a clean way to attach metadata nodes to Arguments and/or >>> BasicBlocks? >> >> not at the moment. Feel free to work on adding this functionality! > > I am looking into that now. > I decided to temporarily go for the following syntax for BasicBlock > metadata (subject to discussion): > > entry: > !property_1 !0, !property_2 !1 > %x = fadd float %a, %b > > It seems that I have to touch lots of files for this: > BasicBlock.h/.cpp, Metadata.cpp, LLParser.cpp, AsmParser, AsmWriter, > BitcodeReader.cpp, BitcodeWriter.cpp so far. > I basically went and duplicated code that handles metadata attached to > instructions.What kind of things might basic block metadata be used for? Dan _______________________________________________ LLVM Developers mailing list LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev --------------------------------------------------------------------- Intel Israel (74) Limited This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
On 07/05/12 22:58, Dan Gohman wrote:> What kind of things might basic block metadata be used for? > > DanI'd be really keen for this to go in. In order to support worse case execution time analysis on compiled binaries we (XMOS) need a way to mark paths that should be excluded when checking timing constraints. A typical query is "Check the worse case execution time from A to B excluding paths which pass through location C is no more than x nanoseconds". Here C would be a location marked in the source code. A natural way to implement this would be to have the frontend attach metadata to the basic block containing C associating the block with the label "C". Trying to attach the information to an individual instruction is problematic since that specific instruction might be removed / hoisted. Other solutions I can think of might prevent optimizations from happening (which is something we want to avoid). Regards, Richard -- Richard Osborne | XMOS http://www.xmos.com
So, is there any chance that metadata for basic blocks is considered a useful feature? There is a patch ready and on the commits-list, it compiles, passes all tests, has a test case of its own, and (as far as I can tell) does not interfere with anything. Cheers, Ralf On 5/7/12 4:21 PM, Ralf Karrenberg wrote:> Hi Duncan, > > On 5/6/12 6:12 PM, Duncan Sands wrote: >> Hi Ralf, >> >>> Is there a clean way to attach metadata nodes to Arguments and/or >>> BasicBlocks? >> >> not at the moment. Feel free to work on adding this functionality! > > I am looking into that now. > I decided to temporarily go for the following syntax for BasicBlock > metadata (subject to discussion): > > entry: > !property_1 !0, !property_2 !1 > %x = fadd float %a, %b > > It seems that I have to touch lots of files for this: > BasicBlock.h/.cpp, Metadata.cpp, LLParser.cpp, AsmParser, AsmWriter, > BitcodeReader.cpp, BitcodeWriter.cpp so far. > I basically went and duplicated code that handles metadata attached to > instructions. > > Concerning Argument metadata, I am unsure of how to best represent this > in LLVM IR. The following seems to be better than putting the metadata > somewhere before the first block or anywhere else, but the space in the > parameter list looks a bit crowded... > > declare void test(i32 %param1 !property1 !0, !property2 !1, > float* %param2 readonly !property2 !1) > > Cheers, > Ralf > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
On May 15, 2012, at 9:29 AM, Ralf Karrenberg wrote:> So, is there any chance that metadata for basic blocks is considered a > useful feature?>From your emails so far, it seems that you are using metadata as acommunication channel between passes. This does not appear to be a better approach than using LLVM's conventional pass communication channels. Dan