[llvm] 674f578 - [gardening] Replace some uses of setDebugLoc(DebugLoc()) with dropLocation(), NFC

Petr Hosek via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 29 23:26:37 PDT 2020


We're seeing a segfault when compiling compiler-rt builtins that seems to
have been introduced by this change:

Stack dump:
0.      Program arguments: ./bin/clang -cc1 -triple aarch64-unknown-fuchsia
-emit-obj --mrelax-relocations -disable-free -main-file-name multc3.c
-mrelocation-model pic -pic-level 2 -mframe-pointer=none -fno-rounding-math
-mconstructor-aliases -munwind-tables -target-cpu generic -target-feature
+neon -target-abi aapcs -fallow-half-arguments-and-returns
-fno-split-dwarf-inlining -debug-info-kind=limited -dwarf-version=4
-debugger-tuning=gdb -sys-header-deps -D VISIBILITY_HIDDEN -D NDEBUG -O2
-std=c11 -ferror-limit 19 -fvisibility hidden -fsanitize=shadow-call-stack
-stack-protector 2 -fno-builtin -fno-signed-char -fgnuc-version=4.2.1
-fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -x c
multc3-9f994f.c
1.      <eof> parser at end of file
2.      Per-module optimization passes
3.      Running pass 'Function Pass Manager' on module 'multc3-9f994f.c'.
4.      Running pass 'Simplify the CFG' on function '@__multc3'
 #0 0x0000000008875f7a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int)
/src/clang-llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:563:11
 #1 0x000000000887608b PrintStackTraceSignalHandler(void*)
/src/clang-llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:630:1
 #2 0x000000000887485b llvm::sys::RunSignalHandlers()
/src/clang-llvm/llvm-project/llvm/lib/Support/Signals.cpp:70:5
 #3 0x00000000088766e3 SignalHandler(int)
/src/clang-llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:405:1
 #4 0x00007f202e2eb140 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x14140)
 #5 0x00000000057d5c3c llvm::BasicBlock::getParent() const
/src/clang-llvm/llvm-project/llvm/include/llvm/IR/BasicBlock.h:107:46
 #6 0x0000000007c9e06d llvm::Instruction::getFunction() const
/src/clang-llvm/llvm-project/llvm/lib/IR/Instruction.cpp:73:3
 #7 0x0000000005737bf5 llvm::Instruction::getFunction()
/src/clang-llvm/llvm-project/llvm/include/llvm/IR/Instruction.h:114:5
 #8 0x0000000007bc9ead llvm::Instruction::dropLocation()
/src/clang-llvm/llvm-project/llvm/lib/IR/DebugInfo.cpp:715:43
 #9 0x00000000089b7bd7 llvm::FoldBranchToCommonDest(llvm::BranchInst*,
