================
@@ -1193,21 +1199,42 @@ bool IRForTarget::RemoveCXAAtExit(BasicBlock
&basic_block) {
llvm::Function *func = call->getCalledFunction();
- if (func && func->getName() == "__cxa_atexit")
+ // Itanium ABI uses __cxa_atexit; MS ABI uses plain atexit.
+ if (func &&
+ (func->getName() == "__cxa_atexit" || func->getName() == "atexit"))
remove = true;
llvm::Value *val = call->getCalledOperand();
- if (val && val->getName() == "__cxa_atexit")
+ if (val && (val->getName() == "__cxa_atexit" || val->getName() ==
"atexit"))
remove = true;
- if (remove)
+ if (remove) {
+ // MS ABI callback thunks (mangled "??__F...") reference the static
+ // they destroy; track them to clear once the call is gone.
+ if (call->arg_size() > 0)
+ if (auto *cb = dyn_cast<llvm::Function>(
+ call->getArgOperand(0)->stripPointerCasts()))
+ if (cb->hasInternalLinkage() && cb->getName().starts_with("??__"))
----------------
Nerixyz wrote:
This only checks for `??__`, but the atexit destructor names are mangled as
`??__F...` as you have written above. Can this check for `??__F`?
https://github.com/llvm/llvm-project/pull/212521
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits