Skip to content

Commit 8d7084d

Browse files
committed
Simplify the bundles vectors.
After the last commit, they contain `Option<&OperandBundleDef<'a>>` but the values are always `Some(_)`. This commit removes the needless `Option` wrapper. This also simplifies the type signatures of `LLVMRustBuild{Invoke,Call}`, which were relying on the fact that the represention of `Option<&T>` is the same as `&T` for non-`None` values.
1 parent 81436eb commit 8d7084d

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

compiler/rustc_codegen_llvm/src/builder.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
227227
let funclet_bundle = funclet.map(|funclet| funclet.bundle());
228228
let funclet_bundle = funclet_bundle.as_ref().map(|b| &*b.raw);
229229
let mut bundles: SmallVec<[_; 2]> = SmallVec::new();
230-
if funclet_bundle.is_some() {
230+
if let Some(funclet_bundle) = funclet_bundle {
231231
bundles.push(funclet_bundle);
232232
}
233233

@@ -237,7 +237,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
237237
// Emit KCFI operand bundle
238238
let kcfi_bundle = self.kcfi_operand_bundle(fn_attrs, fn_abi, llfn);
239239
let kcfi_bundle = kcfi_bundle.as_ref().map(|b| &*b.raw);
240-
if kcfi_bundle.is_some() {
240+
if let Some(kcfi_bundle) = kcfi_bundle {
241241
bundles.push(kcfi_bundle);
242242
}
243243

@@ -1195,7 +1195,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
11951195
let funclet_bundle = funclet.map(|funclet| funclet.bundle());
11961196
let funclet_bundle = funclet_bundle.as_ref().map(|b| &*b.raw);
11971197
let mut bundles: SmallVec<[_; 2]> = SmallVec::new();
1198-
if funclet_bundle.is_some() {
1198+
if let Some(funclet_bundle) = funclet_bundle {
11991199
bundles.push(funclet_bundle);
12001200
}
12011201

@@ -1205,7 +1205,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
12051205
// Emit KCFI operand bundle
12061206
let kcfi_bundle = self.kcfi_operand_bundle(fn_attrs, fn_abi, llfn);
12071207
let kcfi_bundle = kcfi_bundle.as_ref().map(|b| &*b.raw);
1208-
if kcfi_bundle.is_some() {
1208+
if let Some(kcfi_bundle) = kcfi_bundle {
12091209
bundles.push(kcfi_bundle);
12101210
}
12111211

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1301,7 +1301,7 @@ extern "C" {
13011301
NumArgs: c_uint,
13021302
Then: &'a BasicBlock,
13031303
Catch: &'a BasicBlock,
1304-
OpBundles: *const Option<&OperandBundleDef<'a>>,
1304+
OpBundles: *const &OperandBundleDef<'a>,
13051305
NumOpBundles: c_uint,
13061306
Name: *const c_char,
13071307
) -> &'a Value;
@@ -1673,7 +1673,7 @@ extern "C" {
16731673
Fn: &'a Value,
16741674
Args: *const &'a Value,
16751675
NumArgs: c_uint,
1676-
OpBundles: *const Option<&OperandBundleDef<'a>>,
1676+
OpBundles: *const &OperandBundleDef<'a>,
16771677
NumOpBundles: c_uint,
16781678
) -> &'a Value;
16791679
pub fn LLVMRustBuildMemCpy<'a>(

0 commit comments

Comments
 (0)