Index: lib/IR/Constants.cpp =================================================================== --- lib/IR/Constants.cpp +++ lib/IR/Constants.cpp @@ -1409,8 +1409,10 @@ } BlockAddress::BlockAddress(Function *F, BasicBlock *BB) -: Constant(Type::getInt8PtrTy(F->getContext()), Value::BlockAddressVal, - &Op<0>(), 2) { + : Constant(Type::getInt8PtrTy( + F->getContext(), + F->getParent()->getDataLayout().getProgramAddressSpace()), + Value::BlockAddressVal, &Op<0>(), 2) { setOperand(0, F); setOperand(1, BB); BB->AdjustBlockAddressRefCount(1);