Skip to content

Commit 0ca2359

Browse files
[rtsan] Handle attributed IR function declarations
Addresses #169377. Previously, the RealtimeSanitizer pass only handled attributed function definitions in IR, and attributed function declarations caused it to crash. To fix the issue, we must check whether the IR function is empty before attempting to do any manipulation of its instructions.
1 parent 8079d03 commit 0ca2359

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

llvm/lib/Transforms/Instrumentation/RealtimeSanitizer.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ PreservedAnalyses RealtimeSanitizerPass::run(Module &M,
9090
[&](Function *Ctor, FunctionCallee) { appendToGlobalCtors(M, Ctor, 0); });
9191

9292
for (Function &F : M) {
93+
if (F.empty())
94+
continue;
95+
9396
if (F.hasFnAttribute(Attribute::SanitizeRealtime))
9497
runSanitizeRealtime(F);
9598

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
; RUN: opt < %s -passes='rtsan' -S | FileCheck %s
2+
3+
declare void @declared_realtime_function() sanitize_realtime #0
4+
5+
declare void @declared_blocking_function() sanitize_realtime_blocking #0
6+
7+
; RealtimeSanitizer pass should ignore attributed functions that are just declarations
8+
; CHECK: declared_realtime_function
9+
; CHECK-EMPTY:
10+
; CHECK: declared_blocking_function
11+
; CHECK-EMPTY:

0 commit comments

Comments
 (0)