- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Add -Z small-data-threshold #117465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add -Z small-data-threshold #117465
Conversation
| Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @b-naber (or someone else) soon. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label ( 
 | 
358ff44    to
    42150ae      
    Compare
  
    | This is a more targeted version of what I was trying to achieve with #116555 (which would add  | 
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
42150ae    to
    54eada2      
    Compare
  
    
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
54eada2    to
    8a6e656      
    Compare
  
    
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
8a6e656    to
    9f35e5f      
    Compare
  
    
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
9511b44    to
    f4f0492      
    Compare
  
    f4f0492    to
    aefc127      
    Compare
  
    | Sorry for the late reply. I think this needs an MCP before it can be merged. | 
| ☔ The latest upstream changes (presumably #118178) made this pull request unmergeable. Please resolve the merge conflicts. | 
| This could be merged now. Can you rebase? | 
| There's still some lack of clarity on the MCP zulip stream whether this is the right way to solve the problem, versus a target feature. I'll push the rebase but it's probably best to not merge it yet. | 
aefc127    to
    4660911      
    Compare
  
    4660911    to
    a618f74      
    Compare
  
    | OK, the conclusion on the zulip chat appeared to be that a target feature wasn't the right approach, so I think this is ready. | 
| @b-naber can you r+? If I understand this patch is ripe for merging. thanks. | 
| r? compiler-errors @bors r+ | 
      
        
              This comment has been minimized.
        
        
      
    
  This comment has been minimized.
c338170    to
    d470615      
    Compare
  
    | In the last update, I tweaked it to include a default based on the architecture, to avoid having to duplicate the support in many different target files. | 
| // Set up the small-data optimization limit for architectures that use | ||
| // an LLVM module flag to control this. | ||
| (Some(threshold), SmallDataThresholdSupport::LlvmModuleFlag(flag)) => { | ||
| let flag = format!("{flag}\0"); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a CString for that, no need to manually add nulls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like let flag = CString::new(flag).unwrap()? Or should SmallDataThresholdSupport::LllvmModuleFlag contain a StaticCow<Cstr> rather than StaticCow<str>?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, changing type to StaticCow<Cstr> is probably no needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, tweaked to use let flag = SmallCStr::new(flag.as_ref());
| //@ RISCV-NOT: .section | ||
| //@ RISCV: U: | ||
| //@ RISCV: .section .sbss | ||
| //@ RISV-NOT: .section | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops. A bunch of copy-pasted typos, sorry. :-(
| //@ RISV-NOT: .section | ||
| //@ RISCV: V: | ||
| //@ RISCV .section .sdata | ||
| //@ RISV-NOT: .section | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here too
| //@ RISV-NOT: .section | ||
| //@ RISCV: W: | ||
| //@ RISCV: .section .sbss | ||
| //@ RISV-NOT: .section | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...
| //@ MIPS-NOT: .section | ||
| //@ MIPS: U: | ||
| //@ MIPS: .section .sbss | ||
| //@ RISV-NOT: .section | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and 2 next looks like should be MIPS-NOT?
| //@ RISCV: .section .sbss | ||
| //@ RISV-NOT: .section | ||
| //@ RISCV: V: | ||
| //@ RISCV .section .sdata | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:
| //@ MIPS: .section .sbss | ||
| //@ RISV-NOT: .section | ||
| //@ MIPS: V: | ||
| //@ MIPS .section .sdata | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:
This flag allows specifying the threshold size above which LLVM should not consider placing small objects in a .sdata or .sbss section. Support is indicated in the target options via the small-data-threshold-support target option, which can indicate either an LLVM argument or an LLVM module flag. To avoid duplicate specifications in a large number of targets, the default value for support is DefaultForArch, which is translated to a concrete value according to the target's architecture.
d470615    to
    3810386      
    Compare
  
    | I fixed the typos in the tests. | 
| @bors r+ | 
| Thanks @klensy for your thorough reviews as always | 
| @bors rollup=iffy | 
| ☀️ Test successful - checks-actions | 
| Finished benchmarking commit (1f51450): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results (primary 1.5%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment. 
 CyclesResults (primary 6.5%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment. 
 Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 756.297s -> 757.698s (0.19%) | 
This flag allows specifying the threshold size above which LLVM should not consider placing small objects in a
.sdataor.sbsssection.Support is indicated in the target options via the
small-data-threshold-support target option, which can indicate either an
LLVM argument or an LLVM module flag. To avoid duplicate specifications
in a large number of targets, the default value for support is
DefaultForArch, which is translated to a concrete value according to the
target's architecture.