[llvm] r254866 - [WebAssembly] Don't perform the returned-argument optimization on constants.
Dan Gohman via llvm-commits
llvm-commits at lists.llvm.org
Sat Dec 5 14:12:39 PST 2015
Author: djg
Date: Sat Dec 5 16:12:39 2015
New Revision: 254866
URL: http://llvm.org/viewvc/llvm-project?rev=254866&view=rev
Log:
[WebAssembly] Don't perform the returned-argument optimization on constants.
Modified:
llvm/trunk/lib/Target/WebAssembly/WebAssemblyOptimizeReturned.cpp
llvm/trunk/test/CodeGen/WebAssembly/returned.ll
Modified: llvm/trunk/lib/Target/WebAssembly/WebAssemblyOptimizeReturned.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/WebAssembly/WebAssemblyOptimizeReturned.cpp?rev=254866&r1=254865&r2=254866&view=diff
==============================================================================
--- llvm/trunk/lib/Target/WebAssembly/WebAssemblyOptimizeReturned.cpp (original)
+++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyOptimizeReturned.cpp Sat Dec 5 16:12:39 2015
@@ -57,6 +57,9 @@ void OptimizeReturned::visitCallSite(Cal
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++;
Modified: llvm/trunk/test/CodeGen/WebAssembly/returned.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/WebAssembly/returned.ll?rev=254866&r1=254865&r2=254866&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/WebAssembly/returned.ll (original)
+++ llvm/trunk/test/CodeGen/WebAssembly/returned.ll Sat Dec 5 16:12:39 2015
@@ -33,3 +33,17 @@ entry:
%call = tail call i8* @memcpy(i8* %p, i8* %s, i32 %n)
ret i8* %p
}
+
+; Test that the optimization isn't performed on constant arguments.
+
+; CHECK-LABEL: test_constant_arg:
+; CHECK-NEXT: i32.const $push0=, global{{$}}
+; CHECK-NEXT: call $discard=, returns_arg, $pop0{{$}}
+; CHECK-NEXT: return{{$}}
+ at global = external global i32
+ at addr = global i32* @global
+define void @test_constant_arg() {
+ %call = call i32* @returns_arg(i32* @global)
+ ret void
+}
+declare i32* @returns_arg(i32* returned)
More information about the llvm-commits
mailing list