================
@@ -607,6 +607,9 @@ class RISCVTargetCodeGenInfo : public TargetCodeGenInfo {
     auto *Fn = cast<llvm::Function>(GV);
 
     Fn->addFnAttr("interrupt", Kind);
+
+    if (CGM.getCodeGenOpts().CFProtectionReturn)
----------------
mylai-mtk wrote:

After tracing the code, I believe the above lines are for attaching interrupt 
attributes to LLVM functions based on the C `__attribute__((interrupt))` parsed 
by Clang. They're placed here since the interrupt attribute implementation is 
target-specific (ref. 
https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/Function-Attributes.html#index-interrupt-handler-functions-2886).
 

The above lines
```c++
    const auto *Attr = FD->getAttr<RISCVInterruptAttr>();
    if (!Attr)
      return;
```
mean that for C function declarations without the interrupt attribute, which is 
the common case for normal functions, the `setTargetAttributes` function would 
exit early, and this renders your attachment of the `hw-shadow-stack` attribute 
undone.

https://github.com/llvm/llvm-project/pull/112477
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to