1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

[Mem2Reg] Respect optnone

Mem2Reg shouldn't be optimizing a function that is marked
optnone. There is a test checking this that fails when mem2reg is
explicitly added to the standard pass pipeline.

llvm-svn: 255336
This commit is contained in:
James Molloy 2015-12-11 13:36:59 +00:00
parent d8003c7bf6
commit f5a3f4d77c
2 changed files with 24 additions and 0 deletions

View File

@ -63,6 +63,9 @@ bool PromotePass::runOnFunction(Function &F) {
BasicBlock &BB = F.getEntryBlock(); // Get the entry node for the function
if (F.hasFnAttribute(Attribute::OptimizeNone))
return false;
bool Changed = false;
DominatorTree &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();

View File

@ -0,0 +1,21 @@
; RUN: opt < %s -mem2reg -S | FileCheck %s
; This function is optnone, so the allocas should not be eliminated.
; CHECK-LABEL: @testfunc
; CHECK: alloca
; CHECK: alloca
define double @testfunc(i32 %i, double %j) optnone noinline {
%I = alloca i32 ; <i32*> [#uses=4]
%J = alloca double ; <double*> [#uses=2]
store i32 %i, i32* %I
store double %j, double* %J
%t1 = load i32, i32* %I ; <i32> [#uses=1]
%t2 = add i32 %t1, 1 ; <i32> [#uses=1]
store i32 %t2, i32* %I
%t3 = load i32, i32* %I ; <i32> [#uses=1]
%t4 = sitofp i32 %t3 to double ; <double> [#uses=1]
%t5 = load double, double* %J ; <double> [#uses=1]
%t6 = fmul double %t4, %t5 ; <double> [#uses=1]
ret double %t6
}