[PATCH] D16025: [RS4GC] Replace some asserts by similar code using report_fatal_error().
Manuel Jacob via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 8 19:29:05 PST 2016
mjacob created this revision.
mjacob added a reviewer: reames.
mjacob added a subscriber: llvm-commits.
I've replaced asserts which check restrictions on the input IR or for
unimplemented cases. The point is to have these checks also in release builds.
http://reviews.llvm.org/D16025
Files:
lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
Index: lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
===================================================================
--- lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
+++ lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
@@ -394,9 +394,10 @@
// A PHI or Select is a base defining value. The outer findBasePointer
// algorithm is responsible for constructing a base value for this BDV.
- assert((isa<SelectInst>(I) || isa<PHINode>(I)) &&
- "unknown vector instruction - no base found for vector element");
- return BaseDefiningValueResult(I, false);
+ if (isa<SelectInst>(I) || isa<PHINode>(I))
+ return BaseDefiningValueResult(I, false);
+
+ report_fatal_error("unknown vector instruction - no base found for vector element");
}
/// Helper function for findBasePointer - Will return a value which either a)
@@ -428,13 +429,14 @@
Value *Def = CI->stripPointerCasts();
// If stripping pointer casts changes the address space there is an
// addrspacecast in between.
- assert(cast<PointerType>(Def->getType())->getAddressSpace() ==
- cast<PointerType>(CI->getType())->getAddressSpace() &&
- "unsupported addrspacecast");
+ if (Def->getType()->getPointerAddressSpace() !=
+ CI->getType()->getPointerAddressSpace())
+ report_fatal_error("unsupported addrspacecast");
// If we find a cast instruction here, it means we've found a cast which is
// not simply a pointer cast (i.e. an inttoptr). We don't know how to
// handle int->ptr conversion.
- assert(!isa<CastInst>(Def) && "shouldn't find another cast here");
+ if (isa<CastInst>(Def))
+ report_fatal_error("shouldn't find another cast here");
return findBaseDefiningValue(Def);
}
@@ -476,7 +478,8 @@
// I have absolutely no idea how to implement this part yet. It's not
// necessarily hard, I just haven't really looked at it yet.
- assert(!isa<LandingPadInst>(I) && "Landing Pad is unimplemented");
+ if (isa<LandingPadInst>(I))
+ report_fatal_error("Landing Pad is unimplemented");
if (isa<AtomicCmpXchgInst>(I))
// A CAS is effectively a atomic store and load combined under a
@@ -512,9 +515,10 @@
// return a value which dynamically selects from among several base
// derived pointers (each with it's own base potentially). It's the job of
// the caller to resolve these.
- assert((isa<SelectInst>(I) || isa<PHINode>(I)) &&
- "missing instruction case in findBaseDefiningValing");
- return BaseDefiningValueResult(I, false);
+ if (isa<SelectInst>(I) || isa<PHINode>(I))
+ return BaseDefiningValueResult(I, false);
+
+ report_fatal_error("missing instruction case in findBaseDefiningValue");
}
/// Returns the base defining value for this value.
@@ -2293,8 +2297,8 @@
: iterator_range<const Use *>(Statepoint(CS).vm_state_args());
for (Value *Arg : DeoptStateRange) {
- assert(!isUnhandledGCPointerType(Arg->getType()) &&
- "support for FCA unimplemented");
+ if (isUnhandledGCPointerType(Arg->getType()))
+ report_fatal_error("support for FCA unimplemented");
if (isHandledGCPointerType(Arg->getType()))
DeoptValues.push_back(Arg);
}
@@ -2699,8 +2703,8 @@
// USE - Add to the LiveIn set for this instruction
for (Value *V : I->operands()) {
- assert(!isUnhandledGCPointerType(V->getType()) &&
- "support for FCA unimplemented");
+ if (isUnhandledGCPointerType(V->getType()))
+ report_fatal_error("support for FCA unimplemented");
if (isHandledGCPointerType(V->getType()) && !isa<Constant>(V)) {
// The choice to exclude all things constant here is slightly subtle.
// There are two independent reasons:
@@ -2725,8 +2729,8 @@
for (BasicBlock::iterator I = Succ->begin(); I != E; I++) {
PHINode *Phi = cast<PHINode>(&*I);
Value *V = Phi->getIncomingValueForBlock(BB);
- assert(!isUnhandledGCPointerType(V->getType()) &&
- "support for FCA unimplemented");
+ if (isUnhandledGCPointerType(V->getType()))
+ report_fatal_error("support for FCA unimplemented");
if (isHandledGCPointerType(V->getType()) && !isa<Constant>(V)) {
LiveTmp.insert(V);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16025.44399.patch
Type: text/x-patch
Size: 4288 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160109/28935586/attachment.bin>
More information about the llvm-commits
mailing list