[PATCH] D58071: Fix auto-upgrade for the new parameter to llvm.objectsize
Erik Pilkington via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 11 13:14:28 PST 2019
erik.pilkington created this revision.
erik.pilkington added reviewers: vsk, steven_wu.
Herald added subscribers: dexonsmith, jkorous, hiraditya.
Herald added a project: LLVM.
D56761 <https://reviews.llvm.org/D56761> added a 'dynamic' parameter to objectsize, but the AutoUpgrade changes were incomplete. Also, fix an off-by-one error I made in the upgrade logic that is now no longer unreachable.
Thanks!
Repository:
rL LLVM
https://reviews.llvm.org/D58071
Files:
llvm/lib/IR/AutoUpgrade.cpp
llvm/test/Bitcode/upgrade-objectsize.ll
Index: llvm/test/Bitcode/upgrade-objectsize.ll
===================================================================
--- /dev/null
+++ llvm/test/Bitcode/upgrade-objectsize.ll
@@ -0,0 +1,13 @@
+; RUN: opt -S < %s | FileCheck %s
+
+; Test to enssure that calls to llvm.objectsize are auto-upgraded to to add a
+; 'dynamic' parameter.
+
+define void @callit(i8* %ptr) {
+ %sz = call i64 @llvm.objectsize.i64.p0i8(i8* %ptr, i1 false, i1 true)
+ ; CHECK: %sz = call i64 @llvm.objectsize.i64.p0i8(i8* %ptr, i1 false, i1 true, i1 false)
+ ret void
+}
+
+declare i64 @llvm.objectsize.i64.p0i8(i8*, i1, i1)
+; CHECK: declare i64 @llvm.objectsize.i64.p0i8(i8*, i1, i1, i1)
Index: llvm/lib/IR/AutoUpgrade.cpp
===================================================================
--- llvm/lib/IR/AutoUpgrade.cpp
+++ llvm/lib/IR/AutoUpgrade.cpp
@@ -743,7 +743,7 @@
// address space.
if (Name.startswith("objectsize.")) {
Type *Tys[2] = { F->getReturnType(), F->arg_begin()->getType() };
- if (F->arg_size() == 2 ||
+ if (F->arg_size() == 2 || F->arg_size() == 3 ||
F->getName() != Intrinsic::getName(Intrinsic::objectsize, Tys)) {
rename(F);
NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::objectsize,
@@ -3461,7 +3461,7 @@
? Builder.getFalse()
: CI->getArgOperand(2);
Value *Dynamic =
- CI->getNumArgOperands() < 3 ? Builder.getFalse() : CI->getArgOperand(3);
+ CI->getNumArgOperands() < 4 ? Builder.getFalse() : CI->getArgOperand(3);
NewCall = Builder.CreateCall(
NewFn, {CI->getArgOperand(0), CI->getArgOperand(1), NullIsUnknownSize, Dynamic});
break;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58071.186317.patch
Type: text/x-patch
Size: 1720 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190211/cb67f9c2/attachment.bin>
More information about the llvm-commits
mailing list