[PATCH] D46265: StackColoring: better handling of statically unreachable code

Simon Dardis via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 10 16:29:34 PDT 2018


sdardis added a comment.

Sorry for the delay, but this change looks ok, but the supplied test case is flaky and crashes sometimes on my machine:

Assertion failed: (!isa<Constant>(V) && "Can't get a constant or global slot with this!"), function getLocalSlot, file /Users/sdardis/dev/llvm/llvm/lib/IR/AsmWriter.cpp, line 1038.
Stack dump:
0.  Program arguments: /Users/sdardis/dev/llvm/llvmbuild3/bin/llc -mcpu=corei7 -no-stack-coloring=false -stop-after stack-coloring -o /dev/null /Users/sdardis/dev/llvm/llvm/test/CodeGen/X86/stack-coloring-unreachable-bb.mir

1. Running pass 'Function Pass Manager' on module '/Users/sdardis/dev/llvm/llvm/test/CodeGen/X86/stack-coloring-unreachable-bb.mir'.
2. Running pass 'MIR Printing Pass' on function '@foo'

0  llc                      0x0000000107cfdeff llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 63
1  llc                      0x0000000107cfe3a9 PrintStackTraceSignalHandler(void*) + 25
2  llc                      0x0000000107cfaf99 llvm::sys::RunSignalHandlers() + 425
3  llc                      0x0000000107cfe629 SignalHandler(int) + 345
4  libsystem_platform.dylib 0x00007fff9ee7b52a _sigtramp + 26
5  libsystem_platform.dylib 0x00007fff63e0f5c8 _sigtramp + 3304669368
6  libsystem_c.dylib        0x00007fff9c3af6df abort + 129
7  libsystem_c.dylib        0x00007fff9c376dd8 basename + 0
8  llc                      0x0000000106e07ff1 llvm::SlotTracker::getLocalSlot(llvm::Value const*) + 113
9  llc                      0x0000000106e07f6e llvm::ModuleSlotTracker::getLocalSlot(llvm::Value const*) + 126
10 llc                      0x0000000106b9bc2f llvm::MIPrinter::print(llvm::MachineBasicBlock const&) + 447
11 llc                      0x0000000106b97d30 llvm::MIRPrinter::print(llvm::MachineFunction const&) + 944
12 llc                      0x0000000106b9f12d llvm::printMIR(llvm::raw_ostream&, llvm::MachineFunction const&) + 45
13 llc                      0x0000000106ba62fa (anonymous namespace)::MIRPrintingPass::runOnMachineFunction(llvm::MachineFunction&) + 298
14 llc                      0x0000000106a1b2a6 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 454
15 llc                      0x000000010708916d llvm::FPPassManager::runOnFunction(llvm::Function&) + 413
16 llc                      0x00000001070894a5 llvm::FPPassManager::runOnModule(llvm::Module&) + 117
17 llc                      0x000000010708a1fa (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) + 2010
18 llc                      0x000000010708978b llvm::legacy::PassManagerImpl::run(llvm::Module&) + 347
19 llc                      0x000000010708ae41 llvm::legacy::PassManager::run(llvm::Module&) + 33
20 llc                      0x000000010474f991 compileModule(char**, llvm::LLVMContext&) + 19281
21 llc                      0x000000010474ab3e main + 4062
22 libdyld.dylib            0x00007fff9b6d85ad start + 1
/Users/sdardis/dev/llvm/llvmbuild3/test/CodeGen/X86/Output/stack-coloring-unreachable-bb.mir.script: line 1: 84647 Abort trap: 6           /Users/sdardis/dev/llvm/llvmbuild3/bin/llc -mcpu=corei7 -no-stack-coloring=false -stop-after stack-coloring -o /dev/null /Users/sdardis/dev/llvm/llvm/test/CodeGen/X86/stack-coloring-unreachable-bb.mir

Digging in with valgrind shows several invalid reads or "Conditional jump or move depends on uninitialised value(s)".

Digging in with LLDB gives differing results (somewhat expected). Can you run valgrind on the run of llc for this test case and report your findings?



================
Comment at: test/CodeGen/X86/stack-coloring-unreachable-bb.mir:1
+# RUN: llc -mcpu=corei7 -no-stack-coloring=false -stop-after stack-coloring -o - %s
+
----------------
Either rename this file to PR37310.mir or cite the PR number as a comment.


================
Comment at: test/CodeGen/X86/stack-coloring-unreachable-bb.mir:1
+# RUN: llc -mcpu=corei7 -no-stack-coloring=false -stop-after stack-coloring -o - %s
+
----------------
sdardis wrote:
> Either rename this file to PR37310.mir or cite the PR number as a comment.
Add -mtriple=x86_64-unknown-linux-gnu to the command line here.


================
Comment at: test/CodeGen/X86/stack-coloring-unreachable-bb.mir:3
+
+# This MIR testcase was created by compiling the following test, first
+# with "clang -emit-llvm -S" and then "llc -stop-before stack-coloring",
----------------
Explain that this is testing that the stack coloring pass handles statically unreachable blocks.


================
Comment at: test/CodeGen/X86/stack-coloring-unreachable-bb.mir:22-25
+  ; ModuleID = 'llvm-pr-37130.opt.ll'
+  source_filename = "llvm-pr-37130.c"
+  target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+  target triple = "x86_64-unknown-linux-gnu"
----------------
This can all be removed.


================
Comment at: test/CodeGen/X86/stack-coloring-unreachable-bb.mir:27
+  
+  ; Function Attrs: nounwind uwtable
+  define void @foo(i32 %x) local_unnamed_addr #0 {
----------------
These "; Function Attrs.."  lines can all be removed.


================
Comment at: test/CodeGen/X86/stack-coloring-unreachable-bb.mir:28
+  ; Function Attrs: nounwind uwtable
+  define void @foo(i32 %x) local_unnamed_addr #0 {
+  entry:
----------------
local_unnamed_addr can be removed.


================
Comment at: test/CodeGen/X86/stack-coloring-unreachable-bb.mir:69-72
+  attributes #0 = { nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
+  attributes #1 = { argmemonly nounwind }
+  attributes #2 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
+  attributes #3 = { nounwind }
----------------
As far as I can see, these can be removed as well, along with #<num>s in the function declarations.


================
Comment at: test/CodeGen/X86/stack-coloring-unreachable-bb.mir:73-78
+  
+  !llvm.module.flags = !{!0}
+  !llvm.ident = !{!1}
+  
+  !0 = !{i32 1, !"wchar_size", i32 4}
+  !1 = !{!"clang version 7.0.0 (trunk 331069) (llvm/trunk 331070)"}
----------------
This can be removed.


Repository:
  rL LLVM

https://reviews.llvm.org/D46265





More information about the llvm-commits mailing list