[PATCH] D14304: [IR] add bounds checking to paramHasAttr
Sanjoy Das via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 3 20:58:31 PST 2015
sanjoy updated this revision to Diff 39160.
sanjoy added a comment.
- address review: clean up the edit to X86FastISel.cpp
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,10 +2817,14 @@
if (CC == CallingConv::Fast || CC == CallingConv::GHC ||
CC == CallingConv::HiPE)
return 0;
- if (CS && !CS->paramHasAttr(1, Attribute::StructRet))
- return 0;
- if (CS && CS->paramHasAttr(1, Attribute::InReg))
- return 0;
+
+ if (CS) {
+ if (CS->arg_size() == 0) return 0;
+ if (!CS->paramHasAttr(1, Attribute::StructRet) ||
+ 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.39160.patch
Type: text/x-patch
Size: 1363 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151104/6c203d72/attachment.bin>
More information about the llvm-commits
mailing list