Skip to content

Commit 60a714e

Browse files
committed
avoid infinite loop
1 parent d74c49b commit 60a714e

File tree

1 file changed

+6
-1
lines changed
  • llvm-4.0.0.src/lib/Transforms/Instrumentation

1 file changed

+6
-1
lines changed

llvm-4.0.0.src/lib/Transforms/Instrumentation/LowFat.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,12 @@ static Bounds getPtrBounds(const TargetLibraryInfo *TLI, const DataLayout *DL,
540540
Bounds bounds = Bounds::nonFat();
541541
if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(Ptr))
542542
{
543-
bounds = getPtrBounds(TLI, DL, GEP->getPointerOperand(), boundsInfo);
543+
// JumpThreading or other optimizations may produce incorrect IR that
544+
// has not yet been removed; e.g.
545+
// %231 = getelementptr inbounds i8, i8* %231, i64 1
546+
bounds = GEP != GEP->getPointerOperand() ?
547+
getPtrBounds(TLI, DL, GEP->getPointerOperand(), boundsInfo) :
548+
Bounds::nonFat();
544549
if (!bounds.isUnknown() && !bounds.isNonFat())
545550
{
546551
APInt offset(64, 0);

0 commit comments

Comments
 (0)