File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed
test/Transforms/FunctionSpecialization Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -248,9 +248,12 @@ class FunctionSpecializer {
248
248
Metrics.analyzeBasicBlock (&BB, (GetTTI)(*F), EphValues);
249
249
250
250
// If the code metrics reveal that we shouldn't duplicate the function, we
251
- // shouldn't specialize it. Set the specialization cost to the maximum.
252
- if (Metrics.notDuplicatable )
253
- return std::numeric_limits<unsigned >::max ();
251
+ // shouldn't specialize it. Set the specialization cost to Invalid.
252
+ if (Metrics.notDuplicatable ) {
253
+ InstructionCost C{};
254
+ C.setInvalid ();
255
+ return C;
256
+ }
254
257
255
258
// Otherwise, set the specialization cost to be the cost of all the
256
259
// instructions in the function and penalty for specializing more functions.
@@ -417,6 +420,11 @@ class FunctionSpecializer {
417
420
// function where the argument takes on the given constant value. If so,
418
421
// add the constant to Constants.
419
422
auto FnSpecCost = getSpecializationCost (F);
423
+ if (!FnSpecCost.isValid ()) {
424
+ LLVM_DEBUG (dbgs () << " FnSpecialization: Invalid specialisation cost.\n " );
425
+ return false ;
426
+ }
427
+
420
428
LLVM_DEBUG (dbgs () << " FnSpecialization: func specialisation cost: " ;
421
429
FnSpecCost.print (dbgs ()); dbgs () << " \n " );
422
430
Original file line number Diff line number Diff line change 1
1
; RUN: opt -function-specialization -force-function-specialization -S < %s | FileCheck %s
2
2
3
- ; FIXME: Function foo gets specialised even though it contains an instrinsic
3
+ ; Check that function foo does not gets specialised as it contains an instrinsic
4
4
; that is marked as NoDuplicate.
5
5
; Please note that the use of the hardwareloop intrinsic is arbitrary; it's
6
6
; just an easy to use intrinsic that has NoDuplicate.
7
7
8
- ; CHECK: @foo.1(
9
- ; CHECK: @foo.2(
8
+ ; CHECK-NOT : @foo.1(
9
+ ; CHECK-NOT : @foo.2(
10
10
11
11
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
12
12
You can’t perform that action at this time.
0 commit comments