From 8fcb498a9a0825c7f6fd114f4832a5f875a05db4 Mon Sep 17 00:00:00 2001 From: Ramkumar Ramachandra Date: Sat, 14 Feb 2015 19:37:54 +0000 Subject: InstCombine: propagate deref via new addDereferenceableAttr The "dereferenceable" attribute cannot be added via .addAttribute(), since it also expects a size in bytes. AttrBuilder#addAttribute or AttributeSet#addAttribute is wrapped by classes Function, InvokeInst, and CallInst. Add corresponding wrappers to AttrBuilder#addDereferenceableAttr. Having done this, propagate the dereferenceable attribute via gc.relocate, adding a test to exercise it. Note that -datalayout is required during execution over and above -instcombine, because InstCombine only optionally requires DataLayoutPass. Differential Revision: http://reviews.llvm.org/D7510 llvm-svn: 229265 --- llvm/lib/IR/Function.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'llvm/lib/IR/Function.cpp') diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp index fe44f17d686..33e15262524 100644 --- a/llvm/lib/IR/Function.cpp +++ b/llvm/lib/IR/Function.cpp @@ -343,6 +343,12 @@ void Function::removeAttributes(unsigned i, AttributeSet attrs) { setAttributes(PAL); } +void Function::addDereferenceableAttr(unsigned i, uint64_t Bytes) { + AttributeSet PAL = getAttributes(); + PAL = PAL.addDereferenceableAttr(getContext(), i, Bytes); + setAttributes(PAL); +} + // Maintain the GC name for each function in an on-the-side table. This saves // allocating an additional word in Function for programs which do not use GC // (i.e., most programs) at the cost of increased overhead for clients which do -- cgit v1.2.3