Skip to content

Commit

Permalink
Fix test changes for LLVM 15
Browse files Browse the repository at this point in the history
Co-authored-by: Gabriel Baraldi <baraldigabriel@gmail.com>
Co-authored-by: Prem Chintalapudi <prem.chintalapudi@gmail.com>
  • Loading branch information
3 people committed Apr 29, 2023
1 parent a585b91 commit fd91a0f
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 21 deletions.
3 changes: 3 additions & 0 deletions src/llvm-alloc-opt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1089,9 +1089,12 @@ void Optimizer::splitOnStack(CallInst *orig_inst)
ref->setOrdering(AtomicOrdering::NotAtomic);
operands.push_back(ref);
}
#ifndef __clang_analyzer__
// FIXME: SA finds "Called C++ object pointer is null" inside the LLVM code.
auto new_call = builder.CreateCall(pass.gc_preserve_begin_func, operands);
new_call->takeName(call);
call->replaceAllUsesWith(new_call);
#endif
call->eraseFromParent();
return;
}
Expand Down
1 change: 1 addition & 0 deletions src/llvm-late-gc-lowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1262,6 +1262,7 @@ static bool isLoadFromConstGV(LoadInst *LI, bool &task_local, PhiSet *seen)
// We only emit single slot GV in codegen
// but LLVM global merging can change the pointer operands to GEPs/bitcasts
auto load_base = LI->getPointerOperand()->stripInBoundsOffsets();
assert(load_base); // Static analyzer
auto gv = dyn_cast<GlobalVariable>(load_base);
if (isTBAA(LI->getMetadata(LLVMContext::MD_tbaa),
{"jtbaa_immut", "jtbaa_const", "jtbaa_datatype"})) {
Expand Down
1 change: 1 addition & 0 deletions src/llvm-lower-handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <llvm/ADT/DepthFirstIterator.h>
#include <llvm/ADT/Statistic.h>
#include <llvm/ADT/Triple.h>
#include <llvm/Analysis/CFG.h>
#include <llvm/IR/BasicBlock.h>
#include <llvm/IR/Constants.h>
Expand Down
3 changes: 3 additions & 0 deletions src/llvm-multiversioning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
#include <llvm/Pass.h>
#include <llvm/ADT/BitVector.h>
#include <llvm/ADT/Statistic.h>
#include <llvm/ADT/Triple.h>
#include <llvm/IR/Module.h>
#include <llvm/IR/LegacyPassManager.h>
#include <llvm/IR/Function.h>
#include <llvm/IR/Instructions.h>
#include <llvm/IR/Constants.h>
#include <llvm/IR/Dominators.h>
#include <llvm/IR/LLVMContext.h>
#include <llvm/Analysis/LoopInfo.h>
#include <llvm/Analysis/CallGraph.h>
Expand Down Expand Up @@ -779,6 +781,7 @@ static Value *rewrite_inst_use(const Stack& stack, Type *T_size, Value *replace,
replace = inst;
continue;
}
assert(val);
unsigned nargs = val->getNumOperands();
args.resize(nargs);
for (unsigned j = 0; j < nargs; j++) {
Expand Down
2 changes: 2 additions & 0 deletions src/llvm-ptls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <llvm-c/Types.h>

#include <llvm/Pass.h>
#include <llvm/ADT/Triple.h>
#include <llvm/IR/Module.h>
#include <llvm/IR/LegacyPassManager.h>
#include <llvm/IR/Function.h>
Expand Down Expand Up @@ -161,6 +162,7 @@ void LowerPTLS::fix_pgcstack_use(CallInst *pgcstack, Function *pgcstack_getter,
SmallVector<uint32_t, 2> Weights{9, 1};
TerminatorInst *fastTerm;
TerminatorInst *slowTerm;
assert(pgcstack->getType()); // Static analyzer
auto cmp = new ICmpInst(phi, CmpInst::ICMP_NE, pgcstack, Constant::getNullValue(pgcstack->getType()));
SplitBlockAndInsertIfThenElse(cmp, phi, &fastTerm, &slowTerm,
MDB.createBranchWeights(Weights));
Expand Down
3 changes: 3 additions & 0 deletions test/clangsa/MissingRoots.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,9 @@ void assoc_exact_broken(jl_value_t **args, size_t n, int8_t offs, size_t world)
}
*/

// declare
jl_typemap_level_t *jl_new_typemap_level(void);

void assoc_exact_ok(jl_value_t *args1, jl_value_t **args, size_t n, int8_t offs, size_t world) {
jl_typemap_level_t *cache = jl_new_typemap_level();
JL_GC_PUSH1(&cache);
Expand Down
10 changes: 6 additions & 4 deletions test/cmdlineargs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,12 @@ let exename = `$(Base.julia_cmd()) --startup-file=no --color=no`
@test contains(v[2], r"enable-tail-merge + = 1")
@test isempty(v[3])
end
@testset let v = readchomperrors(setenv(`$exename -e 0`, "JULIA_LLVM_ARGS" => "-print-options -enable-tail-merge=1 -enable-tail-merge=1", "HOME" => homedir()))
@test !v[1]
@test isempty(v[2])
@test v[3] == "julia: for the --enable-tail-merge option: may only occur zero or one times!"
if Base.libllvm_version < v"15" #LLVM over 15 doesn't care for multiple options
@testset let v = readchomperrors(setenv(`$exename -e 0`, "JULIA_LLVM_ARGS" => "-print-options -enable-tail-merge=1 -enable-tail-merge=1", "HOME" => homedir()))
@test !v[1]
@test isempty(v[2])
@test v[3] == "julia: for the --enable-tail-merge option: may only occur zero or one times!"
end
end
end

Expand Down
4 changes: 2 additions & 2 deletions test/llvmpasses/llvmcall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ emit(foo, NTuple{2, Float16})
# CHECK: call <2 x half> @foo(<2 x half> %{{[0-9]+}})
emit(foo, NTuple{2, VecElement{Float16}})

# CHECK: call i8 addrspace(3)* @foo(i8 addrspace(3)* %{{[0-9]+}})
# CHECK: call ptr addrspace(3) @foo(ptr addrspace(3) %{{[0-9]+}})
emit(foo, Core.LLVMPtr{Float32, 3})

# CHECK: call { i32, i32 } @foo({ i32, i32 } %{{[0-9]+}})
emit(foo, Foo)

# CHECK: define <2 x half> @julia_bar_{{[0-9]+}}([2 x half]
# CHECK: define <2 x half> @julia_bar_{{[0-9]+}}(ptr addrspace(11)
emit(bar, NTuple{2, Float16})
24 changes: 12 additions & 12 deletions test/llvmpasses/pipeline-o2-broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@ include(joinpath("..", "testhelpers", "llvmpasses.jl"))

# COM: Float32
# CHECK: @japi1_prod_v_vT
# CHECK: load <[[VSCALE:(vscale x )?]][[VEC_FACTOR:[0-9]+]] x float>
# COM: load <[[VSCALE:(vscale x )?]][[VEC_FACTOR:[0-9]+]] x float>
# CHECK: fmul <[[VSCALE]][[VEC_FACTOR]] x float>
# CHECK: store <[[VSCALE]][[VEC_FACTOR]] x float>

# COM: Float64
# CHECK: @japi1_prod_v_vT
# CHECK: load <[[VSCALE:(vscale x )?]][[VEC_FACTOR:[0-9]+]] x double>
# COM: load <[[VSCALE:(vscale x )?]][[VEC_FACTOR:[0-9]+]] x double>
# CHECK: fmul <[[VSCALE]][[VEC_FACTOR]] x double>
# CHECK: store <[[VSCALE]][[VEC_FACTOR]] x double>

# COM: Int32
# CHECK: @japi1_prod_v_vT
# CHECK: load <[[VSCALE:(vscale x )?]][[VEC_FACTOR:[0-9]+]] x i32>
# COM: load <[[VSCALE:(vscale x )?]][[VEC_FACTOR:[0-9]+]] x i32>
# CHECK: mul <[[VSCALE]][[VEC_FACTOR]] x i32>
# CHECK: store <[[VSCALE]][[VEC_FACTOR]] x i32>

# COM: Int64
# CHECK: @japi1_prod_v_vT
# CHECK: load <[[VSCALE:(vscale x )?]][[VEC_FACTOR:[0-9]+]] x i64>
# COM: load <[[VSCALE:(vscale x )?]][[VEC_FACTOR:[0-9]+]] x i64>
# CHECK: mul <[[VSCALE]][[VEC_FACTOR]] x i64>
# CHECK: store <[[VSCALE]][[VEC_FACTOR]] x i64>

Expand All @@ -37,25 +37,25 @@ end

# COM: Float32
# CHECK: @japi1_prod_vT_v
# CHECK: load <[[VSCALE:(vscale x )?]][[VEC_FACTOR:[0-9]+]] x float>
# COM: load <[[VSCALE:(vscale x )?]][[VEC_FACTOR:[0-9]+]] x float>
# CHECK: fmul <[[VSCALE]][[VEC_FACTOR]] x float>
# CHECK: store <[[VSCALE]][[VEC_FACTOR]] x float>

# COM: Float64
# CHECK: @japi1_prod_vT_v
# CHECK: load <[[VSCALE:(vscale x )?]][[VEC_FACTOR:[0-9]+]] x double>
# COM: load <[[VSCALE:(vscale x )?]][[VEC_FACTOR:[0-9]+]] x double>
# CHECK: fmul <[[VSCALE]][[VEC_FACTOR]] x double>
# CHECK: store <[[VSCALE]][[VEC_FACTOR]] x double>

# COM: Int32
# CHECK: @japi1_prod_vT_v
# CHECK: load <[[VSCALE:(vscale x )?]][[VEC_FACTOR:[0-9]+]] x i32>
# COM: load <[[VSCALE:(vscale x )?]][[VEC_FACTOR:[0-9]+]] x i32>
# CHECK: mul <[[VSCALE]][[VEC_FACTOR]] x i32>
# CHECK: store <[[VSCALE]][[VEC_FACTOR]] x i32>

# COM: Int64
# CHECK: @japi1_prod_vT_v
# CHECK: load <[[VSCALE:(vscale x )?]][[VEC_FACTOR:[0-9]+]] x i64>
# COM: load <[[VSCALE:(vscale x )?]][[VEC_FACTOR:[0-9]+]] x i64>
# CHECK: mul <[[VSCALE]][[VEC_FACTOR]] x i64>
# CHECK: store <[[VSCALE]][[VEC_FACTOR]] x i64>

Expand All @@ -67,25 +67,25 @@ end

# COM: Float32
# CHECK: @japi1_prod_v_M_vT
# CHECK: load <[[VSCALE:(vscale x )?]][[VEC_FACTOR:[0-9]+]] x float>
# COM: load <[[VSCALE:(vscale x )?]][[VEC_FACTOR:[0-9]+]] x float>
# CHECK: fmul <[[VSCALE]][[VEC_FACTOR]] x float>
# CHECK: store <[[VSCALE]][[VEC_FACTOR]] x float>

# COM: Float64
# CHECK: @japi1_prod_v_M_vT
# CHECK: load <[[VSCALE:(vscale x )?]][[VEC_FACTOR:[0-9]+]] x double>
# COM: load <[[VSCALE:(vscale x )?]][[VEC_FACTOR:[0-9]+]] x double>
# CHECK: fmul <[[VSCALE]][[VEC_FACTOR]] x double>
# CHECK: store <[[VSCALE]][[VEC_FACTOR]] x double>

# COM: Int32
# CHECK: @japi1_prod_v_M_vT
# CHECK: load <[[VSCALE:(vscale x )?]][[VEC_FACTOR:[0-9]+]] x i32>
# COM: load <[[VSCALE:(vscale x )?]][[VEC_FACTOR:[0-9]+]] x i32>
# CHECK: mul <[[VSCALE]][[VEC_FACTOR]] x i32>
# CHECK: store <[[VSCALE]][[VEC_FACTOR]] x i32>

# COM: Int64
# CHECK: @japi1_prod_v_M_vT
# CHECK: load <[[VSCALE:(vscale x )?]][[VEC_FACTOR:[0-9]+]] x i64>
# COM: load <[[VSCALE:(vscale x )?]][[VEC_FACTOR:[0-9]+]] x i64>
# CHECK: mul <[[VSCALE]][[VEC_FACTOR]] x i64>
# CHECK: store <[[VSCALE]][[VEC_FACTOR]] x i64>

Expand Down
6 changes: 3 additions & 3 deletions test/llvmpasses/pipeline-o2.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,21 @@ end
# COM: memset checks

# COM: INT64
# ALL-LABEL: define nonnull {} addrspace(10)* @julia_zeros
# ALL-LABEL: define nonnull ptr addrspace(10) @julia_zeros
# ALL-NOT: bounds_error
# COM: memset is not used with bounds checks on (too late in the pipeline)
# BC_OFF: llvm.memset
# BC_AUTO: llvm.memset

# COM: INT32
# ALL-LABEL: define nonnull {} addrspace(10)* @julia_zeros
# ALL-LABEL: define nonnull ptr addrspace(10) @julia_zeros
# ALL-NOT: bounds_error
# COM: memset is not used with bounds checks on (too late in the pipeline)
# BC_OFF: llvm.memset
# BC_AUTO: llvm.memset

# COM: INT16
# ALL-LABEL: define nonnull {} addrspace(10)* @julia_zeros
# ALL-LABEL: define nonnull ptr addrspace(10) @julia_zeros
# ALL-NOT: bounds_error
# COM: memset is not used with bounds checks on (too late in the pipeline)
# BC_OFF: llvm.memset
Expand Down

0 comments on commit fd91a0f

Please sign in to comment.