mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Add support for running LLVM optimizer. (#6225)
Adds a flag `--optimize=<mode>` that specifies what to optimize for: * `--optimize=none` turns off the optimizer as much as possible, but still respects always_inline. * `--optimize=debug` aims to be the equivalent of `-Og` / `-O1`, and provides optimizations that don't affect the ability to debug the program. This is the default. * `--optimize=size` optimizes for the size of the produced program, and aims to be the equivalent of `-Oz`. * `--optimize=speed` optimizes for the execution time of the produced program, and aims to be the equivalent of `-O3`. Following the approach taken by Clang, the optimization level feeds into both the configuration of the LLVM pass pipeline and the attributes added to function definitions generated by the frontend. Optimization is performed in a new phase, `optimize`, which runs between `lower` and `codegen`. --------- Co-authored-by: Dana Jansens <danakj@orodu.net> Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
This commit is contained in:
co-authored by
Dana Jansens
Chandler Carruth
parent
db150ffc5c
commit
aa69a484eb
@@ -37,21 +37,23 @@ fn F() {
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: $_ZN1XIiE1fEi = comdat any
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: define void @_CF.Main() !dbg !7 {
|
||||
// CHECK:STDOUT: ; Function Attrs: nounwind
|
||||
// CHECK:STDOUT: define void @_CF.Main() #0 !dbg !7 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: call void @_ZN1XIiE1fEi(i32 42), !dbg !10
|
||||
// CHECK:STDOUT: ret void, !dbg !11
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: ; Function Attrs: mustprogress noinline nounwind optnone
|
||||
// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN1XIiE1fEi(i32 %t) #0 comdat align 2 {
|
||||
// CHECK:STDOUT: define linkonce_odr dso_local void @_ZN1XIiE1fEi(i32 %t) #1 comdat align 2 {
|
||||
// CHECK:STDOUT: entry:
|
||||
// CHECK:STDOUT: %t.addr = alloca i32, align 4
|
||||
// CHECK:STDOUT: store i32 %t, ptr %t.addr, align 4
|
||||
// CHECK:STDOUT: ret void
|
||||
// CHECK:STDOUT: }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: attributes #0 = { mustprogress noinline nounwind optnone "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="0" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
|
||||
// CHECK:STDOUT: attributes #0 = { nounwind }
|
||||
// CHECK:STDOUT: attributes #1 = { mustprogress noinline nounwind optnone "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="0" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
|
||||
// CHECK:STDOUT:
|
||||
// CHECK:STDOUT: !llvm.module.flags = !{!0, !1, !2, !3, !4}
|
||||
// CHECK:STDOUT: !llvm.dbg.cu = !{!5}
|
||||
|
||||
Reference in New Issue
Block a user