ValueType = 1, None = 0, }; } llvm::GlobalValue *IRGenModule::defineTypeMetadata(...) { ... unsigned adjustmentIndex; ... if (...) { ... } else { ... adjustmentIndex = MetadataAdjustmentIndex::ValueType; } ... llvm::GlobalVariable *var = cast<llvm::GlobalVariable>(getAddrOfLLVMVariable(...)); ... llvm::Constant *addr = var; if (adjustmentIndex) { llvm::Constant *indices[] = { llvm::ConstantInt::get(Int32Ty, 0), llvm::ConstantInt::get(Int32Ty, adjustmentIndex) }; addr = llvm::ConstantExpr::getInBoundsGetElementPtr(/*Ty=*/nullptr, addr, indices); } addr = llvm::ConstantExpr::getBitCast(addr, TypeMetadataPtrTy); ... auto *alias = llvm::GlobalAlias::create(..., addr, ...); ... return alias; } 20