[llvm] r304019 - PMB: Run the whole-program-devirt pass during LTO at --lto-O0.
Peter Collingbourne via llvm-commits
llvm-commits at lists.llvm.org
Fri May 26 11:27:14 PDT 2017
Author: pcc
Date: Fri May 26 13:27:13 2017
New Revision: 304019
URL: http://llvm.org/viewvc/llvm-project?rev=304019&view=rev
Log:
PMB: Run the whole-program-devirt pass during LTO at --lto-O0.
The whole-program-devirt pass needs to run at -O0 because only it
knows about the llvm.type.checked.load intrinsic: it needs to both
lower the intrinsic itself and handle it in the summary.
Differential Revision: https://reviews.llvm.org/D33571
Added:
llvm/trunk/test/LTO/Resolution/X86/type-checked-load.ll
Modified:
llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp
Modified: llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp?rev=304019&r1=304018&r2=304019&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/PassManagerBuilder.cpp Fri May 26 13:27:13 2017
@@ -913,6 +913,12 @@ void PassManagerBuilder::populateLTOPass
if (OptLevel != 0)
addLTOOptimizationPasses(PM);
+ else {
+ // The whole-program-devirt pass needs to run at -O0 because only it knows
+ // about the llvm.type.checked.load intrinsic: it needs to both lower the
+ // intrinsic itself and handle it in the summary.
+ PM.add(createWholeProgramDevirtPass(ExportSummary, nullptr));
+ }
// Create a function that performs CFI checks for cross-DSO calls with targets
// in the current module.
Added: llvm/trunk/test/LTO/Resolution/X86/type-checked-load.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LTO/Resolution/X86/type-checked-load.ll?rev=304019&view=auto
==============================================================================
--- llvm/trunk/test/LTO/Resolution/X86/type-checked-load.ll (added)
+++ llvm/trunk/test/LTO/Resolution/X86/type-checked-load.ll Fri May 26 13:27:13 2017
@@ -0,0 +1,16 @@
+; RUN: llvm-as -o %t %s
+; RUN: llvm-lto2 run %t -O0 -r %t,foo,px -o %t2
+
+; This just tests that we don't crash when compiling this test case.
+; It means that the wholeprogramdevirt pass must have run and lowered
+; the llvm.type.checked.load call.
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define {i8*, i1} @foo(i8* %ptr) {
+ %pair = call {i8*, i1} @llvm.type.checked.load(i8* %ptr, i32 16, metadata !"foo")
+ ret {i8*, i1} %pair
+}
+
+declare {i8*, i1} @llvm.type.checked.load(i8* %ptr, i32 %offset, metadata %type)
More information about the llvm-commits
mailing list