[PATCH] D29854: WholeProgramDevirt: Implement importing for uniform ret val opt.
Peter Collingbourne via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 10 14:51:13 PST 2017
pcc created this revision.
Depends on https://reviews.llvm.org/D29844
https://reviews.llvm.org/D29854
Files:
llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
llvm/test/Transforms/WholeProgramDevirt/Inputs/import-uniform-ret-val.yaml
llvm/test/Transforms/WholeProgramDevirt/import.ll
Index: llvm/test/Transforms/WholeProgramDevirt/import.ll
===================================================================
--- llvm/test/Transforms/WholeProgramDevirt/import.ll
+++ llvm/test/Transforms/WholeProgramDevirt/import.ll
@@ -1,4 +1,5 @@
; RUN: opt -S -wholeprogramdevirt -wholeprogramdevirt-summary-action=import -wholeprogramdevirt-read-summary=%S/Inputs/import-single-impl.yaml < %s | FileCheck --check-prefixes=CHECK,SINGLE-IMPL %s
+; RUN: opt -S -wholeprogramdevirt -wholeprogramdevirt-summary-action=import -wholeprogramdevirt-read-summary=%S/Inputs/import-uniform-ret-val.yaml < %s | FileCheck --check-prefixes=CHECK,UNIFORM-RET-VAL %s
target datalayout = "e-p:64:64"
target triple = "x86_64-unknown-linux-gnu"
@@ -15,6 +16,7 @@
%fptr_casted = bitcast i8* %fptr to i32 (i8*, i32)*
; SINGLE-IMPL: call i32 bitcast (void ()* @singleimpl1 to i32 (i8*, i32)*)
%result = call i32 %fptr_casted(i8* %obj, i32 1)
+ ; UNIFORM-RET-VAL: ret i32 42
ret i32 %result
}
@@ -32,6 +34,7 @@
cont:
%fptr_casted = bitcast i8* %fptr to i1 (i8*, i32)*
; SINGLE-IMPL: call i1 bitcast (void ()* @singleimpl2 to i1 (i8*, i32)*)
+ ; UNIFORM-RET-VAL: call i1 %
%result = call i1 %fptr_casted(i8* %obj, i32 undef)
ret i1 %result
Index: llvm/test/Transforms/WholeProgramDevirt/Inputs/import-uniform-ret-val.yaml
===================================================================
--- /dev/null
+++ llvm/test/Transforms/WholeProgramDevirt/Inputs/import-uniform-ret-val.yaml
@@ -0,0 +1,19 @@
+---
+TypeIdMap:
+ typeid1:
+ WPDRes:
+ 0:
+ Kind: Indir
+ ResByArg:
+ 1:
+ Kind: UniformRetVal
+ Info: 42
+ typeid2:
+ WPDRes:
+ 8:
+ Kind: Indir
+ ResByArg:
+ 1:
+ Kind: UniformRetVal
+ Info: 42
+...
Index: llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
===================================================================
--- llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
+++ llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
@@ -1069,6 +1069,24 @@
bool IsExported;
applySingleImplDevirt(SlotInfo, SingleImpl, IsExported);
}
+
+ for (auto &CSByConstantArg : SlotInfo.ConstCSInfo) {
+ auto I = Res.ResByArg.find(CSByConstantArg.first);
+ if (I == Res.ResByArg.end())
+ continue;
+ auto &ResByArg = I->second;
+ // FIXME: We should figure out what to do about the "function name" argument
+ // to the apply* functions, as the function names are unavailable during the
+ // importing phase. For now we just pass the empty string. This does not
+ // impact correctness because the function names are just used for remarks.
+ switch (ResByArg.TheKind) {
+ case WholeProgramDevirtResolution::ByArg::UniformRetVal:
+ applyUniformRetValOpt(CSByConstantArg.second, "", ResByArg.Info);
+ break;
+ default:
+ break;
+ }
+ }
}
void DevirtModule::removeUnusedTypeTests() {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29854.88059.patch
Type: text/x-patch
Size: 2956 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170210/72d79318/attachment.bin>
More information about the llvm-commits
mailing list