Clean up FFI calls for operand bundles · rust-lang/rust@c307159 (original) (raw)
`@@ -239,7 +239,6 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
`
239
239
``
240
240
`let args = self.check_call("invoke", llty, llfn, args);
`
241
241
`let funclet_bundle = funclet.map(|funclet| funclet.bundle());
`
242
``
`-
let funclet_bundle = funclet_bundle.as_ref().map(|b| &*b.raw);
`
243
242
`let mut bundles: SmallVec<[_; 2]> = SmallVec::new();
`
244
243
`if let Some(funclet_bundle) = funclet_bundle {
`
245
244
` bundles.push(funclet_bundle);
`
`@@ -250,13 +249,12 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
`
250
249
``
251
250
`// Emit KCFI operand bundle
`
252
251
`let kcfi_bundle = self.kcfi_operand_bundle(fn_attrs, fn_abi, instance, llfn);
`
253
``
`-
let kcfi_bundle = kcfi_bundle.as_ref().map(|b| &*b.raw);
`
254
``
`-
if let Some(kcfi_bundle) = kcfi_bundle {
`
``
252
`+
if let Some(kcfi_bundle) = kcfi_bundle.as_deref() {
`
255
253
` bundles.push(kcfi_bundle);
`
256
254
`}
`
257
255
``
258
256
`let invoke = unsafe {
`
259
``
`-
llvm::LLVMRustBuildInvoke(
`
``
257
`+
llvm::LLVMBuildInvokeWithOperandBundles(
`
260
258
`self.llbuilder,
`
261
259
` llty,
`
262
260
` llfn,
`
`@@ -1179,7 +1177,6 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
`
1179
1177
``
1180
1178
`let args = self.check_call("call", llty, llfn, args);
`
1181
1179
`let funclet_bundle = funclet.map(|funclet| funclet.bundle());
`
1182
``
`-
let funclet_bundle = funclet_bundle.as_ref().map(|b| &*b.raw);
`
1183
1180
`let mut bundles: SmallVec<[_; 2]> = SmallVec::new();
`
1184
1181
`if let Some(funclet_bundle) = funclet_bundle {
`
1185
1182
` bundles.push(funclet_bundle);
`
`@@ -1190,20 +1187,20 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
`
1190
1187
``
1191
1188
`// Emit KCFI operand bundle
`
1192
1189
`let kcfi_bundle = self.kcfi_operand_bundle(fn_attrs, fn_abi, instance, llfn);
`
1193
``
`-
let kcfi_bundle = kcfi_bundle.as_ref().map(|b| &*b.raw);
`
1194
``
`-
if let Some(kcfi_bundle) = kcfi_bundle {
`
``
1190
`+
if let Some(kcfi_bundle) = kcfi_bundle.as_deref() {
`
1195
1191
` bundles.push(kcfi_bundle);
`
1196
1192
`}
`
1197
1193
``
1198
1194
`let call = unsafe {
`
1199
``
`-
llvm::LLVMRustBuildCall(
`
``
1195
`+
llvm::LLVMBuildCallWithOperandBundles(
`
1200
1196
`self.llbuilder,
`
1201
1197
` llty,
`
1202
1198
` llfn,
`
1203
1199
` args.as_ptr() as *const &llvm::Value,
`
1204
1200
` args.len() as c_uint,
`
1205
1201
` bundles.as_ptr(),
`
1206
1202
` bundles.len() as c_uint,
`
``
1203
`+
c"".as_ptr(),
`
1207
1204
`)
`
1208
1205
`};
`
1209
1206
`if let Some(fn_abi) = fn_abi {
`
`@@ -1509,7 +1506,6 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
`
1509
1506
``
1510
1507
`let args = self.check_call("callbr", llty, llfn, args);
`
1511
1508
`let funclet_bundle = funclet.map(|funclet| funclet.bundle());
`
1512
``
`-
let funclet_bundle = funclet_bundle.as_ref().map(|b| &*b.raw);
`
1513
1509
`let mut bundles: SmallVec<[_; 2]> = SmallVec::new();
`
1514
1510
`if let Some(funclet_bundle) = funclet_bundle {
`
1515
1511
` bundles.push(funclet_bundle);
`
`@@ -1520,13 +1516,12 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
`
1520
1516
``
1521
1517
`// Emit KCFI operand bundle
`
1522
1518
`let kcfi_bundle = self.kcfi_operand_bundle(fn_attrs, fn_abi, instance, llfn);
`
1523
``
`-
let kcfi_bundle = kcfi_bundle.as_ref().map(|b| &*b.raw);
`
1524
``
`-
if let Some(kcfi_bundle) = kcfi_bundle {
`
``
1519
`+
if let Some(kcfi_bundle) = kcfi_bundle.as_deref() {
`
1525
1520
` bundles.push(kcfi_bundle);
`
1526
1521
`}
`
1527
1522
``
1528
1523
`let callbr = unsafe {
`
1529
``
`-
llvm::LLVMRustBuildCallBr(
`
``
1524
`+
llvm::LLVMBuildCallBr(
`
1530
1525
`self.llbuilder,
`
1531
1526
` llty,
`
1532
1527
` llfn,
`
`@@ -1601,7 +1596,7 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
`
1601
1596
`fn_abi: Option<&FnAbi<'tcx, Ty<'tcx>>>,
`
1602
1597
`instance: Option<Instance<'tcx>>,
`
1603
1598
`llfn: &'ll Value,
`
1604
``
`-
) -> Option<llvm::OperandBundleDef<'ll>> {
`
``
1599
`+
) -> Option<llvm::OperandBundleOwned<'ll>> {
`
1605
1600
`let is_indirect_call = unsafe { llvm::LLVMRustIsNonGVFunctionPointerTy(llfn) };
`
1606
1601
`let kcfi_bundle = if self.tcx.sess.is_sanitizer_kcfi_enabled()
`
1607
1602
` && let Some(fn_abi) = fn_abi
`
`@@ -1627,7 +1622,7 @@ impl<'a, 'll, 'tcx> Builder<'a, 'll, 'tcx> {
`
1627
1622
` kcfi::typeid_for_fnabi(self.tcx, fn_abi, options)
`
1628
1623
`};
`
1629
1624
``
1630
``
`-
Some(llvm::OperandBundleDef::new("kcfi", &[self.const_u32(kcfi_typeid)]))
`
``
1625
`+
Some(llvm::OperandBundleOwned::new("kcfi", &[self.const_u32(kcfi_typeid)]))
`
1631
1626
`} else {
`
1632
1627
`None
`
1633
1628
`};
`