Index: llvm/test/Transforms/FunctionSpecialization/literal-const.ll =================================================================== --- llvm/test/Transforms/FunctionSpecialization/literal-const.ll +++ llvm/test/Transforms/FunctionSpecialization/literal-const.ll @@ -4,70 +4,89 @@ ; RUN: -function-specialization-for-literal-constant \ ; RUN: -force-function-specialization < %s | FileCheck %s -check-prefix CHECK-LIT -define dso_local i32 @f0(i32 noundef %x) { +define i32 @f0(i32 noundef %x) { entry: - %call = tail call fastcc i32 @neg(i32 noundef %x, i1 noundef zeroext false) + %call = tail call i32 @neg(i32 noundef %x, i1 noundef zeroext false) ret i32 %call } -define internal fastcc i32 @neg(i32 noundef %x, i1 noundef zeroext %b) { +define i32 @f1(i32 noundef %x) { entry: - %sub = sub nsw i32 0, %x - %cond = select i1 %b, i32 %sub, i32 %x - ret i32 %cond + %call = tail call i32 @neg(i32 noundef %x, i1 noundef zeroext true) + ret i32 %call } -define dso_local i32 @f1(i32 noundef %x) { +define i32 @g0(i32 noundef %x) { entry: - %call = tail call fastcc i32 @neg(i32 noundef %x, i1 noundef zeroext true) + %call = tail call i32 @add(i32 noundef %x, i32 noundef 1) ret i32 %call } -define dso_local i32 @g0(i32 noundef %x) { +define i32 @g1(i32 noundef %x) { entry: - %call = tail call fastcc i32 @add(i32 noundef %x, i32 noundef 1) + %call = tail call i32 @add(i32 noundef %x, i32 noundef 2) ret i32 %call } -define internal fastcc i32 @add(i32 noundef %x, i32 noundef %y) { +define float @h0(float noundef %x) { entry: - %add = add nsw i32 %y, %x - ret i32 %add + %call = tail call float @addf(float noundef %x, float noundef 1.000000e+00) + ret float %call } -define dso_local i32 @g1(i32 noundef %x) { +define float @h1(float noundef %x) { entry: - %call = tail call fastcc i32 @add(i32 noundef %x, i32 noundef 2) - ret i32 %call + %call = tail call float @addf(float noundef %x, float noundef 2.000000e+00) + ret float %call } -define dso_local float @h0(float noundef %x) { +define internal i32 @neg(i32 noundef %x, i1 noundef zeroext %b) { entry: - %call = tail call fastcc float @addf(float noundef %x, float noundef 1.000000e+00) - ret float %call + %sub = sub nsw i32 0, %x + %cond = select i1 %b, i32 %sub, i32 %x + ret i32 %cond } -define internal fastcc float @addf(float noundef %x, float noundef %y) { +define internal i32 @add(i32 noundef %x, i32 noundef %y) { entry: - %add = fadd float %x, %y - ret float %add + %add = add nsw i32 %y, %x + ret i32 %add } -define dso_local float @h1(float noundef %x) { +define internal float @addf(float noundef %x, float noundef %y) { entry: - %call = tail call fastcc float @addf(float noundef %x, float noundef 2.000000e+00) - ret float %call + %add = fadd float %x, %y + ret float %add } + ; Check no functions were specialised. ; CHECK-NOLIT-NOT: @neg. ; CHECK-NOLIT-NOT: @add. ; CHECK-NOLIT-NOT: @addf. +; CHECK-LIT-LABEL: @f0 +; CHECK-LIT: call i32 @neg.[[#A:]] + +; CHECK-LIT-LABEL: @f1 +; CHECK-LIT: call i32 @neg.[[#B:]] + +; CHECK-LIT-LABEL: @g0 +; CHECK-LIT: call i32 @add.[[#C:]] + +; CHECK-LIT-LABEL: @g1 +; CHECK-LIT: call i32 @add.[[#D:]] + +; CHECK-LIT-LABEL: @h0 +; CHECK-LIT: call float @addf.[[#E:]] + +; CHECK-LIT-LABEL: @h1 +; CHECK-LIT: call float @addf.[[#F:]] + ; Check all of `neg`, `add`, and `addf` were specialised. -; CHECK-LIT-DAG: @neg.1 -; CHECK-LIT-DAG: @neg.2 -; CHECK-LIT-DAG: @add.3 -; CHECK-LIT-DAG: @add.4 -; CHECK-LIT-DAG: @addf.5 -; CHECK-LIT-DAG: @addf.6 +; CHECK-LIT-DAG: @neg.[[#A]] +; CHECK-LIT-DAG: @neg.[[#B]] +; CHECK-LIT-DAG: @add.[[#C]] +; CHECK-LIT-DAG: @add.[[#D]] +; CHECK-LIT-DAG: @addf.[[#E]] +; CHECK-LIT-DAG: @addf.[[#F]]