<div dir="ltr">This change causes build failures on the UBSan bot, like <a href="http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap-ubsan/builds/7121/steps/build%20clang%2Fubsan/logs/stdio">so</a>:<div><pre style="font-family:"Courier New",courier,monotype,monospace;font-size:medium"><span class="inbox-inbox-stdout"><pre style="font-family:"Courier New",courier,monotype,monospace"><span class="inbox-inbox-stdout">3.    /b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm/include/llvm/Support/Allocator.h:98:40: Generating code for declaration 'llvm::MallocAllocator::Allocate'</span></pre></span></pre><pre style="font-family:"Courier New",courier,monotype,monospace;font-size:medium"><span class="inbox-inbox-stdout">#0 0x000055c1695ee77a llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x265677a)
#1 0x000055c1695ecc55 llvm::sys::RunSignalHandlers() (/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x2654c55)
#2 0x000055c1695ecd6c SignalHandler(int) (/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x2654d6c)
#3 0x00007f1e75f880c0 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x110c0)
#4 0x000055c169018c69 llvm::DebugLoc::get(unsigned int, unsigned int, llvm::MDNode const*, llvm::MDNode const*, bool) (/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x2080c69)
#5 0x000055c1697ddb31 clang::CodeGen::CGDebugInfo::EmitLocation(clang::CodeGen::CGBuilderTy&, clang::SourceLocation) (/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x2845b31)
#6 0x000055c1697ddcd6 clang::CodeGen::ApplyDebugLocation::init(clang::SourceLocation, bool) (/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x2845cd6)
#7 0x000055c1699defa6 emitCheckHandlerCall(clang::CodeGen::CodeGenFunction&, llvm::FunctionType*, llvm::ArrayRef<llvm::Value*>, clang::CodeGen::SanitizerHandler, (anonymous namespace)::CheckRecoverableKind, bool, llvm::BasicBlock*) (/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x2a46fa6)
#8 0x000055c1699e155a clang::CodeGen::CodeGenFunction::EmitCheck(llvm::ArrayRef<std::pair<llvm::Value*, unsigned long> >, clang::CodeGen::SanitizerHandler, llvm::ArrayRef<llvm::Constant*>, llvm::ArrayRef<llvm::Value*>) (/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x2a4955a)
#9 0x000055c169991463 clang::CodeGen::CodeGenFunction::EmitReturnValueCheck(llvm::Value*) (/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x29f9463)
#10 0x000055c16999f536 clang::CodeGen::CodeGenFunction::EmitFunctionEpilog(clang::CodeGen::CGFunctionInfo const&, bool, clang::SourceLocation) (/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x2a07536)
#11 0x000055c16985070a clang::CodeGen::CodeGenFunction::FinishFunction(clang::SourceLocation) (/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x28b870a)
#12 0x000055c16985959f clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x28c159f)
#13 0x000055c169895ac5 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x28fdac5)
#14 0x000055c169892c39 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x28fac39)
#15 0x000055c169898992 clang::CodeGen::CodeGenModule::EmitDeferred() (/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x2900992)
#16 0x000055c1698989ac clang::CodeGen::CodeGenModule::EmitDeferred() (/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x29009ac)
#17 0x000055c1698989ac clang::CodeGen::CodeGenModule::EmitDeferred() (/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x29009ac)
#18 0x000055c1698989ac clang::CodeGen::CodeGenModule::EmitDeferred() (/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x29009ac)
#19 0x000055c1698989ac clang::CodeGen::CodeGenModule::EmitDeferred() (/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x29009ac)
#20 0x000055c169898af3 clang::CodeGen::CodeGenModule::Release() (/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x2900af3)
#21 0x000055c169fae527 (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) (/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x3016527)
#22 0x000055c169fad156 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x3015156)
#23 0x000055c16a7b9569 clang::ParseAST(clang::Sema&, bool, bool) (/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x3821569)
#24 0x000055c169fac339 clang::CodeGenAction::ExecuteAction() (/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x3014339)
#25 0x000055c169c2d25e clang::FrontendAction::Execute() (/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x2c9525e)
#26 0x000055c169bf7b0e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x2c5fb0e)
#27 0x000055c169cd0f51 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0x2d38f51)
#28 0x000055c167c34760 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0xc9c760)
#29 0x000055c167b9ea92 main (/b/sanitizer-x86_64-linux-bootstrap-ubsan/build/llvm_build0/bin/clang-8+0xc06a92)
</span></pre>I've reverted it in r344961.</div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, Oct 22, 2018 at 9:29 AM Adrian Prantl via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: adrian<br>
Date: Mon Oct 22 09:27:41 2018<br>
New Revision: 344915<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=344915&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=344915&view=rev</a><br>
Log:<br>
Ensure sanitizer check function calls have a !dbg location<br>
<br>
Function calls without a !dbg location inside a function that has a<br>
DISubprogram make it impossible to construct inline information and<br>
are rejected by the verifier. This patch ensures that sanitizer check<br>
function calls have a !dbg location, by carrying forward the location<br>
of the preceding instruction or by inserting an artificial location if<br>
necessary.<br>
<br>
This fixes a crash when compiling the attached testcase with -Os.<br>
<br>
rdar://problem/45311226<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D53459" rel="noreferrer" target="_blank">https://reviews.llvm.org/D53459</a><br>
<br>
Added:<br>
    cfe/trunk/test/CodeGenCXX/ubsan-check-debuglocs.cpp<br>
