From 1acd9a1a29ac30044ecefb6613485d5d168f66ca Mon Sep 17 00:00:00 2001 From: Roman Lebedev Date: Sat, 8 May 2021 15:42:11 +0300 Subject: [PATCH] Revert "[LICM] Hoist loads with invariant.group metadata" This appears to miscompile google benchmark's GetCacheSizesFromKVFS() when compiling with -fstrict-vtable-pointers. Runnable reproducer: https://godbolt.org/z/f9ovKqTzb The "f.fail()" crashes with BUS error, it is compiled into testb, and the adress it is testing is non-sensical. This reverts commit 4c89bcadf6cae8320a1925eb9cbeb8c8c1f5f58b. --- llvm/lib/Transforms/Scalar/LICM.cpp | 4 -- llvm/test/Transforms/LICM/invariant.group.ll | 58 ---------------------------- 2 files changed, 62 deletions(-) delete mode 100644 llvm/test/Transforms/LICM/invariant.group.ll diff --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp index c2bc93c..a2bda9d 100644 --- a/llvm/lib/Transforms/Scalar/LICM.cpp +++ b/llvm/lib/Transforms/Scalar/LICM.cpp @@ -1198,10 +1198,6 @@ bool llvm::canSinkOrHoistInst(Instruction &I, AAResults *AA, DominatorTree *DT, if (isLoadInvariantInLoop(LI, DT, CurLoop)) return true; - // Stores with an invariant.group metadata are ok to sink/hoist. - if (LI->hasMetadata(LLVMContext::MD_invariant_group)) - return true; - bool Invalidated; if (CurAST) Invalidated = pointerInvalidatedByLoop(MemoryLocation::get(LI), CurAST, diff --git a/llvm/test/Transforms/LICM/invariant.group.ll b/llvm/test/Transforms/LICM/invariant.group.ll deleted file mode 100644 index 0d33ac1..0000000 --- a/llvm/test/Transforms/LICM/invariant.group.ll +++ /dev/null @@ -1,58 +0,0 @@ -; RUN: opt -S < %s -passes=licm | FileCheck %s - -declare i8* @llvm.launder.invariant.group.p0i8(i8* %a) - -; CHECK-LABEL: define{{.*}}@f -define void @f(i32* %x) { -; CHECK: entry: -; CHECK-NOT: {{.*}}: -; CHECK: load {{.*}} !invariant.group -entry: - %x_i8 = bitcast i32* %x to i8* - %x_i8_inv = call i8* @llvm.launder.invariant.group.p0i8(i8* %x_i8) - br label %for.body - -for.cond.cleanup: - ret void - -for.body: - %i.04 = phi i32 [ 0, %entry ], [ %inc, %for.body ] - - %x_inv = bitcast i8* %x_i8_inv to i32* - %0 = load i32, i32* %x_inv, !invariant.group !0 - - call void @a(i32 %0) - %inc = add nuw nsw i32 %i.04, 1 - %exitcond.not = icmp eq i32 %inc, 100 - br i1 %exitcond.not, label %for.cond.cleanup, label %for.body -} - -; CHECK-LABEL: define{{.*}}@g -define void @g(i32* %x) { -; CHECK: for.body: -; CHECK-NOT: {{.*}}: -; CHECK: load {{.*}} !invariant.group -entry: - %x_i8 = bitcast i32* %x to i8* - br label %for.body - -for.cond.cleanup: - ret void - -for.body: - %i.04 = phi i32 [ 0, %entry ], [ %inc, %for.body ] - - %x_i8_inv = call i8* @llvm.launder.invariant.group.p0i8(i8* %x_i8) - %x_inv = bitcast i8* %x_i8_inv to i32* - - %0 = load i32, i32* %x_inv, !invariant.group !0 - - call void @a(i32 %0) - %inc = add nuw nsw i32 %i.04, 1 - %exitcond.not = icmp eq i32 %inc, 100 - br i1 %exitcond.not, label %for.cond.cleanup, label %for.body -} - -declare void @a(i32) - -!0 = !{} -- 2.7.4