[llvm] Fix for failing test from cf8ff75bade763b054476321dcb82dcb2e7744c7
authorLeonard Chan <leonardchan@google.com>
Tue, 1 Dec 2020 01:18:50 +0000 (17:18 -0800)
committerLeonard Chan <leonardchan@google.com>
Tue, 1 Dec 2020 01:22:28 +0000 (17:22 -0800)
Handle null values when handling operand changes for DSOLocalEquivalent.

llvm/lib/IR/Constants.cpp

index 7ebe461..eba8c8e 100644 (file)
@@ -1862,6 +1862,11 @@ Value *DSOLocalEquivalent::handleOperandChangeImpl(Value *From, Value *To) {
       return NewEquiv;
   }
 
+  // If the argument is replaced with a null value, just replace this constant
+  // with a null value.
+  if (cast<Constant>(To)->isNullValue())
+    return To;
+
   // The replacement could be a bitcast or an alias to another function. We can
   // replace it with a bitcast to the dso_local_equivalent of that function.
   auto *Func = cast<Function>(To->stripPointerCastsAndAliases());