[clang] [llvm] [LoongArch] Add options for annotate tablejump (PR #102411)

via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 11 23:45:51 PDT 2024


heiher wrote:

```llvm
define void @switch_4_arms(i32 %in, ptr %out) nounwind {
entry:                                                                          
  switch i32 %in, label %exit [                                                 
    i32 1, label %bb1                                                           
    i32 2, label %bb2                                                           
    i32 3, label %bb3                                                           
    i32 4, label %bb4                                                           
  ]                                                                             
bb1:                                                                            
  store i32 4, ptr %out                                                         
  br label %exit                                                                
bb2:                                                                            
  store i32 3, ptr %out                                                         
  br label %exit                                                                
bb3:                                                                            
  store i32 2, ptr %out                                                         
  br label %exit                                                                
bb4:                                                                            
  store i32 1, ptr %out                                                         
  br label %exit                                                                
exit:                                                                           
  switch i32 %in, label %exit2 [                                                
    i32 5, label %bb1                                                           
    i32 6, label %bb2                                                           
    i32 7, label %bb3                                                           
    i32 8, label %bb4                                                           
  ]                                                                             
exit2:                                                                          
  ret void                                                                      
}
```

```asm
    .section    .discard.tablejump_annotate,"", at progbits                        
    .dword  .Ljrtb_0                                                            
    .dword  .LJTI0_0                                                            
    .dword  .Ljrtb_1                                                            
    .dword  .LJTI0_0                                                            
    .dword  .Ljrtb_0                                                            
    .dword  .LJTI0_1                                                            
    .dword  .Ljrtb_1                                                            
    .dword  .LJTI0_1
```

Is this expected?

https://github.com/llvm/llvm-project/pull/102411


More information about the cfe-commits mailing list