diff options
| author | Peter Collingbourne <peter@pcc.me.uk> | 2016-11-10 22:34:55 +0000 |
|---|---|---|
| committer | Peter Collingbourne <peter@pcc.me.uk> | 2016-11-10 22:34:55 +0000 |
| commit | d93620bf4d5e165999ad1c3cec2a2fdb02f56218 (patch) | |
| tree | aef2609ce725411649a10eb99701de1eb1bf7843 /llvm/lib/IR/AsmWriter.cpp | |
| parent | a0dee61df34fc819aeb26607bd099ef2ae61c903 (diff) | |
| download | bcm5719-llvm-d93620bf4d5e165999ad1c3cec2a2fdb02f56218.tar.gz bcm5719-llvm-d93620bf4d5e165999ad1c3cec2a2fdb02f56218.zip | |
IR: Introduce inrange attribute on getelementptr indices.
If the inrange keyword is present before any index, loading from or
storing to any pointer derived from the getelementptr has undefined
behavior if the load or store would access memory outside of the bounds of
the element selected by the index marked as inrange.
This can be used, e.g. for alias analysis or to split globals at element
boundaries where beneficial.
As previously proposed on llvm-dev:
http://lists.llvm.org/pipermail/llvm-dev/2016-July/102472.html
Differential Revision: https://reviews.llvm.org/D22793
llvm-svn: 286514
Diffstat (limited to 'llvm/lib/IR/AsmWriter.cpp')
| -rw-r--r-- | llvm/lib/IR/AsmWriter.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp index f93739d14c7..7334c988f29 100644 --- a/llvm/lib/IR/AsmWriter.cpp +++ b/llvm/lib/IR/AsmWriter.cpp @@ -1320,12 +1320,18 @@ static void WriteConstantInternal(raw_ostream &Out, const Constant *CV, static_cast<CmpInst::Predicate>(CE->getPredicate())); Out << " ("; + Optional<unsigned> InRangeOp; if (const GEPOperator *GEP = dyn_cast<GEPOperator>(CE)) { TypePrinter.print(GEP->getSourceElementType(), Out); Out << ", "; + InRangeOp = GEP->getInRangeIndex(); + if (InRangeOp) + ++*InRangeOp; } for (User::const_op_iterator OI=CE->op_begin(); OI != CE->op_end(); ++OI) { + if (InRangeOp && (OI - CE->op_begin()) == *InRangeOp) + Out << "inrange "; TypePrinter.print((*OI)->getType(), Out); Out << ' '; WriteAsOperandInternal(Out, *OI, &TypePrinter, Machine, Context); |

