search for: get_fptr

Displaying 20 results from an estimated 24 matches for "get_fptr".

2018 Apr 09
2
ThinLTO + CFI
...s point to jump table entries. It appears that I’m hitting a limitation in ThinLTO on how much information it can propagate across modules, particularly information about constants. In the example below, the fact that “i” is effectively a constant, is lost under ThinLTO, and the inlined copy of b.c:get_fptr() in a.c does not eliminate the conditional, which, for CFI purposes requires to generate a type check/jump table. I was wondering if there was a way to mitigate this limitation. a.c ============================= typedef int (*fptr_t) (void); fptr_t get_fptr(); int main(int argc, char *argv[]) {...
2018 Apr 17
3
ThinLTO + CFI
...er person to answer. But on the issue of global variables being optimized, that hasn't happened yet. That would be great if you wanted to pick that up! In your original email example, it seems like the file static i=53 could be constant propagated since there are no other defs, and the code in get_fptr simplified during the compile step, but I assume this is part of a more complex example where it is not possible to do this? Also note that with r327254 we started importing global variables. Do you know why we don't import in your case? I wonder if it has to do with it being CFI inserted code?...
2018 Apr 27
3
ThinLTO + CFI
...this can be fixed by replacing direct > calls to jump tables with direct calls to real targets, I found other cases > where ThinLTO+CFI has issues. > > In ThinLTO backend, type test lowering happens very early in the pipeline, > before inlining. When the type check after the call to get_fptr() is > lowered (in my original example, below), the compiler cannot see that both > targets belong to the same type and that the type check will always return > ‘true’ and can be eliminated. Moving the type check lowering pass further > down the pipeline (after inlining) still does not...
2018 Apr 27
0
ThinLTO + CFI
...achable, !nosanitize !9 ; <label>:10: ; preds = %2 %11 = tail call i32 %5() #5 ret i32 %11 } . . . declare hidden i32 @foo() #3 declare hidden i32 @bar() #3 —————————test case--------------- b.c ================= typedef int (*fptr_t) (void); fptr_t get_fptr(); extern int i; int main(int argc, char *argv[]) { i = argc - 2; fptr_t fp = get_fptr(); return fp(); } v.c ================ int i; typedef int (*fptr_t) (void); int foo(void) { return 11; } int bar(void) { return 22; } fptr_t get_fptr(void) { return (i >= 0) ? foo : bar; } > On...
2018 Apr 30
4
ThinLTO + CFI
...; preds = %2 > %11 = tail call i32 %5() #5 > ret i32 %11 > } > > . . . > declare hidden i32 @foo() #3 > declare hidden i32 @bar() #3 > > > —————————test case--------------- > b.c > ================= > typedef int (*fptr_t) (void); > fptr_t get_fptr(); > extern int i; > > int main(int argc, char *argv[]) > { > i = argc - 2; > fptr_t fp = get_fptr(); > return fp(); > } > > v.c > ================ > int i; > typedef int (*fptr_t) (void); > int foo(void) { return 11; } > int bar(void) { return 22;...
2018 Apr 17
0
ThinLTO + CFI
...s point to jump table entries. It appears that I’m hitting a limitation in ThinLTO on how much information it can propagate across modules, particularly information about constants. In the example below, the fact that “i” is effectively a constant, is lost under ThinLTO, and the inlined copy of b.c:get_fptr() in a.c does not eliminate the conditional, which, for CFI purposes requires to generate a type check/jump table. > > I was wondering if there was a way to mitigate this limitation. > > a.c > ============================= > typedef int (*fptr_t) (void); > fptr_t get_fptr();...
2018 May 14
1
ThinLTO + CFI
...; preds = %2 > %11 = tail call i32 %5() #5 > ret i32 %11 > } > > . . . > declare hidden i32 @foo() #3 > declare hidden i32 @bar() #3 > > > —————————test case--------------- > b.c > ================= > typedef int (*fptr_t) (void); > fptr_t get_fptr(); > extern int i; > > int main(int argc, char *argv[]) > { > i = argc - 2; > fptr_t fp = get_fptr(); > return fp(); > } > v.c > ================ > int i; > typedef int (*fptr_t) (void); > int foo(void) { return 11; } > int bar(void) { return 22; } &g...
2018 Apr 20
2
ThinLTO + CFI
...bles being >> optimized, that hasn't happened yet. That would be great if you wanted to >> pick that up! >> >> In your original email example, it seems like the file static i=53 could >> be constant propagated since there are no other defs, and the code in >> get_fptr simplified during the compile step, but I assume this is part of a >> more complex example where it is not possible to do this? Also note that >> with r327254 we started importing global variables. Do you know why we >> don't import in your case? I wonder if it has to do with...
2018 Apr 26
0
ThinLTO + CFI
...ted from indirect. While this can be fixed by replacing direct calls to jump tables with direct calls to real targets, I found other cases where ThinLTO+CFI has issues. In ThinLTO backend, type test lowering happens very early in the pipeline, before inlining. When the type check after the call to get_fptr() is lowered (in my original example, below), the compiler cannot see that both targets belong to the same type and that the type check will always return ‘true’ and can be eliminated. Moving the type check lowering pass further down the pipeline (after inlining) still does not solve the problem be...
2018 Apr 18
0
ThinLTO + CFI
...er person to answer. But on the issue of global variables being optimized, that hasn't happened yet. That would be great if you wanted to pick that up! In your original email example, it seems like the file static i=53 could be constant propagated since there are no other defs, and the code in get_fptr simplified during the compile step, but I assume this is part of a more complex example where it is not possible to do this? Also note that with r327254 we started importing global variables. Do you know why we don't import in your case? I wonder if it has to do with it being CFI inserted code?...
2018 Apr 19
3
ThinLTO + CFI
...he issue of global variables being > optimized, that hasn't happened yet. That would be great if you wanted to > pick that up! > > In your original email example, it seems like the file static i=53 could > be constant propagated since there are no other defs, and the code in > get_fptr simplified during the compile step, but I assume this is part of a > more complex example where it is not possible to do this? Also note that > with r327254 we started importing global variables. Do you know why we > don't import in your case? I wonder if it has to do with it being CFI...
2018 May 01
0
ThinLTO + CFI
...t; > ret i32 %11 > > } > > > > . . . > > declare hidden i32 @foo() #3 > > declare hidden i32 @bar() #3 > > > > > > —————————test case--------------- > > b.c > > ================= > > typedef int (*fptr_t) (void); > > fptr_t get_fptr(); > > extern int i; > > > > int main(int argc, char *argv[]) > > { > > i = argc - 2; > > fptr_t fp = get_fptr(); > > return fp(); > > } > > > > v.c > > ================ > > int i; > > typedef int (*fptr_t) (void); &gt...
2018 May 01
2
ThinLTO + CFI
...> ret i32 %11 > > } > > > > . . . > > declare hidden i32 @foo() #3 > > declare hidden i32 @bar() #3 > > > > > > —————————test case--------------- > > b.c > > ================= > > typedef int (*fptr_t) (void); > > fptr_t get_fptr(); > > extern int i; > > > > int main(int argc, char *argv[]) > > { > > i = argc - 2; > > fptr_t fp = get_fptr(); > > return fp(); > > } > > > > v.c > > ================ > > int i; > > typedef int (*fptr_t) (void); &...
2018 May 01
0
ThinLTO + CFI
...t; > ret i32 %11 > > } > > > > . . . > > declare hidden i32 @foo() #3 > > declare hidden i32 @bar() #3 > > > > > > —————————test case--------------- > > b.c > > ================= > > typedef int (*fptr_t) (void); > > fptr_t get_fptr(); > > extern int i; > > > > int main(int argc, char *argv[]) > > { > > i = argc - 2; > > fptr_t fp = get_fptr(); > > return fp(); > > } > > > > v.c > > ================ > > int i; > > typedef int (*fptr_t) (void); &gt...
2018 May 01
2
ThinLTO + CFI
...> . . . > > > declare hidden i32 @foo() #3 > > > declare hidden i32 @bar() #3 > > > > > > > > > —————————test case--------------- > > > b.c > > > ================= > > > typedef int (*fptr_t) (void); > > > fptr_t get_fptr(); > > > extern int i; > > > > > > int main(int argc, char *argv[]) > > > { > > > i = argc - 2; > > > fptr_t fp = get_fptr(); > > > return fp(); > > > } > > > > > > v.c > > > ================ &gt...
2018 May 01
0
ThinLTO + CFI
...t; > . . . > > > declare hidden i32 @foo() #3 > > > declare hidden i32 @bar() #3 > > > > > > > > > —————————test case--------------- > > > b.c > > > ================= > > > typedef int (*fptr_t) (void); > > > fptr_t get_fptr(); > > > extern int i; > > > > > > int main(int argc, char *argv[]) > > > { > > > i = argc - 2; > > > fptr_t fp = get_fptr(); > > > return fp(); > > > } > > > > > > v.c > > > ================ >...
2018 May 01
2
ThinLTO + CFI
...n i32 @foo() #3 > > > > declare hidden i32 @bar() #3 > > > > > > > > > > > > —————————test case--------------- > > > > b.c > > > > ================= > > > > typedef int (*fptr_t) (void); > > > > fptr_t get_fptr(); > > > > extern int i; > > > > > > > > int main(int argc, char *argv[]) > > > > { > > > > i = argc - 2; > > > > fptr_t fp = get_fptr(); > > > > return fp(); > > > > } > > > > > >...
2018 May 01
0
ThinLTO + CFI
...den i32 @foo() #3 > > > > declare hidden i32 @bar() #3 > > > > > > > > > > > > —————————test case--------------- > > > > b.c > > > > ================= > > > > typedef int (*fptr_t) (void); > > > > fptr_t get_fptr(); > > > > extern int i; > > > > > > > > int main(int argc, char *argv[]) > > > > { > > > > i = argc - 2; > > > > fptr_t fp = get_fptr(); > > > > return fp(); > > > > } > > > > > > &...
2018 May 01
0
ThinLTO + CFI
...t; declare hidden i32 @bar() #3 > > > > > > > > > > > > > > > —————————test case--------------- > > > > > b.c > > > > > ================= > > > > > typedef int (*fptr_t) (void); > > > > > fptr_t get_fptr(); > > > > > extern int i; > > > > > > > > > > int main(int argc, char *argv[]) > > > > > { > > > > > i = argc - 2; > > > > > fptr_t fp = get_fptr(); > > > > > return fp(); > > > &gt...
2018 May 01
2
ThinLTO + CFI
...declare hidden i32 @bar() #3 > > > > > > > > > > > > > > > —————————test case--------------- > > > > > b.c > > > > > ================= > > > > > typedef int (*fptr_t) (void); > > > > > fptr_t get_fptr(); > > > > > extern int i; > > > > > > > > > > int main(int argc, char *argv[]) > > > > > { > > > > > i = argc - 2; > > > > > fptr_t fp = get_fptr(); > > > > > return fp(); > > > &g...