[all-commits] [llvm/llvm-project] 2a7213: [IR] Don't use blockaddresses as callbr arguments

Nikita Popov via All-commits all-commits at lists.llvm.org
Fri Jul 15 01:18:34 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 2a721374aef326d4668f750d341c86d1aa1a0309
      https://github.com/llvm/llvm-project/commit/2a721374aef326d4668f750d341c86d1aa1a0309
  Author: Nikita Popov <npopov at redhat.com>
  Date:   2022-07-15 (Fri, 15 Jul 2022)

  Changed paths:
    M clang/lib/CodeGen/CGStmt.cpp
    M clang/test/CodeGen/asm-goto.c
    M clang/test/CodeGen/asm.c
    M clang/test/Modules/asm-goto.c
    M llvm/docs/LangRef.rst
    M llvm/docs/ReleaseNotes.rst
    M llvm/include/llvm/IR/InlineAsm.h
    M llvm/include/llvm/IR/Instructions.h
    M llvm/lib/Bitcode/Reader/BitcodeReader.cpp
    M llvm/lib/CodeGen/GlobalISel/InlineAsmLowering.cpp
    M llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
    M llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
    M llvm/lib/IR/InlineAsm.cpp
    M llvm/lib/IR/Instructions.cpp
    M llvm/lib/IR/Verifier.cpp
    M llvm/test/Analysis/BasicAA/pr52735.ll
    M llvm/test/Assembler/call-arg-is-callee.ll
    M llvm/test/Assembler/inline-asm-constraint-error.ll
    M llvm/test/Bitcode/callbr.ll
    M llvm/test/CodeGen/AArch64/callbr-asm-label.ll
    M llvm/test/CodeGen/AArch64/callbr-asm-obj-file.ll
    M llvm/test/CodeGen/AArch64/speculation-hardening-sls.ll
    M llvm/test/CodeGen/ARM/speculation-hardening-sls.ll
    M llvm/test/CodeGen/PowerPC/ppc64-inlineasm-clobber.ll
    M llvm/test/CodeGen/SystemZ/asm-20.ll
    M llvm/test/CodeGen/X86/callbr-asm-bb-exports.ll
    M llvm/test/CodeGen/X86/callbr-asm-blockplacement.ll
    M llvm/test/CodeGen/X86/callbr-asm-branch-folding.ll
    M llvm/test/CodeGen/X86/callbr-asm-destinations.ll
    R llvm/test/CodeGen/X86/callbr-asm-errors.ll
    M llvm/test/CodeGen/X86/callbr-asm-instr-scheduling.ll
    M llvm/test/CodeGen/X86/callbr-asm-kill.mir
    M llvm/test/CodeGen/X86/callbr-asm-label-addr.ll
    M llvm/test/CodeGen/X86/callbr-asm-obj-file.ll
    M llvm/test/CodeGen/X86/callbr-asm-outputs-pred-succ.ll
    M llvm/test/CodeGen/X86/callbr-asm-outputs.ll
    M llvm/test/CodeGen/X86/callbr-asm-phi-placement.ll
    M llvm/test/CodeGen/X86/callbr-asm-sink.ll
    M llvm/test/CodeGen/X86/callbr-asm.ll
    M llvm/test/CodeGen/X86/callbr-codegenprepare.ll
    M llvm/test/CodeGen/X86/inline-asm-pic.ll
    M llvm/test/CodeGen/X86/shrinkwrap-callbr.ll
    M llvm/test/CodeGen/X86/speculation-hardening-sls.ll
    M llvm/test/CodeGen/X86/tail-dup-asm-goto.ll
    M llvm/test/Instrumentation/MemorySanitizer/msan_asm_conservative.ll
    M llvm/test/Transforms/CallSiteSplitting/callsite-split-callbr.ll
    M llvm/test/Transforms/CodeExtractor/PartialInlinePGOMultiRegion.ll
    M llvm/test/Transforms/Coroutines/coro-debug.ll
    M llvm/test/Transforms/GVN/callbr-loadpre-critedge.ll
    M llvm/test/Transforms/GVN/callbr-scalarpre-critedge.ll
    M llvm/test/Transforms/GVN/critical-edge-split-failure.ll
    M llvm/test/Transforms/IROutliner/illegal-callbr.ll
    M llvm/test/Transforms/Inline/blockaddress.ll
    M llvm/test/Transforms/Inline/callbr.ll
    M llvm/test/Transforms/JumpThreading/callbr-edge-split.ll
    M llvm/test/Transforms/JumpThreading/pr46857-callbr.ll
    M llvm/test/Transforms/LICM/callbr-crash.ll
    M llvm/test/Transforms/LoopDeletion/two-predecessors.ll
    M llvm/test/Transforms/LoopRotate/callbr.ll
    M llvm/test/Transforms/LoopStrengthReduce/callbr-critical-edge-splitting.ll
    M llvm/test/Transforms/LoopStrengthReduce/callbr-critical-edge-splitting2.ll
    M llvm/test/Transforms/LoopStrengthReduce/remove_scev_indvars.ll
    M llvm/test/Transforms/LoopUnroll/callbr.ll
    M llvm/test/Transforms/PGOProfile/callbr.ll
    M llvm/test/Transforms/SimpleLoopUnswitch/not-safe-to-clone.ll
    M llvm/test/Transforms/SimplifyCFG/callbr-destinations.ll
    M llvm/test/Transforms/SimplifyCFG/jump-threading.ll
    M llvm/test/Verifier/callbr.ll
    M llvm/test/Verifier/dominates.ll
    M llvm/test/tools/llvm-diff/callbr.ll
    M llvm/test/tools/llvm-diff/phinode.ll
    M llvm/test/tools/llvm-reduce/remove-function-arguments-of-funcs-used-in-blockaddress.ll
    M llvm/unittests/IR/InstructionsTest.cpp
    M polly/test/ScopDetect/callbr.ll

  Log Message:
  -----------
  [IR] Don't use blockaddresses as callbr arguments

Following some recent discussions, this changes the representation
of callbrs in IR. The current blockaddress arguments are replaced
with `!` label constraints that refer directly to callbr indirect
destinations:

    ; Before:
    %res = callbr i8* asm "", "=r,r,i"(i8* %x, i8* blockaddress(@test8, %foo))
    to label %asm.fallthrough [label %foo]
    ; After:
    %res = callbr i8* asm "", "=r,r,!i"(i8* %x)
    to label %asm.fallthrough [label %foo]

The benefit of this is that we can easily update the successors of
a callbr, without having to worry about also updating blockaddress
references. This should allow us to remove some limitations:

* Allow unrolling/peeling/rotation of callbr, or any other
  clone-based optimizations
  (https://github.com/llvm/llvm-project/issues/41834)
* Allow duplicate successors
  (https://github.com/llvm/llvm-project/issues/45248)

This is just the IR representation change though, I will follow up
with patches to remove limtations in various transformation passes
that are no longer needed.

Differential Revision: https://reviews.llvm.org/D129288




More information about the All-commits mailing list