summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVedant Kumar <vsk@apple.com>2019-07-11 00:09:16 +0000
committerVedant Kumar <vsk@apple.com>2019-07-11 00:09:16 +0000
commit31c4d2a40d12efb6be340b93a84fb582f7897f5f (patch)
treef1dde379222101f54467ea9e195f36ee08adfe4c
parentc0ae1be06637ef4e0a4b5047e7856523550e4bdc (diff)
downloadbcm5719-llvm-31c4d2a40d12efb6be340b93a84fb582f7897f5f.tar.gz
bcm5719-llvm-31c4d2a40d12efb6be340b93a84fb582f7897f5f.zip
[CGDebugInfo] Fix -femit-debug-entry-values crash on os_log_helpers
An os_log_helper FunctionDecl may not have a body. Ignore these for the purposes of debug entry value emission. Fixes an assertion failure seen in a stage2 build of clang: Assertion failed: (FD->hasBody() && "Functions must have body here"), function analyzeParametersModification llvm-svn: 365716
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp9
-rw-r--r--clang/test/CodeGen/debug-info-param-modification.c13
2 files changed, 17 insertions, 5 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index f49d1ef8787..f6ee7ee26d4 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3587,9 +3587,12 @@ void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, SourceLocation Loc,
// We use the SPDefCache only in the case when the debug entry values option
// is set, in order to speed up parameters modification analysis.
- if (CGM.getCodeGenOpts().EnableDebugEntryValues && HasDecl &&
- isa<FunctionDecl>(D))
- SPDefCache[cast<FunctionDecl>(D)].reset(SP);
+ //
+ // FIXME: Use AbstractCallee here to support ObjCMethodDecl.
+ if (CGM.getCodeGenOpts().EnableDebugEntryValues && HasDecl)
+ if (auto *FD = dyn_cast<FunctionDecl>(D))
+ if (FD->hasBody() && !FD->param_empty())
+ SPDefCache[FD].reset(SP);
if (CGM.getCodeGenOpts().DwarfVersion >= 5) {
// Starting with DWARF V5 method declarations are emitted as children of
diff --git a/clang/test/CodeGen/debug-info-param-modification.c b/clang/test/CodeGen/debug-info-param-modification.c
index ef7ff922560..f2aa4c7290e 100644
--- a/clang/test/CodeGen/debug-info-param-modification.c
+++ b/clang/test/CodeGen/debug-info-param-modification.c
@@ -1,12 +1,21 @@
-// RUN: %clang -Xclang -femit-debug-entry-values -g -O2 -S -target x86_64-none-linux-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK-ENTRY-VAL-OPT
+// RUN: %clang -Xclang -femit-debug-entry-values -g -O2 -Xclang -disable-llvm-passes -S -target x86_64-none-linux-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix=CHECK-ENTRY-VAL-OPT
// CHECK-ENTRY-VAL-OPT: !DILocalVariable(name: "a", arg: 1, scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: {{.*}})
// CHECK-ENTRY-VAL-OPT: !DILocalVariable(name: "b", arg: 2, scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: {{.*}}, flags: DIFlagArgumentNotModified)
//
-// RUN: %clang -g -O2 -target x86_64-none-linux-gnu -S -emit-llvm %s -o - | FileCheck %s
+// For the os_log_helper:
+// CHECK-ENTRY-VAL-OPT: !DILocalVariable(name: "buffer", arg: 1, {{.*}}, flags: DIFlagArtificial)
+//
+// RUN: %clang -g -O2 -Xclang -disable-llvm-passes -target x86_64-none-linux-gnu -S -emit-llvm %s -o - | FileCheck %s
// CHECK-NOT: !DILocalVariable(name: "b", arg: 2, scope: {{.*}}, file: {{.*}}, line: {{.*}}, type: {{.*}}, flags: DIFlagArgumentNotModified)
//
+// For the os_log_helper:
+// CHECK: !DILocalVariable(name: "buffer", arg: 1, {{.*}}, flags: DIFlagArtificial)
int fn2 (int a, int b) {
++a;
return b;
}
+
+void test_builtin_os_log(void *buf, int i, const char *data) {
+ __builtin_os_log_format(buf, "%d %{public}s %{private}.16P", i, data, data);
+}
OpenPOWER on IntegriCloud