File tree 2 files changed +7
-1
lines changed 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -455,6 +455,10 @@ impl CallSiteValue {
455
455
456
456
/// Shortcut for setting the alignment `Attribute` for this `CallSiteValue`.
457
457
///
458
+ /// # Panics
459
+ ///
460
+ /// When the alignment is not a power of 2.
461
+ ///
458
462
/// # Example
459
463
///
460
464
/// ```no_run
@@ -475,6 +479,8 @@ impl CallSiteValue {
475
479
/// call_site_value.set_param_alignment_attribute(0, 2);
476
480
/// ```
477
481
pub fn set_param_alignment_attribute ( & self , index : u32 , alignment : u32 ) {
482
+ assert_eq ! ( alignment. count_ones( ) , 1 , "Alignment must be a power of two." ) ;
483
+
478
484
unsafe {
479
485
LLVMSetInstrParamAlignment ( self . as_value_ref ( ) , index, alignment)
480
486
}
Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ fn test_call_site() {
60
60
61
61
assert_eq ! ( call_site. get_call_convention( ) , 2 ) ;
62
62
63
- call_site. set_param_alignment_attribute ( 0 , 12 ) ;
63
+ call_site. set_param_alignment_attribute ( 0 , 16 ) ;
64
64
}
65
65
66
66
#[ test]
You can’t perform that action at this time.
0 commit comments