[llvm] [llvm][StackProtector] Add noreturn to __stack_chk_fail aliassee (PR #143976)

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 12 15:04:58 PDT 2025


================
@@ -725,7 +725,9 @@ BasicBlock *CreateFailBB(Function *F, const Triple &Trip) {
     StackChkFail =
         M->getOrInsertFunction("__stack_chk_fail", Type::getVoidTy(Context));
   }
-  cast<Function>(StackChkFail.getCallee())->addFnAttr(Attribute::NoReturn);
+  cast<Function>(
+      cast<GlobalValue>(StackChkFail.getCallee())->getAliaseeObject())
+      ->addFnAttr(Attribute::NoReturn);
----------------
efriedma-quic wrote:

This can also fail, if you try hard enough.

If the global already exists for some reason (`M->getNamedValue("__stack_chk_fail") != nullptr`), we probably shouldn't try to mess with it.  Maybe we can stick a noreturn attribute on the call instead.

https://github.com/llvm/llvm-project/pull/143976


More information about the llvm-commits mailing list