File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 1+ //  Tests that callback function whose address is taken is attached Type ID metadata
2+ //  as it is a potential indirect call target.
3+ 
4+ //  RUN: %clang_cc1 -triple x86_64-unknown-linux -fexperimental-call-graph-section \
5+ // RUN: -emit-llvm -o %t %s 
6+ //  RUN: FileCheck %s < %t
7+ 
8+ // //////////////////////////////////////////////////////////////////////////////
9+ typedef  void  (*CallbackFn)(int );
10+ 
11+ //  Callback function with "internal" linkage.
12+ //  CHECK-DAG: define internal void @_ZL10myCallbacki({{.*}} !type [[F_CALLBACK:![0-9]+]]
13+ static  void  myCallback (int  value) 
14+ {
15+     volatile  int  sink = value;
16+     (void )sink;
17+ }
18+ 
19+ int  takeCallbackAddress () {
20+     //  Take the address of the callback explicitly (address-taken function)
21+     CallbackFn cb = &myCallback;
22+     //  Store the address in a volatile pointer to keep it observable
23+     volatile  void * addr = (void *)cb;
24+     (void )addr;
25+ 
26+     return  0 ;
27+ }
28+ 
29+ //  CHECK-DAG: [[F_CALLBACK]]   = !{i64 0, !"_ZTSFviE.generalized"}
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments