aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.h
diff options
context:
space:
mode:
authorChen Zheng <czhengsz@cn.ibm.com>2024-07-08 09:30:01 +0800
committerGitHub <noreply@github.com>2024-07-08 09:30:01 +0800
commitafd0e6d06ba05cf3cd8b0bb91b6506242de78a4d (patch)
tree57a519d8b87a25239c3fa135fcdf0d7da2c823f4 /clang/lib/CodeGen/CodeGenModule.h
parentcc5ba739f27ab2f28d4a0f2e295d1e426aa836a7 (diff)
downloadllvm-afd0e6d06ba05cf3cd8b0bb91b6506242de78a4d.zip
llvm-afd0e6d06ba05cf3cd8b0bb91b6506242de78a4d.tar.gz
llvm-afd0e6d06ba05cf3cd8b0bb91b6506242de78a4d.tar.bz2
[PowerPC] Diagnose musttail instead of crash inside backend (#93267)
musttail is not often possible to be generated on PPC targets as when calling to a function defined in another module, PPC needs to restore the TOC pointer. To restore the TOC pointer, compiler needs to emit a nop after the call to let linker generate codes to restore TOC pointer. Tail call cannot generate expected call sequence for this case. To avoid the crash inside the compiler backend, a diagnosis is added in the frontend. Fixes #63214
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.h')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h
index 0444f9f..8b65348 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -485,6 +485,14 @@ private:
typedef std::pair<OrderGlobalInitsOrStermFinalizers, llvm::Function *>
GlobalInitData;
+ // When a tail call is performed on an "undefined" symbol, on PPC without pc
+ // relative feature, the tail call is not allowed. In "EmitCall" for such
+ // tail calls, the "undefined" symbols may be forward declarations, their
+ // definitions are provided in the module after the callsites. For such tail
+ // calls, diagnose message should not be emitted.
+ llvm::SmallSetVector<std::pair<const FunctionDecl *, SourceLocation>, 4>
+ MustTailCallUndefinedGlobals;
+
struct GlobalInitPriorityCmp {
bool operator()(const GlobalInitData &LHS,
const GlobalInitData &RHS) const {
@@ -1647,6 +1655,11 @@ public:
return getTriple().isSPIRVLogical();
}
+ void addUndefinedGlobalForTailCall(
+ std::pair<const FunctionDecl *, SourceLocation> Global) {
+ MustTailCallUndefinedGlobals.insert(Global);
+ }
+
private:
bool shouldDropDLLAttribute(const Decl *D, const llvm::GlobalValue *GV) const;