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(InAllocaArg->stripInBoundsOffsets())) + Value *InAllocaArg = + CS.getArgument(FTy->getNumParams() - 1)->stripInBoundsOffsets(); + if (auto AI = dyn_cast(InAllocaArg)) Assert2(AI->isUsedWithInAlloca(), "inalloca argument for call has mismatched alloca", AI, I); + if (auto A = dyn_cast(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 +}