[LLVMdev] Overly restrictive size argument to llvm.invariant.start

Geoff Reedy geoff at programmer-monk.net
Fri Jul 29 08:33:05 PDT 2011


On Thu, Jul 28, 2011 at 11:30:29PM -0700, Nick Lewycky said
> Geoff Reedy wrote:
> > Why is it that @llvm.invariant.start requires the size argument to be a
> > constant integer literal and does not accept constant expressions? For
> > example the following IR:
> >
> > declare {}* @llvm.invariant.start(i64,i8*)
> > define void @foo() {
> >    %1 = call {}* @llvm.invariant.start(i64 ptrtoint(i8* getelementptr(i8*
> >    %null, i32 1) to i64), i8* null)
> >    ret void
> > }
> >
> > gives the following error from llvm-as:
> >
> > size argument of memory use markers must be a constant integer
> 
> Because the optimizers couldn't make use of such expressions anyway. If 
> you have TargetData, you can resolve that offsetof expression to a 
> concrete value, or else you can emit -1.

I'll allow that the optimizers might not be able to deal with arbitrary
constant expressions in a meaningful way but it seems like the case of
portable sizeof could be easily supported. Perhaps I'll have a go at
trying to make this work.

-- Geoff



More information about the llvm-dev mailing list