llvm::MemorySSAUpdater*, llvm::TargetTransformInfo const*, unsigned int)
/src/clang-llvm/llvm-project/llvm/lib/Transforms/Utils/SimplifyCFG.cpp:2883:24
#10 0x00000000089bf2e0 (anonymous
namespace)::SimplifyCFGOpt::simplifyCondBranch(llvm::BranchInst*,
llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter>&)
/src/clang-llvm/llvm-project/llvm/lib/Transforms/Utils/SimplifyCFG.cpp:6103:7
#11 0x00000000089bb03c (anonymous
namespace)::SimplifyCFGOpt::simplifyBranch(llvm::BranchInst*,
llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter>&)
/src/clang-llvm/llvm-project/llvm/lib/Transforms/Utils/SimplifyCFG.cpp:5992:38
#12 0x00000000089b9953 (anonymous
namespace)::SimplifyCFGOpt::simplifyOnce(llvm::BasicBlock*)
/src/clang-llvm/llvm-project/llvm/lib/Transforms/Utils/SimplifyCFG.cpp:6285:16
#13 0x00000000089b9500 (anonymous
namespace)::SimplifyCFGOpt::run(llvm::BasicBlock*)
/src/clang-llvm/llvm-project/llvm/lib/Transforms/Utils/SimplifyCFG.cpp:6319:16
#14 0x00000000089b9476 llvm::simplifyCFG(llvm::BasicBlock*,
llvm::TargetTransformInfo const&, llvm::SimplifyCFGOptions const&,
llvm::SmallPtrSetImpl<llvm::BasicBlock*>*)
/src/clang-llvm/llvm-project/llvm/lib/Transforms/Utils/SimplifyCFG.cpp:6328:3
#15 0x0000000008729bb6 iterativelySimplifyCFG(llvm::Function&,
llvm::TargetTransformInfo const&, llvm::SimplifyCFGOptions const&)
/src/clang-llvm/llvm-project/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp:184:11
#16 0x00000000087291af simplifyFunctionCFG(llvm::Function&,
llvm::TargetTransformInfo const&, llvm::SimplifyCFGOptions const&)
/src/clang-llvm/llvm-project/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp:198:18
#17 0x0000000008729eed (anonymous
namespace)::CFGSimplifyPass::runOnFunction(llvm::Function&)
/src/clang-llvm/llvm-project/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp:285:5
#18 0x0000000007cf4aa2 llvm::FPPassManager::runOnFunction(llvm::Function&)
/src/clang-llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1519:23
#19 0x0000000007cf9c65 llvm::FPPassManager::runOnModule(llvm::Module&)
/src/clang-llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1565:16
#20 0x0000000007cf5446 (anonymous
namespace)::MPPassManager::runOnModule(llvm::Module&)
/src/clang-llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1634:23
#21 0x0000000007cf4f76 llvm::legacy::PassManagerImpl::run(llvm::Module&)
/src/clang-llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:615:16
#22 0x0000000007cf9f61 llvm::legacy::PassManager::run(llvm::Module&)
/src/clang-llvm/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1761:3
#23 0x0000000008c4fe2d (anonymous
namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction,
std::__2::unique_ptr<llvm::raw_pwrite_stream,
std::__2::default_delete<llvm::raw_pwrite_stream> >)
/src/clang-llvm/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:982:3
#24 0x0000000008c4c5b0 clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::HeaderSearchOptions const&, clang::CodeGenOptions const&,
clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout
const&, llvm::Module*, clang::BackendAction,
std::__2::unique_ptr<llvm::raw_pwrite_stream,
std::__2::default_delete<llvm::raw_pwrite_stream> >)
/src/clang-llvm/llvm-project/clang/lib/CodeGen/BackendUtil.cpp:1650:17
#25 0x00000000098e8ee4
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
/src/clang-llvm/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:345:7
#26 0x000000000bff6648 clang::ParseAST(clang::Sema&, bool, bool)
/src/clang-llvm/llvm-project/clang/lib/Parse/ParseAST.cpp:178:12
#27 0x000000000971c0dd clang::ASTFrontendAction::ExecuteAction()
/src/clang-llvm/llvm-project/clang/lib/Frontend/FrontendAction.cpp:1059:1
#28 0x00000000098e5290 clang::CodeGenAction::ExecuteAction()
/src/clang-llvm/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:1189:1
#29 0x000000000971bad8 clang::FrontendAction::Execute()
/src/clang-llvm/llvm-project/clang/lib/Frontend/FrontendAction.cpp:954:7
#30 0x000000000964886b
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
/src/clang-llvm/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:984:23
#31 0x00000000098d62b4
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
/src/clang-llvm/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:278:8
#32 0x0000000005666835 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) /src/clang-llvm/llvm-project/clang/tools/driver/cc1_main.cpp:240:13
#33 0x000000000565971a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&)
/src/clang-llvm/llvm-project/clang/tools/driver/driver.cpp:330:5
#34 0x00000000056588dd main
/src/clang-llvm/llvm-project/clang/tools/driver/driver.cpp:407:5
#35 0x00007f202df95cca __libc_start_main ./csu/../csu/libc-start.c:308:16
#36 0x000000000565807a _start (./bin/clang+0x565807a)

