Skip to content

Commit 4dad6c5

Browse files
authored
Merge pull request swiftlang#30255 from ravikandhadai/skip-tsan-instrumentation-in-consteval
2 parents 79bac4e + fd77ae9 commit 4dad6c5

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/SILOptimizer/Utils/ConstExpr.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "swift/SIL/ApplySite.h"
2222
#include "swift/SIL/DynamicCasts.h"
2323
#include "swift/SIL/FormalLinkage.h"
24+
#include "swift/SIL/InstructionUtils.h"
2425
#include "swift/SIL/SILBuilder.h"
2526
#include "swift/SIL/SILConstants.h"
2627
#include "swift/SILOptimizer/Utils/Devirtualize.h"
@@ -1718,7 +1719,9 @@ ConstExprFunctionState::evaluateFlowSensitive(SILInstruction *inst) {
17181719
isa<DestroyAddrInst>(inst) || isa<RetainValueInst>(inst) ||
17191720
isa<ReleaseValueInst>(inst) || isa<StrongRetainInst>(inst) ||
17201721
isa<StrongReleaseInst>(inst) || isa<DestroyValueInst>(inst) ||
1721-
isa<EndBorrowInst>(inst))
1722+
isa<EndBorrowInst>(inst) ||
1723+
// Skip sanitizer instrumentation
1724+
isSanitizerInstrumentation(inst))
17221725
return None;
17231726

17241727
// If this is a special flow-sensitive instruction like a stack allocation,

test/SILOptimizer/constant_evaluator_test.sil

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,3 +1531,16 @@ bb0:
15311531
dealloc_stack %2 : $*UInt64
15321532
return %5 : $String
15331533
} // CHECK: Returns string: "18446744073709551615"
1534+
1535+
// CHECK-LABEL: @interpretTsanInstrumentationSkip
1536+
sil [ossa] @interpretTsanInstrumentationSkip : $@convention(thin) () -> Builtin.Int32 {
1537+
bb0:
1538+
%0 = integer_literal $Builtin.Int32, 23
1539+
%1 = alloc_stack $Builtin.Int32
1540+
store %0 to [trivial] %1 : $*Builtin.Int32
1541+
// This builtin should be skipped and should not affect the value of the argument
1542+
%2 = builtin "tsanInoutAccess"(%1 : $*Builtin.Int32) : $()
1543+
%3 = load [trivial] %1 : $*Builtin.Int32
1544+
dealloc_stack %1 : $*Builtin.Int32
1545+
return %3 : $Builtin.Int32
1546+
} // CHECK: Returns int: 23

0 commit comments

Comments
 (0)