Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
aengelke committed Aug 1, 2024
1 parent d0462c5 commit 5a3375f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 0 additions & 2 deletions llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,6 @@ bool AlignmentFromAssumptionsPass::processAssumption(CallInst *ACall,
for (auto &U : J->uses()) {
if (U->getType()->isPointerTy()) {
Instruction *K = cast<Instruction>(U.getUser());
if (K->getFunction() != ACall->getFunction())
continue;
StoreInst *SI = dyn_cast<StoreInst>(K);
if (SI && SI->getPointerOperandIndex() != U.getOperandNo())
continue;
Expand Down
18 changes: 13 additions & 5 deletions llvm/test/Transforms/AlignmentFromAssumptions/domtree-crash.ll
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
; RUN: opt -passes=alignment-from-assumptions -disable-output < %s

; REQUIRES: asserts
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt -passes=alignment-from-assumptions -S < %s | FileCheck %s

; The alignment assumption is a global, which has users in a different
; function. Test that in this case the dominator tree is only queried with
; blocks from the same function.

target triple = "x86_64-unknown-linux-gnu"

@global = external constant [192 x i8]

define void @fn1() {
; CHECK-LABEL: define void @fn1() {
; CHECK-NEXT: call void @llvm.assume(i1 false) [ "align"(ptr @global, i64 1) ]
; CHECK-NEXT: ret void
;
call void @llvm.assume(i1 false) [ "align"(ptr @global, i64 1) ]
ret void
}

define void @fn2() {
; CHECK-LABEL: define void @fn2() {
; CHECK-NEXT: ret void
; CHECK: [[LOOP:.*]]:
; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds i8, ptr @global, i64 0
; CHECK-NEXT: [[LOAD:%.*]] = load i64, ptr [[GEP]], align 1
; CHECK-NEXT: br label %[[LOOP]]
;
ret void

loop:
Expand Down

0 comments on commit 5a3375f

Please sign in to comment.