Would it be possible to revert it?

On Tue, Sep 29, 2020 at 5:39 PM Vedant Kumar via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

>
> Author: Vedant Kumar
> Date: 2020-09-29T17:39:07-07:00
> New Revision: 674f57870f4c8a7fd7b629bffc85b149cbefd3e0
>
> URL:
> https://github.com/llvm/llvm-project/commit/674f57870f4c8a7fd7b629bffc85b149cbefd3e0
> DIFF:
> https://github.com/llvm/llvm-project/commit/674f57870f4c8a7fd7b629bffc85b149cbefd3e0.diff
>
> LOG: [gardening] Replace some uses of setDebugLoc(DebugLoc()) with
> dropLocation(), NFC
>
> Added:
>
>
> Modified:
>     llvm/lib/Transforms/Scalar/LICM.cpp
>     llvm/lib/Transforms/Utils/SimplifyCFG.cpp
>
> Removed:
>
>
>
>
> ################################################################################
> diff  --git a/llvm/lib/Transforms/Scalar/LICM.cpp
> b/llvm/lib/Transforms/Scalar/LICM.cpp
> index 631fa2f27c5b..bc581e7ad40f 100644
> --- a/llvm/lib/Transforms/Scalar/LICM.cpp
> +++ b/llvm/lib/Transforms/Scalar/LICM.cpp
> @@ -2159,7 +2159,7 @@ bool llvm::promoteLoopAccessesToScalars(
>    if (SawUnorderedAtomic)
>      PreheaderLoad->setOrdering(AtomicOrdering::Unordered);
>    PreheaderLoad->setAlignment(Alignment);
> -  PreheaderLoad->setDebugLoc(DebugLoc());
> +  PreheaderLoad->dropLocation();
>    if (AATags)
>      PreheaderLoad->setAAMetadata(AATags);
>    SSA.AddAvailableValue(Preheader, PreheaderLoad);
>
> diff  --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
> b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
> index 124a7c423e72..1672293380d7 100644
> --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
> +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
> @@ -2218,7 +2218,7 @@ bool
> SimplifyCFGOpt::SpeculativelyExecuteBB(BranchInst *BI, BasicBlock *ThenBB,
>    // be misleading while debugging.
>    for (auto &I : *ThenBB) {
>      if (!SpeculatedStoreValue || &I != SpeculatedStore)
> -      I.setDebugLoc(DebugLoc());
> +      I.dropLocation();
>      I.dropUnknownNonDebugMetadata();
>    }
>
> @@ -2878,7 +2878,7 @@ bool llvm::FoldBranchToCommonDest(BranchInst *BI,
> MemorySSAUpdater *MSSAU,
>        // When we fold the bonus instructions we want to make sure we
>        // reset their debug locations in order to avoid stepping on dead
>        // code caused by folding dead branches.
> -      NewBonusInst->setDebugLoc(DebugLoc());
> +      NewBonusInst->dropLocation();
>
>        RemapInstruction(NewBonusInst, VMap,
>                         RF_NoModuleLevelChanges | RF_IgnoreMissingLocals);
> @@ -2902,7 +2902,7 @@ bool llvm::FoldBranchToCommonDest(BranchInst *BI,
> MemorySSAUpdater *MSSAU,
>
>      // Reset the condition debug location to avoid jumping on dead code
>      // as the result of folding dead branches.
> -    CondInPred->setDebugLoc(DebugLoc());
> +    CondInPred->dropLocation();
>
>      RemapInstruction(CondInPred, VMap,
>                       RF_NoModuleLevelChanges | RF_IgnoreMissingLocals);
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200929/5f54ce30/attachment.html>


More information about the llvm-commits mailing list