[PATCH] D14304: [IR] add bounds checking to paramHasAttr
Sanjoy Das via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 3 18:44:02 PST 2015
sanjoy updated this revision to Diff 39146.
sanjoy added a comment.
- make the bounds checking stricter, and fix an out of bounds access
http://reviews.llvm.org/D14304
Files:
lib/IR/Instructions.cpp
lib/Target/X86/X86FastISel.cpp
Index: lib/Target/X86/X86FastISel.cpp
===================================================================
--- lib/Target/X86/X86FastISel.cpp
+++ lib/Target/X86/X86FastISel.cpp
@@ -2817,9 +2817,9 @@
if (CC == CallingConv::Fast || CC == CallingConv::GHC ||
CC == CallingConv::HiPE)
return 0;
- if (CS && !CS->paramHasAttr(1, Attribute::StructRet))
+ if (CS && !(CS->arg_size() != 0 && CS->paramHasAttr(1, Attribute::StructRet)))
return 0;
- if (CS && CS->paramHasAttr(1, Attribute::InReg))
+ if (CS && CS->arg_size() != 0 && CS->paramHasAttr(1, Attribute::InReg))
return 0;
return 4;
}
Index: lib/IR/Instructions.cpp
===================================================================
--- lib/IR/Instructions.cpp
+++ lib/IR/Instructions.cpp
@@ -331,6 +331,8 @@
}
bool CallInst::paramHasAttr(unsigned i, Attribute::AttrKind A) const {
+ assert(i < (getNumArgOperands() + 1) && "Param index out of bounds!");
+
if (AttributeList.hasAttribute(i, A))
return true;
if (const Function *F = getCalledFunction())
@@ -575,6 +577,8 @@
}
bool InvokeInst::paramHasAttr(unsigned i, Attribute::AttrKind A) const {
+ assert(i < (getNumArgOperands() + 1) && "Param index out of bounds!");
+
if (AttributeList.hasAttribute(i, A))
return true;
if (const Function *F = getCalledFunction())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14304.39146.patch
Type: text/x-patch
Size: 1334 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151104/32522185/attachment.bin>
More information about the llvm-commits
mailing list