Modified:<br>
    cfe/trunk/lib/CodeGen/CGExpr.cpp<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=344915&r1=344914&r2=344915&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=344915&r1=344914&r2=344915&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Oct 22 09:27:41 2018<br>
@@ -2867,6 +2867,9 @@ static void emitCheckHandlerCall(CodeGen<br>
                                  CheckRecoverableKind RecoverKind, bool IsFatal,<br>
                                  llvm::BasicBlock *ContBB) {<br>
   assert(IsFatal || RecoverKind != CheckRecoverableKind::Unrecoverable);<br>
+  auto *DI = CGF.getDebugInfo();<br>
+  SourceLocation Loc = DI ? DI->getLocation() : SourceLocation();<br>
+  auto DL = ApplyDebugLocation::CreateDefaultArtificial(CGF, Loc);<br>
   bool NeedsAbortSuffix =<br>
       IsFatal && RecoverKind != CheckRecoverableKind::Unrecoverable;<br>
   bool MinimalRuntime = CGF.CGM.getCodeGenOpts().SanitizeMinimalRuntime;<br>
<br>
Added: cfe/trunk/test/CodeGenCXX/ubsan-check-debuglocs.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/ubsan-check-debuglocs.cpp?rev=344915&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/ubsan-check-debuglocs.cpp?rev=344915&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/CodeGenCXX/ubsan-check-debuglocs.cpp (added)<br>
+++ cfe/trunk/test/CodeGenCXX/ubsan-check-debuglocs.cpp Mon Oct 22 09:27:41 2018<br>
@@ -0,0 +1,17 @@<br>
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited \<br>
+// RUN:   -fsanitize=null %s -o - | FileCheck %s<br>
+<br>
+// Check that santizer check calls have a !dbg location.<br>
+// CHECK: define {{.*}}acquire{{.*}} !dbg<br>
+// CHECK-NOT: define<br>
+// CHECK: call void {{.*}}@__ubsan_handle_type_mismatch_v1<br>
+// CHECK-SAME: !dbg<br>
+<br>
+struct SourceLocation {<br>
+  SourceLocation acquire() {};<br>
+};<br>
+extern "C" void __ubsan_handle_type_mismatch_v1(SourceLocation *Loc);<br>
+static void handleTypeMismatchImpl(SourceLocation *Loc) { Loc->acquire(); }<br>
+void __ubsan_handle_type_mismatch_v1(SourceLocation *Loc) {<br>
+  handleTypeMismatchImpl(Loc);<br>
+}<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div>