aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp32
1 files changed, 28 insertions, 4 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 93b3dbf..879ebfb 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -3923,6 +3923,25 @@ void BitcodeReader::propagateAttributeTypes(CallBase *CB,
}
}
+ if (CB->isInlineAsm()) {
+ const InlineAsm *IA = cast<InlineAsm>(CB->getCalledOperand());
+ unsigned ArgNo = 0;
+ for (const InlineAsm::ConstraintInfo &CI : IA->ParseConstraints()) {
+ bool HasArg = CI.Type == InlineAsm::isInput ||
+ (CI.Type == InlineAsm::isOutput && CI.isIndirect);
+ if (!HasArg)
+ continue;
+
+ if (CI.isIndirect && !CB->getAttributes().getParamElementType(ArgNo)) {
+ Type *ElemTy = ArgsTys[ArgNo]->getPointerElementType();
+ CB->addParamAttr(
+ ArgNo, Attribute::get(Context, Attribute::ElementType, ElemTy));
+ }
+
+ ArgNo++;
+ }
+ }
+
switch (CB->getIntrinsicID()) {
case Intrinsic::preserve_array_access_index:
case Intrinsic::preserve_struct_access_index:
@@ -4826,15 +4845,18 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
return error("Insufficient operands to call");
SmallVector<Value*, 16> Args;
+ SmallVector<Type *, 16> ArgsTys;
// Read the fixed params.
for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i, ++OpNum) {
+ Value *Arg;
if (FTy->getParamType(i)->isLabelTy())
- Args.push_back(getBasicBlock(Record[OpNum]));
+ Arg = getBasicBlock(Record[OpNum]);
else
- Args.push_back(getValue(Record, OpNum, NextValueNo,
- FTy->getParamType(i)));
- if (!Args.back())
+ Arg = getValue(Record, OpNum, NextValueNo, FTy->getParamType(i));
+ if (!Arg)
return error("Invalid record");
+ Args.push_back(Arg);
+ ArgsTys.push_back(Arg->getType());
}
// Read type/value pairs for varargs params.
@@ -4847,6 +4869,7 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
if (getValueTypePair(Record, OpNum, NextValueNo, Op))
return error("Invalid record");
Args.push_back(Op);
+ ArgsTys.push_back(Op->getType());
}
}
@@ -4857,6 +4880,7 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
cast<CallBrInst>(I)->setCallingConv(
static_cast<CallingConv::ID>((0x7ff & CCInfo) >> bitc::CALL_CCONV));
cast<CallBrInst>(I)->setAttributes(PAL);
+ propagateAttributeTypes(cast<CallBase>(I), ArgsTys);
break;
}
case bitc::FUNC_CODE_INST_UNREACHABLE: // UNREACHABLE