Geoff Reedy
2011-Jul-29 05:57 UTC
[LLVMdev] 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
Nick Lewycky
2011-Jul-29 06:30 UTC
[LLVMdev] Overly restrictive size argument to llvm.invariant.start
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 integerBecause 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
Geoff Reedy
2011-Jul-29 15:33 UTC
[LLVMdev] Overly restrictive size argument to llvm.invariant.start
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