Skip to content

Commit 75cbfdc

Browse files
committedJan 5, 2016
[RS4GC] Simplify handling of Constants in findBaseDefiningValue(). NFC.
Summary: Previously there were three conditionals, checking for global variables, undef values and everything constant except these two, all three returning the same value. This commit replaces them by one conditional. Reviewers: reames Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D15818 llvm-svn: 256812
1 parent 83eefa6 commit 75cbfdc

File tree

1 file changed

+7
-22
lines changed

1 file changed

+7
-22
lines changed
 

‎llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -428,30 +428,15 @@ static BaseDefiningValueResult findBaseDefiningValue(Value *I) {
428428
// We should have never reached here if this argument isn't an gc value
429429
return BaseDefiningValueResult(I, true);
430430

431-
if (isa<GlobalVariable>(I))
432-
// base case
431+
if (isa<Constant>(I))
432+
// We assume that objects with a constant base (e.g. a global) can't move
433+
// and don't need to be reported to the collector because they are always
434+
// live. All constants have constant bases. Besides global references, all
435+
// kinds of constants (e.g. undef, constant expressions, null pointers) can
436+
// be introduced by the inliner or the optimizer, especially on dynamically
437+
// dead paths. See e.g. test4 in constants.ll.
433438
return BaseDefiningValueResult(I, true);
434439

435-
// inlining could possibly introduce phi node that contains
436-
// undef if callee has multiple returns
437-
if (isa<UndefValue>(I))
438-
// utterly meaningless, but useful for dealing with
439-
// partially optimized code.
440-
return BaseDefiningValueResult(I, true);
441-
442-
// Due to inheritance, this must be _after_ the global variable and undef
443-
// checks
444-
if (isa<Constant>(I)) {
445-
assert(!isa<GlobalVariable>(I) && !isa<UndefValue>(I) &&
446-
"order of checks wrong!");
447-
// Note: Even for frontends which don't have constant references, we can
448-
// see constants appearing after optimizations. A simple example is
449-
// specialization of an address computation on null feeding into a merge
450-
// point where the actual use of the now-constant input is protected by
451-
// another null check. (e.g. test4 in constants.ll)
452-
return BaseDefiningValueResult(I, true);
453-
}
454-
455440
if (CastInst *CI = dyn_cast<CastInst>(I)) {
456441
Value *Def = CI->stripPointerCasts();
457442
// If stripping pointer casts changes the address space there is an

0 commit comments

Comments
 (0)
Please sign in to comment.