Overly restrictive size argument to llvm.invariant.start

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

-- Geoff Reedy

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.

Nick

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