[WebAssembly] Don't perform the returned-argument optimization on constants.
[oota-llvm.git] / lib / Target / WebAssembly / WebAssemblyOptimizeReturned.cpp
index dea419c5975c37bb190deedcc7436ed80229c9c0..4dc401a2c7cc776ddd99b1430dcde21abad8fdc1 100644 (file)
@@ -57,6 +57,9 @@ void OptimizeReturned::visitCallSite(CallSite CS) {
     if (CS.paramHasAttr(1 + i, Attribute::Returned)) {
       Instruction *Inst = CS.getInstruction();
       Value *Arg = CS.getArgOperand(i);
+      // Ignore constants, globals, undef, etc.
+      if (isa<Constant>(Arg))
+        continue;
       // Like replaceDominatedUsesWith but using Instruction/Use dominance.
       for (auto UI = Arg->use_begin(), UE = Arg->use_end(); UI != UE;) {
         Use &U = *UI++;