[PATCH] IR: Check inalloca call argument originating from parameter

David Majnemer david.majnemer at gmail.com
Fri May 2 09:23:00 PDT 2014


Hi rnk,

Catch more mismatches involving inalloca.

http://reviews.llvm.org/D3593

Files:
  lib/IR/Verifier.cpp
  test/Verifier/inalloca4.ll

Index: lib/IR/Verifier.cpp
===================================================================
--- lib/IR/Verifier.cpp
+++ lib/IR/Verifier.cpp
@@ -1498,10 +1498,15 @@
   // We have a bug if we can find that there is an underlying alloca without
   // inalloca.
   if (CS.hasInAllocaArgument()) {
-    Value *InAllocaArg = CS.getArgument(FTy->getNumParams() - 1);
-    if (auto AI = dyn_cast<AllocaInst>(InAllocaArg->stripInBoundsOffsets()))
+    Value *InAllocaArg =
+        CS.getArgument(FTy->getNumParams() - 1)->stripInBoundsOffsets();
+    if (auto AI = dyn_cast<AllocaInst>(InAllocaArg))
       Assert2(AI->isUsedWithInAlloca(),
               "inalloca argument for call has mismatched alloca", AI, I);
+    if (auto A = dyn_cast<Argument>(InAllocaArg))
+      Assert2(A->hasInAllocaAttr(), "inalloca argument for call originated "
+                                    "from argument without inalloca",
+              A, I);
   }
 
   if (FTy->isVarArg()) {
Index: test/Verifier/inalloca4.ll
===================================================================
--- /dev/null
+++ test/Verifier/inalloca4.ll
@@ -0,0 +1,11 @@
+; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s
+
+
+declare void @doit(i64* inalloca %a)
+
+define void @a(i64* %a) {
+entry:
+  call void @doit(i64* inalloca %a)
+; CHECK: inalloca argument for call originated from argument without inalloca
+  ret void
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3593.9036.patch
Type: text/x-patch
Size: 1396 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140502/354d88d1/attachment.bin>


More information about the llvm-commits mailing list