[LLVMdev] How to Obtain a DataLayout Reference Given a Function & F

Kamal Sharma kgs1.rice at gmail.com
Mon Jun 22 14:53:28 PDT 2015


On Mon, Jun 22, 2015 at 12:58 PM, John Criswell <jtcriswel at gmail.com> wrote:

>  On 6/22/15 2:29 PM, Peter Finn wrote:
>
> I’ve been debugging SAFECode source code files, and line 170 in
> ArrayBoundCheckLocal.cpp has been causing the following compilation error:
>
>  In file included from
> /Users/peterfinn/Desktop/llvm_trunk_2/projects/safecode/lib/ArrayBoundChecks/ArrayBoundCheckLocal.cpp:18:
> In file included from
> /Users/peterfinn/Desktop/build/projects/safecode/../../../llvm_trunk_2/projects/safecode/include/safecode/ArrayBoundsCheck.h:17:
> In file included from
> /Users/peterfinn/Desktop/build/projects/safecode/../../../llvm_trunk_2/projects/safecode/include/safecode/AllocatorInfo.h:21:
> In file included from
> /Users/peterfinn/Desktop/llvm_trunk_2/include/llvm/IR/Module.h:20:
> In file included from
> /Users/peterfinn/Desktop/llvm_trunk_2/include/llvm/IR/DataLayout.h:27:
> In file included from
> /Users/peterfinn/Desktop/llvm_trunk_2/include/llvm/Pass.h:378:
> */Users/peterfinn/Desktop/llvm_trunk_2/include/llvm/PassAnalysisSupport.h:201:53:
> **error: **no member named 'ID' in 'llvm::DataLayout'*
>   return getAnalysisID<AnalysisType>(&AnalysisType::ID);
> *                                      ~~~~~~~~~~~~~~^*
> */Users/peterfinn/Desktop/llvm_trunk_2/projects/safecode/lib/ArrayBoundChecks/ArrayBoundCheckLocal.cpp:170:9:
> note: *in instantiation of function template specialization
>       'llvm::Pass::getAnalysis<llvm::DataLayout>' requested here
>   TD = &getAnalysis<DataLayout>();
> *        ^*
> 1 error generated.
> make[2]: ***
> [/Users/peterfinn/Desktop/build/projects/safecode/lib/ArrayBoundChecks/Debug+Asserts/ArrayBoundCheckLocal.o]
> Error 1
> make[1]: *** [ArrayBoundChecks/.makeall] Error 2
> make: *** [all] Error 1
>
>  I assume I need to obtain a DataLayout reference from the argument of
> the function “runOnFunction”.  Is this correct?  If so, how do I do this?
> If not, what is supposed to be done instead?
>
>
> If you have a pointer to a Function object, you can get the Module in
> which the Function resides by calling the getParent() method of Function.
> If F is a pointer to an llvm::Function, then
>
> F->getParent()
>
> ... should return a pointer (or reference; I'm not sure which) to the
> Function's containing module.
>
> Once you have the Module, you can get the DataLayout.
>
> Regards,
>
> John Criswell
>
>
>  Thanks,
> Peter Finn
>
>
> _______________________________________________
> LLVM Developers mailing listLLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.eduhttp://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
>
> --
> John Criswell
> Assistant Professor
> Department of Computer Science, University of Rochesterhttp://www.cs.rochester.edu/u/criswell <https://urldefense.proofpoint.com/v2/url?u=http-3A__www.cs.rochester.edu_u_criswell&d=AwMD-g&c=8hUWFZcy2Z-Za5rBPlktOQ&r=Mfk2qtn1LTDThVkh6-oGglNfMADXfJdty4_bhmuhMHA&m=RX2VsepnsRpeviZdtI4AHZNkYk7hZp4avI5KZZhXttk&s=eUPRdR1rCx9Ui9iNQKxkju46lFOGfMenIVdaRaqW024&e=>
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
InstCombine pass in LLVM has an example of DataLayout.
http://llvm.org/docs/doxygen/html/InstructionCombining_8cpp_source.html
Line 2979.

Regards,
Kamal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150622/991bd4be/attachment.html>


More information about the llvm-dev mailing list