Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/cmd/llvmplugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,32 @@ if(BUILD_TESTING)
"ptr nest %context"
)

add_test(
NAME GoALLCStatepoints.SupportedParamAttrsRewrite
COMMAND
"${GOALLC_LLC_EXECUTABLE}"
"-load-pass-plugin=$<TARGET_FILE:GoALLCStatepoints>"
-goallc-pass-plugin-emit-ir
-filetype=null
-o -
"${CMAKE_CURRENT_SOURCE_DIR}/testdata/supported-param-attrs.ll"
)
set_tests_properties(GoALLCStatepoints.SupportedParamAttrsRewrite PROPERTIES
PASS_REGULAR_EXPRESSION
"ptr noundef nonnull align 8 %argument"
)

add_test(
NAME GoALLCStatepoints.SupportedParamAttrsCodegen
COMMAND
"${GOALLC_LLC_EXECUTABLE}"
"-load-pass-plugin=$<TARGET_FILE:GoALLCStatepoints>"
-verify-machineinstrs
-filetype=obj
-o "${CMAKE_CURRENT_BINARY_DIR}/supported-param-attrs.goobj"
"${CMAKE_CURRENT_SOURCE_DIR}/testdata/supported-param-attrs.ll"
)

add_test(
NAME GoALLCStatepoints.CallOnlyPointersNotLive
COMMAND
Expand Down
15 changes: 12 additions & 3 deletions src/cmd/llvmplugin/GoALLCStatepoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -692,13 +692,22 @@ Error validateSafepoint(const SafepointRecord &Record) {
"GoALLC statepoints only support a single deopt call operand bundle");
for (unsigned I = 0; I != Call.arg_size(); ++I) {
for (Attribute Attr : Call.getAttributes().getParamAttrs(I)) {
// These non-ABI attributes remain valid after LLVM's generic
// RewriteStatepointsForGC pass and are natively accepted by both the
// statepoint verifier and SelectionDAG call lowering. O2 commonly
// infers them on otherwise ordinary runtime calls. Keep ABI-affecting
// attributes fail closed except for nest, whose Go closure ABI lowering
// is covered separately.
if (!Attr.hasAttribute(Attribute::Nest) &&
!Attr.hasAttribute(Attribute::Captures) &&
!Attr.hasAttribute(Attribute::ReadOnly))
!Attr.hasAttribute(Attribute::ReadOnly) &&
!Attr.hasAttribute(Attribute::NonNull) &&
!Attr.hasAttribute(Attribute::NoUndef) &&
!Attr.hasAttribute(Attribute::Alignment))
return createStringError(
std::errc::not_supported,
"GoALLC statepoints only support nest, captures, and readonly "
"call parameter attributes");
"GoALLC statepoints do not support call parameter attribute '%s'",
Attr.getAsString().c_str());
}
}
for (Value *V : Record.Live) {
Expand Down
11 changes: 11 additions & 0 deletions src/cmd/llvmplugin/testdata/supported-param-attrs.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
target triple = "aarch64-unknown-linux-goobj"

declare goabiinternal void @supported_callee(ptr)

define goabiinternal void @supported_param_attrs(ptr %argument) #0 gc "goallc" {
entry:
call goabiinternal void @supported_callee(ptr noundef nonnull align 8 %argument)
ret void
}

attributes #0 = { "frame-pointer"="non-leaf" "go-stack-growth-statepoint" }