[PATCH] D22666: Frontend: Fix mcount inlining bug

Honggyu Kim via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 5 19:51:43 PDT 2016


honggyu.kim added a comment.

I see the difference now.
Below is the originally generated IR without this patch.  It shows `\01` clearly in `call void @"\01__gnu_mcount_nc"()`.

  $ clang -target armv7-unknown-none-eabi -pg -meabi gnu -S -emit-llvm -o - test-mcount.c
  ; ModuleID = 'mcount.c'
  source_filename = "mcount.c"
  target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
  target triple = "armv7-unknown-none-eabi"
  
  ; Function Attrs: nounwind
  define i32 @f() #0 {
    call void @"\01__gnu_mcount_nc"() #1
    ret i32 0
  }
  
  declare void @"\01__gnu_mcount_nc"()
  
  attributes #0 = { nounwind "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="cortex-a8" "target-features"="+dsp,+neon,+strict-align,+vfp3" "unsafe-fp-math"="false" "use-soft-float"="false" }
  attributes #1 = { nounwind }
    ...

Here is the IR result with this patch.  But it doesn't show `\01` in front of __gnu_mcount_nc in attribute list. It shows only `"counting-function"="__gnu_mcount_nc"` here but if I dump the output into a file then open it, it shows as `"counting-function"="^A__gnu_mcount_nc"`. Maybe there's some mishandling of `\01` prefix whiling passing string that I didn't find yet.

  $ clang -target armv7-unknown-none-eabi -pg -meabi gnu -S -emit-llvm -o - test-mcount.c
  ; ModuleID = 'mcount.c'
  source_filename = "mcount.c"
  target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
  target triple = "armv7-unknown-none-eabi"
  
  ; Function Attrs: nounwind
  define i32 @f() #0 {
    ret i32 0
  }
  
  attributes #0 = { nounwind "counting-function"="__gnu_mcount_nc" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="cortex-a8" "target-features"="+dsp,+neon,+strict-align,+vfp3" "unsafe-fp-math"="false" "use-soft-float"="false" }
    ...


https://reviews.llvm.org/D22666





More information about the cfe-commits mailing list