diff --git a/cranelift/codegen/Cargo.toml b/cranelift/codegen/Cargo.toml index 2c5ccb4d2e..2d81a660e8 100644 --- a/cranelift/codegen/Cargo.toml +++ b/cranelift/codegen/Cargo.toml @@ -21,6 +21,7 @@ hashmap_core = { version = "0.1.9", optional = true } target-lexicon = "0.8.1" log = { version = "0.4.6", default-features = false } serde = { version = "1.0.94", features = ["derive"], optional = true } +smallvec = { version = "0.6.10" } # It is a goal of the cranelift-codegen crate to have minimal external dependencies. # Please don't add any unless they are essential to the task of creating binary # machine code. Integration tests that need external dependencies can be diff --git a/cranelift/codegen/src/regalloc/virtregs.rs b/cranelift/codegen/src/regalloc/virtregs.rs index 584ad9c53a..fc267c3f61 100644 --- a/cranelift/codegen/src/regalloc/virtregs.rs +++ b/cranelift/codegen/src/regalloc/virtregs.rs @@ -21,6 +21,7 @@ use crate::packed_option::PackedOption; use crate::ref_slice::ref_slice; use core::cmp::Ordering; use core::fmt; +use smallvec::SmallVec; use std::vec::Vec; /// A virtual register reference. @@ -292,7 +293,7 @@ impl VirtRegs { /// Find the leader value and rank of the set containing `v`. /// Compress the path if needed. fn find(&mut self, mut val: Value) -> (Value, u32) { - let mut val_stack = vec![]; + let mut val_stack = SmallVec::<[Value; 8]>::new(); let found = loop { match UFEntry::decode(self.union_find[val]) { UFEntry::Rank(rank) => break (val, rank),