0
다음 간단한 함수 고려해연타 모든 기능 noinline 속성을 추가
; ModuleID = 'foo.cpp'
source_filename = "foo.cpp"
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.13.0"
; Function Attrs: noinline nounwind ssp uwtable
define i32 @_Z3foov() #0 {
ret i32 42
}
attributes #0 = { noinline nounwind ssp uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "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" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="penryn" "target-features"="+cx16,+fxsr,+mmx,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
!llvm.module.flags = !{!0}
!llvm.ident = !{!1}
!0 = !{i32 1, !"PIC Level", i32 2}
!1 = !{!"Apple LLVM version 9.0.0 (clang-900.0.37)"}
가 왜 foo
함수 :
int foo() { return 42; }
clang -emit-llvm -S foo.cpp
통해 LLVM이 컴파일 다음 모듈 생산 noinline
으로 신고하셨습니까? 최적화 수준 (-O0
제외)이 지정되어 있으면 플래그가 추가되지 않지만이를 피하고 싶습니다.
다른 방법이 있습니까/플래그가 있습니까? 당신은 할 수있다, 당신의 요구 사항에 따라
// At O0 we want to fully disable inlining outside of cases marked with
// 'alwaysinline' that are required for correctness.
Opts.setInlining((Opts.OptimizationLevel == 0)
? CodeGenOptions::OnlyAlwaysInlining
: CodeGenOptions::NormalInlining);
:
은 (디버그 할 수 있어야)는 최적화되지 않은 빌드, 함수는 인라인되지 않습니다, 나에게 의미가 있습니다. 왜 다른 이유가 필요한거야? –
외부 도구를 사용하여 추가/수정을하고 싶기 때문에 (나중에 최적화되지 않아야 함) 수정 된 모듈을 나중에 'opt'에 전달하고 최적화 할 수 있기를 원합니다. – jfrohnhofen