summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorJonathan Roelofs <jonathan@codesourcery.com>2017-01-18 15:31:11 +0000
committerJonathan Roelofs <jonathan@codesourcery.com>2017-01-18 15:31:11 +0000
commit8277c41a899bc2e1290ce22595fbd79191f32066 (patch)
tree11229fdf6d0ca6edac562eab8b0a8dbab9f72270 /clang/lib
parent68019578a3f9e708b70300ef1746d6586188fcc3 (diff)
downloadbcm5719-llvm-8277c41a899bc2e1290ce22595fbd79191f32066.tar.gz
bcm5719-llvm-8277c41a899bc2e1290ce22595fbd79191f32066.zip
Warn when calling a non interrupt function from an interrupt on ARM
The idea for this originated from a really tricky bug: ISRs on ARM don't automatically save off the VFP regs, so if say, memcpy gets interrupted and the ISR itself calls memcpy, the regs are left clobbered when the ISR is done. https://reviews.llvm.org/D28820 llvm-svn: 292375
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 7b404f40a76..7d72b7ede82 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -5395,6 +5395,15 @@ Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
return ExprError();
}
+ // Interrupt handlers don't save off the VFP regs automatically on ARM,
+ // so there's some risk when calling out to non-interrupt handler functions
+ // that the callee might not preserve them. This is easy to diagnose here,
+ // but can be very challenging to debug.
+ if (auto *Caller = getCurFunctionDecl())
+ if (Caller->hasAttr<ARMInterruptAttr>())
+ if (!FDecl->hasAttr<ARMInterruptAttr>())
+ Diag(Fn->getExprLoc(), diag::warn_arm_interrupt_calling_convention);
+
// Promote the function operand.
// We special-case function promotion here because we only allow promoting
// builtin functions to function pointers in the callee of a call.
OpenPOWER on IntegriCloud