aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorChuanqi Xu <yedeng.yd@linux.alibaba.com>2024-08-01 14:45:21 +0800
committerGitHub <noreply@github.com>2024-08-01 14:45:21 +0800
commite167f753bd4679329ebcf0232f72be9c63d9b671 (patch)
tree61ff2b51caafdf1b9a8ff6d8e0862f10055d666c /clang/lib/CodeGen/CodeGenModule.cpp
parentab33c3dd65ab9b2101e42eaa05ed781a21753f65 (diff)
downloadllvm-e167f753bd4679329ebcf0232f72be9c63d9b671.zip
llvm-e167f753bd4679329ebcf0232f72be9c63d9b671.tar.gz
llvm-e167f753bd4679329ebcf0232f72be9c63d9b671.tar.bz2
[C++20] [Modules] Always emit the inline builtins (#101278)
See the attached test for the motivation example. If we're too greedy to not emit the definition for inline builtins, we may meet a middle end crash. And it should be good to emit inline builtins always.
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 760185d..31f6632 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -4022,6 +4022,11 @@ bool CodeGenModule::shouldEmitFunction(GlobalDecl GD) {
return true;
const auto *F = cast<FunctionDecl>(GD.getDecl());
+ // Inline builtins declaration must be emitted. They often are fortified
+ // functions.
+ if (F->isInlineBuiltinDeclaration())
+ return true;
+
if (CodeGenOpts.OptimizationLevel == 0 && !F->hasAttr<AlwaysInlineAttr>())
return false;
@@ -4067,11 +4072,6 @@ bool CodeGenModule::shouldEmitFunction(GlobalDecl GD) {
}
}
- // Inline builtins declaration must be emitted. They often are fortified
- // functions.
- if (F->isInlineBuiltinDeclaration())
- return true;
-
// PR9614. Avoid cases where the source code is lying to us. An available
// externally function should have an equivalent function somewhere else,
// but a function that calls itself through asm label/`__builtin_` trickery is