[PATCH] D48603: llvm-lto: Set OptLevel for ThinLTO codegen

Vlad Tsyrklevich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 2 11:10:55 PDT 2018


vlad.tsyrklevich updated this revision to Diff 153759.
vlad.tsyrklevich added a comment.
Herald added subscribers: dexonsmith, eraman.

- Add test


Repository:
  rL LLVM

https://reviews.llvm.org/D48603

Files:
  test/tools/llvm-lto/thinlto-opt.ll
  tools/llvm-lto/llvm-lto.cpp


Index: tools/llvm-lto/llvm-lto.cpp
===================================================================
--- tools/llvm-lto/llvm-lto.cpp
+++ tools/llvm-lto/llvm-lto.cpp
@@ -484,6 +484,7 @@
     ThinGenerator.setCacheMaxSizeFiles(ThinLTOCacheMaxSizeFiles);
     ThinGenerator.setCacheMaxSizeBytes(ThinLTOCacheMaxSizeBytes);
     ThinGenerator.setFreestanding(EnableFreestanding);
+    ThinGenerator.setOptLevel(OptLevel - '0');
 
     // Add all the exported symbols to the table of symbols to preserve.
     for (unsigned i = 0; i < ExportedSymbols.size(); ++i)
Index: test/tools/llvm-lto/thinlto-opt.ll
===================================================================
--- /dev/null
+++ test/tools/llvm-lto/thinlto-opt.ll
@@ -0,0 +1,17 @@
+; Test that -O works with ThinLTO
+
+; RUN: opt -module-summary %s -o %t.o
+; RUN: llvm-lto -O0 -thinlto-action=optimize -o %t.O0 %t.o
+; RUN: llvm-lto -O3 -thinlto-action=optimize -o %t.O3 %t.o
+; RUN: llvm-dis %t.O0 -o - | FileCheck %s --check-prefix=O0
+; RUN: llvm-dis %t.O3 -o - | FileCheck %s --check-prefix=O3
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define void @f() {
+; O0: %dead =
+; O3-NOT: %dead =
+  %dead = add i32 1, 1
+  ret void
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48603.153759.patch
Type: text/x-patch
Size: 1260 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180702/f7006bdd/attachment.bin>


More information about the llvm-commits mailing list